Expand description
The lexer: the single cssToken matcher the plugin installs on the
engine, and the scanners it reads spans with.
CSS is context-sensitive — the same characters can begin a selector, a property or a value — so the matcher 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: the engine reads a token only when the alternate being tried needs one, under the rule trying it, and passes that rule to the matcher.
See ts/src/css.ts for the canonical commentary; the three ports are kept
in step, and this module follows buildCssTokenMatcher there line for
line.
Structs§
- Error
- A parse failure.
Enums§
- Tin
- A token kind.
Functions§
- 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. - 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.