1mod animation;
2mod parser;
3mod style;
4mod unit;
5
6pub mod error;
7
8pub use animation::*;
9pub use declaration::Declaration;
10pub use error::ParseError;
11pub use parser::PseudoClass;
12pub use style::StyleSheet;
13
14pub(crate) use parser::*;
15pub use unit::*;
16
17use lexer::Token;
18
19#[must_use]
34pub fn css_to_rules(input: &str) -> Result<Vec<Rule<'_>>, Vec<SyntaxError>> {
35 let tokens = Lexer::new(input).tokens();
36 analyze_tokens(&tokens, input)?;
37 let rules = Parser::new(tokens).parse();
38 Ok(replace_vars(rules))
39}
40
41pub fn analyze(input: &str) -> Result<(), Vec<SyntaxError>> {
42 let tokens = Lexer::new(input).tokens();
43 let res = parser::analyze_tokens(&tokens, input);
44
45 if !res.is_empty() {
46 return Err(res);
47 }
48
49 Ok(())
50}
51
52pub fn analyze_tokens<'a>(
53 tokens: &[Token<'a>],
54 input: &'a str,
55) -> Result<(), Vec<SyntaxError<'a>>> {
56 let res = parser::analyze_tokens(&tokens, input);
57
58 if !res.is_empty() {
59 return Err(res);
60 }
61
62 Ok(())
63}