Expand description
MusKitty CSS Parser
Implements the parsing stage of the CSS Syntax Module Level 3 (§5
“Parser Algorithms”). Extracted from muskitty-css as a standalone
crate for independent versioning and publication.
Re-exports Token / Tokenizer / CssTokenizer from
muskitty-css-tokenizer so downstream crates (e.g.
muskitty-selectors) can depend on this single crate to access
the full CSS Syntax stack.
§Architecture
The parser follows the two-stage model described in CSS Syntax §3.1:
- Tokenization — handled by
muskitty-css-tokenizer(re-exported here for convenience). - Parsing — consumes tokens and produces CSS objects: stylesheets, rules, declarations, component values (§5, fully implemented).
§Top-level API
parse_stylesheet— full stylesheet parse (§5.4.3)parse_rule— single rule parse (§5.4.6)parse_declaration— single declaration parse (§5.4.7)parse_component_value— single component value (§5.4.8)parse_list_of_component_values— list of component values (§5.4.9)parse_comma_separated_list_of_component_values— comma-separated list (§5.4.10)parse_a_grammar/parse_a_comma_separated_list_with_grammar— generic grammar hooks (§5.4.1 / §5.4.2)tokenize— token stream only (§4.3)
§References
- CSS Syntax Module Level 3: https://drafts.csswg.org/css-syntax-3/
- Spec source (Markdown):
D:\CSSWG\css-syntax-3\Overview.md
Re-exports§
pub use algorithms::consume_a_block;pub use algorithms::consume_a_blocks_contents;pub use algorithms::consume_a_component_value;pub use algorithms::consume_a_declaration;pub use algorithms::consume_a_function;pub use algorithms::consume_a_list_of_component_values;pub use algorithms::consume_a_qualified_rule;pub use algorithms::consume_a_simple_block;pub use algorithms::consume_a_stylesheets_contents;pub use algorithms::consume_a_unicode_range_value;pub use algorithms::consume_an_at_rule;pub use algorithms::consume_the_remnants_of_a_bad_declaration;pub use algorithms::BlockContents;pub use entry_points::parse_a_blocks_contents;pub use entry_points::parse_a_comma_separated_list_of_component_values;pub use entry_points::parse_a_component_value;pub use entry_points::parse_a_declaration;pub use entry_points::parse_a_list_of_component_values;pub use entry_points::parse_a_rule;pub use entry_points::parse_a_stylesheet;pub use entry_points::parse_a_stylesheets_contents;pub use grammar::parse_a_comma_separated_list_with_grammar;pub use grammar::parse_a_grammar;pub use grammar::Grammar;pub use token_stream::TokenStream;pub use types::AtRule;pub use types::BlockKind;pub use types::ComponentValue;pub use types::Declaration;pub use types::Function;pub use types::ParseError;pub use types::QualifiedRule;pub use types::Rule;pub use types::SimpleBlock;pub use types::Stylesheet;
Modules§
- algorithms
- §5.5 Parser Algorithms.
- entry_
points - §5.4 Parser Entry Points.
- grammar
- §5.4.1 / §5.4.2 grammar-based parse entry points.
- token_
stream - Token stream (§5.3 L1722-1814).
- types
- CSS Parsing Results data structures (§5.2).
Structs§
- CssTokenizer
- The CSS tokenizer (§4.3).
- Numeric
- A numeric value carried by
<number-token>,<percentage-token>, and<dimension-token>(§4.3.13).
Enums§
- Hash
Type - The type flag on a
<hash-token>(§4.1, §4.3.4). - State
- The current state of the CSS tokenizer.
- Token
- A CSS token (§4.1).
Traits§
- Tokenizer
- The CSS tokenizer.
Functions§
- parse_
comma_ separated_ list_ of_ component_ values - Parse a CSS string into a comma-separated list of
ComponentValue(§5.4.10). - parse_
component_ value - Parse a CSS string into a single
ComponentValue(§5.4.8). - parse_
declaration - Parse a CSS string into a single
Declaration(§5.4.7). - parse_
list_ of_ component_ values - Parse a CSS string into a list of
ComponentValue(§5.4.9). - parse_
rule - Parse a CSS string into a single
Rule(§5.4.6). - parse_
stylesheet - Parse a CSS string into a
Stylesheet(§5.4.3). - tokenize
- Tokenize a CSS input string into a vector of tokens.