package cascade
Module Cascade.TokenSource
CSS Syntax Module Level 3 section 4.2: token taxonomy.
Types only; the section 4.3 tokenization algorithm lives in Lexer. Every token carries the source Loc.t it was read from.
Whether a Hash starts an identifier (#abc) or is unrestricted (#123). Only id-flag hashes are valid as ID selectors.
The parsed numeric value, its original textual representation, and the integer-vs-number flag.
The three kinds of balanced bracket character used in CSS blocks.
type kind = | Ident of string| Function of string(*Ident immediately followed by
*)(.| At_keyword of string(*
*)@followed by an ident.| Hash of {value : string;hash_flag : hash_flag;
}| String of {}(*String literal.
*)quoteis the opening quote character (double or single); the spec treats both as equivalent delimiters (CSS Syntax section 4.3.5) but we record it for quote-sensitive rules (e.g.@charsetper CSS Syntax section 8.2) and to round-trip the input style.terminatedisfalsewhen the lexer reached EOF without seeing the closing quote (CSS Syntax section 4.3.5 returns the string token but flags a parse error); the serializer omits the closing quote so the original byte sequence is preserved.| Bad_string(*Unterminated string (newline or EOF before the closing quote).
*)| Url of string| Bad_url(*Malformed
*)url(...)body (unquoted content with invalid chars).| Delim of string(*Any single Unicode code point not consumed by another token rule. Stored as the UTF-8 byte sequence (1 to 4 bytes).
*)| Number_tok of number| Percentage of number| Dimension of {number : number;unit_ : string;
}| Whitespace(*Any run of whitespace characters.
*)| Unicode_range of {start_value : int;end_value : int;form : unicode_range_form;
}(*
*)U+XXXX/U+XXXX-YYYY/U+XX??(CSS Syntax section 4.3.14). The three syntactic forms are normalised to the[start_value, end_value]inclusive range;start_value = end_valuefor the single-codepoint form.formkeeps the typed token shape for non-minified fidelity.| Cdo(*
*)<!--at top level.| Cdc(*
*)-->at top level.| Colon| Semicolon| Comma| Open of bracket(*Opening bracket of a balanced group.
*)| Close of bracket(*Closing bracket of a balanced group.
*)| Eof
Token payload: the section 4.2 variants without the location wrapper.
A located token: the section 4.2 payload plus the source range it covers.
v ~kind ~loc is a token with the given payload and location.
synthetic k is a token with payload k and Loc.dummy - for test fixtures and synthetic values that don't come from a real input.