Parser
MMO\client\scs · 1 symbol · generated 5 Oct 2026
Parser
Parser.php:24Turns the tokens of a .scs source into an ast (StylesheetNode).
- Namespace
MMO\client\scs
Index
| CSS_FUNCTIONS | css functions whose arguments must never be evaluated as arithmetic (calc(100% - 20px)) | |
| PRECEDENCE | operator precedence, highest binds tighter | |
| filename | ||
| index | ||
| source | ||
| tokens | ||
| accept($type, $text) | ||
| at($type, $text) | ||
| error($token, $message, $context) | ||
| expect($type, $text) | ||
| expectTerminator($node) | Consume the ; that ends a statement, or say where it is missing. | |
| getFilename() | ||
| getSource() | ||
| location($token) | ||
| needsTerminator($node) | ||
| next() | ||
| parse() | ||
| parseArguments($raw, $selector) | Read the arguments of a call. | |
| parseArray() | [4, 8, 16] | |
| parseAtRule() | ||
| parseBlock() | Parse a { ... } block. | |
| parseComponent() | ||
| parseConfig() | ||
| parseCssTerm($selector) | Read one term of a css value: everything that is not scs is kept as written. | |
| parseDefinition($class) | `@style name($a, $b = default) { ... | |
| parseExpression($precedence) | Parse a full expression, where + - * / are arithmetic (PRECEDENCE). | |
| parseFor() | ||
| parseIdentPrimary() | ||
| parseIdentTerm($selector) | An identifier in a css value is a call (spacing(4), lib::step(3), php::round(1.2), calc(...)), a namespaced reference (context::density) or plain css text. | |
| parseIf() | ||
| parseImport() | ||
| parseInterpolated() | Parse the body of an interpolation: a single expression. | |
| parseInterpolation() | ||
| parseLet() | ||
| parseName() | Read a reference to a definition: center, or lib::center for one that belongs to another file. | |
| parseNamespace($token) | @namespace ui -- name the definitions of this file. | |
| parseOrder() | ||
| parseParameters() | ||
| parseParenthesis() | (a + b) or a map literal (sm: 8px, md: 16px). | |
| parsePrimary() | ||
| parseRawArgument($selector) | Read one argument of a css-only function (calc, clamp, ...): everything is kept verbatim but $variables and ${interpolations}, which are still resolved. | |
| parseRawAtRule($token) | A css at-rule the language does not interpret: @media, @keyframes, @font-face, @supports... | |
| parseRuleOrDeclaration() | Decide between a nested rule and a declaration by looking ahead for the token that ends the statement: a { means everything read so far was a selector. | |
| parseScreen() | ||
| parseStatement() | ||
| parseStatements($inBlock) | ||
| parseString() | Read a string token, keeping the ${...} / #{...} it may contain interpolable. | |
| parseTheme() | ||
| parseThemeEntries($prefix) | Read the group { key: value } body of a @theme, flattening it into dotted paths. | |
| parseThemeValue() | Read the value of a theme token. | |
| parseUnary() | ||
| parseUse() | ||
| parseValue() | Parse the whole source as a single value, for the evaluation api (Compiler::evaluate). | |
| parseValueList($css, $stop, $selector) | Read a css value, a selector or an @let value: a list of terms, up to the end of the statement. | |
| parseVariableRef() | ||
| parseVariant() | ||
| peek($offset) | ||
| skipNewlines() | Skip end of lines, which are only statement separators. | |
| skipTerminators() | Skip what separates two statements: ; and the newlines around it. | |
| startsThemeEntry($offset) | ||
| __construct($source, $filename, $line, $col) |
Constants2
CSS_FUNCTIONS
css functions whose arguments must never be evaluated as arithmetic (calc(100% - 20px))
PRECEDENCE
operator precedence, highest binds tighter
Properties4
filename
- Type
- string
index
- Type
- int
source
- Type
- string
tokens
- Type
- array
Methods55
accept($type, $text)
Parser.php:97at($type, $text)
Parser.php:93error($token, $message, $context)
Parser.php:121expect($type, $text)
Parser.php:101expectTerminator($node)
Parser.php:180Consume the ; that ends a statement, or say where it is missing.
getFilename()
Parser.php:67| returns | string |
getSource()
Parser.php:68| returns | string |
location($token)
Parser.php:125| $token | Token | |
| returns | SourceLocation |
needsTerminator($node)
Parser.php:162next()
Parser.php:87| returns | Token |
parse()
Parser.php:74| returns | StylesheetNode | the parsed source |
| throws | on any syntax error, located on the offending token |
parseArguments($raw, $selector)
Parser.php:699Read the arguments of a call.
parseArray()
Parser.php:962[4, 8, 16]
| returns | Node |
parseAtRule()
Parser.php:254| returns | Node |
parseBlock()
Parser.php:188Parse a { ... } block.
| returns | array |
parseComponent()
Parser.php:444| returns | ComponentNode |
parseConfig()
Parser.php:564| returns | ConfigNode |
parseCssTerm($selector)
Parser.php:631Read one term of a css value: everything that is not scs is kept as written.
parseDefinition($class)
Parser.php:381@style name($a, $b = default) { ... } / @fn name($a) { ... }
parseExpression($precedence)
Parser.php:866Parse a full expression, where + - * / are arithmetic (PRECEDENCE).
parseFor()
Parser.php:512| returns | ForNode |
parseIdentPrimary()
Parser.php:921| returns | Node |
parseIdentTerm($selector)
Parser.php:653An identifier in a css value is a call (spacing(4), lib::step(3), php::round(1.2), calc(...)), a namespaced reference (context::density) or plain css text.
parseIf()
Parser.php:490| returns | IfNode |
parseImport()
Parser.php:535| returns | ImportNode | AtRuleNode |
parseInterpolated()
Parser.php:814Parse the body of an interpolation: a single expression.
| returns | Node |
parseInterpolation()
Parser.php:790| returns | Node |
parseLet()
Parser.php:281| returns | VariableNode |
parseName()
Parser.php:400Read a reference to a definition: center, or lib::center for one that belongs to another file.
| returns | array | ?string, name: string} |
parseNamespace($token)
Parser.php:415@namespace ui -- name the definitions of this file.
parseOrder()
Parser.php:486| returns | OrderNode |
parseParameters()
Parser.php:425| returns | array | [['name' => string, 'default' => ?Node], ...] |
parseParenthesis()
Parser.php:932(a + b) or a map literal (sm: 8px, md: 16px).
| returns | Node |
parsePrimary()
Parser.php:901| returns | Node |
parseRawArgument($selector)
Parser.php:723Read one argument of a css-only function (calc, clamp, ...): everything is kept verbatim but $variables and ${interpolations}, which are still resolved.
| $selector = false | bool | true to keep reading the argument as a selector |
| returns | ValueListNode |
parseRawAtRule($token)
Parser.php:580A css at-rule the language does not interpret: @media, @keyframes, @font-face, @supports...
| $token | Token | |
| returns | AtRuleNode |
parseRuleOrDeclaration()
Parser.php:214Decide between a nested rule and a declaration by looking ahead for the token that ends the statement: a { means everything read so far was a selector.
| returns | Node |
parseScreen()
Parser.php:479| returns | ScreenNode |
parseStatement()
Parser.php:196| returns | Node |
parseStatements($inBlock)
Parser.php:137parseString()
Parser.php:751Read a string token, keeping the ${...} / #{...} it may contain interpolable.
| returns | Node | a LiteralNode for a plain string, a StringNode otherwise |
parseTheme()
Parser.php:287| returns | ThemeNode |
parseThemeEntries($prefix)
Parser.php:305Read the group { key: value } body of a @theme, flattening it into dotted paths.
parseThemeValue()
Parser.php:345Read the value of a theme token.
| returns | ValueListNode |
parseUnary()
Parser.php:889| returns | Node |
parseUse()
Parser.php:461| returns | UseNode |
parseValue()
Parser.php:803Parse the whole source as a single value, for the evaluation api (Compiler::evaluate).
| returns | ValueListNode |
parseValueList($css, $stop, $selector)
Parser.php:596Read a css value, a selector or an @let value: a list of terms, up to the end of the statement.
| $css | bool | true for css context (+ - * / stay literal), false for an expression context |
| $stop = [] | array | extra punctuation that ends the list (not consumed) |
| $selector = false | bool | |
| returns | ValueListNode |
parseVariableRef()
Parser.php:824| returns | Node |
parseVariant()
Parser.php:456| returns | VariantNode |
peek($offset)
Parser.php:83skipNewlines()
Parser.php:112Skip end of lines, which are only statement separators.
| returns | void |
skipTerminators()
Parser.php:117Skip what separates two statements: ; and the newlines around it.
| returns | void |