@precedence { attribute @left, structure @left, call, valueCompareOp, valueOp @left, layerName } @skip { whitespace | Comment } @top StyleSheet { item* } @top Styles { blockContent } item { RuleSet | ImportStatement | MediaStatement | CharsetStatement | NamespaceStatement | KeyframesStatement | SupportsStatement | ScopeStatement | AtRule } RuleSet { selector ("," selector)* Block } ImportStatement { atKw<"import"> value Layer { queryCalleeKw<"layer"> (!layerName "(" LayerName ("." LayerName)* ")")? | queryKw<"layer"> }? commaSep ";" } LayerName { identifier } MediaStatement { atKw<"media"> commaSep Block } CharsetStatement { atKw<"charset"> value ";" } NamespaceStatement { atKw<"namespace"> NamespaceName { identifier }? (StringLiteral | CallLiteral) ";" } KeyframesStatement { atKw<"keyframes"> KeyframeName { identifier | StringLiteral } KeyframeList } KeyframeSelector { KeyframeRangeName { identifier } NumberLiteral? | NumberLiteral } KeyframeList { "{" (KeyframeSelector ("," KeyframeSelector)* Block)* "}" } SupportsStatement { atKw<"supports"> query Block } ScopeStatement { atKw<"scope"> ParenthesizedSelector? (@extend[@name=to] ParenthesizedSelector)? Block } AtRule { AtKeyword commaSep (";" | Block) } Block[@dynamicPrecedence=1] { "{" blockContent "}" } blockContent { ~item item* (Declaration (";" ~item item* Declaration?)*)? } selector { UniversalSelector | TagSelector { ~item TagName { identifier ~item } } | NestingSelector | ClassSelector { selector? !attribute "." ClassName { identifier } } | PseudoClassSelector { selector? !attribute (":" | "::") ( PseudoClassName { identifier } | pseudoClassWithArg ArgList | PseudoClassName { callee } ArgList) } | IdSelector { selector? !attribute "#" IdName { identifier } } | AttributeSelector { selector? !attribute "[" AttributeName { identifier } (MatchOp value)? "]" } | ChildSelector { selector? !structure ChildOp selector } | DescendantSelector { selector !structure descendantOp selector } | SiblingSelector { selector? !structure SiblingOp selector } } pseudoClassWithArg { @specialize[@name=PseudoClassName] } NumberLiteral { numberLiteralInner Unit? } ArgList { "(" commaSep ")" } Declaration { (PropertyName { identifier ~item } | VariableName) ":" (value (","? value)*)? Important? } query { KeywordQuery { queryIdentifier } | FeatureQuery { "(" FeatureName ":" value+ ")" } | BinaryQuery { query !valueOp @specialize[@name=LogicOp] query } | ComparisonQuery { "(" (queryValue | FeatureName) !valueCompareOp CompareOp (queryValue | FeatureName) (!valueCompareOp CompareOp (queryValue | FeatureName))? ")" } | UnaryQuery { @specialize[@name=UnaryQueryOp] query } | ParenthesizedQuery { "(" query ")" } | SelectorQuery { queryCalleeKw<"selector"> ParenthesizedSelector } | CallQuery { QueryCallee ArgList } } ParenthesizedSelector { "(" selector ")" } FeatureName { queryIdentifier } value { VariableName | ValueName { identifier } | ParenthesizedValue { "(" token* ")" } | BracketedValue { "[" token* "]" } | BracedValue { "{" token* "}" } | ColorLiteral | NumberLiteral | StringLiteral | BinaryExpression { value !valueOp BinOp value } | CallExpression | IfExpression | CallLiteral } token { value | AtKeyword | "#" | ";" | "." | ":" } queryValue { queryVariableName | ColorLiteral | NumberLiteral | StringLiteral } IfExpression { @specialize[@name=if] ArgList { "(" (IfBranch ";")* IfBranch ";"? ")" } } IfBranch { query ":" value } CallLiteral { @specialize[@name=CallTag] "(" (ParenthesizedContent | StringLiteral)? ")" } CallExpression { (Callee { callee } | VariableName) !call ArgList } @skip {} { Comment[isolate] { "/*" (commentContent | commentLineBreak)* commentEnd } } @local tokens { commentEnd { "*/" | @eof } commentLineBreak { "\n" } @else commentContent } commaSep { "" | value ("," value?)* } queryKw { @specialize[@name={name}] } queryCalleeKw { @specialize[@name={name}] } atKw { @specialize[@name={name}] } @external tokens descendant from "./tokens" { descendantOp } @external tokens unitToken from "./tokens" { Unit } @external tokens identifiers from "./tokens" { identifier, callee, VariableName } @external tokens queryIdentifiers from "./tokens" { @conflict { identifier, VariableName, callee } queryIdentifier, queryVariableName[@name=VariableName], QueryCallee } @tokens { UniversalSelector { "*" } NestingSelector { "&" } AtKeyword { "@" "-"? @asciiLetter (@asciiLetter | @digit | "-")* } MatchOp { $[~^|*$]? "=" } ChildOp { ">" ">"? } CompareOp { $[<>] "="? | "=" } SiblingOp { "~" | "+" } BinOp { $[+\-*/] } Important { "!important" } whitespace { @whitespace+ } hexDigit { @digit | $[a-fA-F] } ParenthesizedContent { !['")] ![)]+ } @precedence { whitespace, ParenthesizedContent, "/*" } ColorLiteral { "#" hexDigit hexDigit hexDigit (hexDigit (hexDigit hexDigit (hexDigit hexDigit)?)?)? } numberLiteralInner { ("+" | "-")? (@digit+ ("." @digit*)? | "." @digit+) (("e" | "E") ("+" | "-")? @digit+)? } @precedence { numberLiteralInner, BinOp, SiblingOp } @precedence { numberLiteralInner, "." } StringLiteral[isolate] { "\"" (!["\n\\] | "\\" _)* "\"" | "'" (!['\n\\] | "\\" _)* "'" } "#" "." ":" "::" ";" "," "(" ")" "[" "]" "{" "}" } @external propSource cssHighlighting from "./highlight" @detectDelim