Expand description
The lexer: the single cssToken matcher, the scanners it reads spans
with, and the token buffer the rule machine peeks into.
CSS is context-sensitive — the same characters can begin a selector, a
property or a value — so the lexer owns the hard tokenisation and the
grammar only assembles typed nodes from what it emits. Which token comes
out depends on the rule that is active when the character is read, which is
why Lex::peek takes a rule name.
See ts/src/css.ts for the canonical commentary; the three ports are kept
in step.
Structs§
- Error
- A parse failure.
- Lex
- The lexer, plus the token buffer the rule machine peeks into.
- Point
- The lexer’s scan position.
- Token
- One lexed token.
Enums§
- Tin
- A token kind.
Functions§
- end_pos
- The position just after a token’s last character.
- es_
is_ whitespace - Whether
cis whitespace as ECMAScript defines it, which is NOT whatchar::is_whitespaceanswers. - es_trim
- Trim as JavaScript’s
String.prototype.trimdoes. Seees_is_whitespacefor why this is notstr::trim. - split_
selectors - Split a selector-group prelude on its top-level commas (commas inside
strings,
()or[]are part of a single selector), stripping comments and trimming each selector. An empty prelude yields an empty list. - start_
pos - A token’s first-character position (1-based line and column).
- strip_
comments - Remove
/* ... */comments from a selector or value run, leaving quoted strings (which may contain/*) untouched. - vendor_
prefix ^(-[a-z]+-): a vendor prefix on an at-keyword, e.g.-webkit-keyframes.