MCPcopy Create free account
hub / github.com/csskit/csskit / parse

Method parse

crates/css_parse/src/comparison.rs:32–56  ·  view source on GitHub ↗
(p: &mut Parser<'a, I>)

Source from the content-addressed store, hash-verified

30
31impl<'a> Parse<'a> for Comparison {
32 fn parse<I>(p: &mut Parser<'a, I>) -> Result<Comparison>
33 where
34 I: Iterator<Item = crate::Cursor> + Clone,
35 {
36 let c = p.peek_n(1);
37 match c.token().char() {
38 Some('=') => p.parse::<T![=]>().map(Comparison::Equal),
39 Some('>') => {
40 if <T![>=]>::peek(p, c) {
41 p.parse::<T![>=]>().map(Comparison::GreaterThanEqual)
42 } else {
43 p.parse::<T![>]>().map(Comparison::GreaterThan)
44 }
45 }
46 Some('<') => {
47 if <T![<=]>::peek(p, c) {
48 p.parse::<T![<=]>().map(Comparison::LessThanEqual)
49 } else {
50 p.parse::<T![<]>().map(Comparison::LessThan)
51 }
52 }
53 Some(_) => Err(Diagnostic::new(p.next(), Diagnostic::unexpected_delim))?,
54 _ => Err(Diagnostic::new(p.next(), Diagnostic::unexpected))?,
55 }
56 }
57}
58
59impl ToCursors for Comparison {

Callers

nothing calls this directly

Calls 5

ErrClass · 0.85
peek_nMethod · 0.80
charMethod · 0.80
tokenMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected