MCPcopy
hub / github.com/postcss/postcss / other

Method other

lib/parser.js:385–446  ·  view source on GitHub ↗
(start)

Source from the content-addressed store, hash-verified

383 }
384
385 other(start) {
386 let end = false
387 let type = null
388 let colon = false
389 let bracket = null
390 let brackets = []
391 let customProperty = start[1].startsWith('--')
392
393 let tokens = []
394 let token = start
395 while (token) {
396 type = token[0]
397 tokens.push(token)
398
399 if (type === '(' || type === '[') {
400 if (!bracket) bracket = token
401 brackets.push(type === '(' ? ')' : ']')
402 } else if (customProperty && colon && type === '{') {
403 if (!bracket) bracket = token
404 brackets.push('}')
405 } else if (brackets.length === 0) {
406 if (type === ';') {
407 if (colon) {
408 this.decl(tokens, customProperty)
409 return
410 } else {
411 break
412 }
413 } else if (type === '{') {
414 this.rule(tokens)
415 return
416 } else if (type === '}') {
417 this.tokenizer.back(tokens.pop())
418 end = true
419 break
420 } else if (type === ':') {
421 colon = true
422 }
423 } else if (type === brackets[brackets.length - 1]) {
424 brackets.pop()
425 if (brackets.length === 0) bracket = null
426 }
427
428 token = this.tokenizer.nextToken()
429 }
430
431 if (this.tokenizer.endOfFile()) end = true
432 if (brackets.length > 0) this.unclosedBracket(bracket)
433
434 if (end && colon) {
435 if (!customProperty) {
436 while (tokens.length) {
437 token = tokens[tokens.length - 1][0]
438 if (token !== 'space' && token !== 'comment') break
439 this.tokenizer.back(tokens.pop())
440 }
441 }
442 this.decl(tokens, customProperty)

Callers 1

parseMethod · 0.95

Calls 5

declMethod · 0.95
ruleMethod · 0.95
unclosedBracketMethod · 0.95
unknownWordMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected