MCPcopy
hub / github.com/postcss/postcss / nextToken

Function nextToken

lib/tokenize.js:53–258  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

51 }
52
53 function nextToken(opts) {
54 if (returned.length) return returned.pop()
55 if (pos >= length) return
56
57 let ignoreUnclosed = opts ? opts.ignoreUnclosed : false
58
59 code = css.charCodeAt(pos)
60
61 switch (code) {
62 case NEWLINE:
63 case SPACE:
64 case TAB:
65 case CR:
66 case FEED: {
67 next = pos
68 do {
69 next += 1
70 code = css.charCodeAt(next)
71 } while (
72 code === SPACE ||
73 code === NEWLINE ||
74 code === TAB ||
75 code === CR ||
76 code === FEED
77 )
78
79 currentToken = ['space', css.slice(pos, next)]
80 pos = next - 1
81 break
82 }
83
84 case OPEN_SQUARE:
85 case CLOSE_SQUARE:
86 case OPEN_CURLY:
87 case CLOSE_CURLY:
88 case COLON:
89 case SEMICOLON:
90 case CLOSE_PARENTHESES: {
91 let controlChar = String.fromCharCode(code)
92 currentToken = [controlChar, controlChar, pos]
93 break
94 }
95
96 case OPEN_PARENTHESES: {
97 prev = buffer.length ? buffer.pop()[1] : ''
98 n = css.charCodeAt(pos + 1)
99 if (
100 prev === 'url' &&
101 n !== SINGLE_QUOTE &&
102 n !== DOUBLE_QUOTE &&
103 n !== SPACE &&
104 n !== NEWLINE &&
105 n !== TAB &&
106 n !== FEED &&
107 n !== CR
108 ) {
109 next = pos
110 do {

Callers

nothing calls this directly

Calls 2

unclosedFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…