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

Method parse_entirely

crates/css_parse/src/parser.rs:142–169  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

140 }
141
142 pub fn parse_entirely<T: Parse<'a> + ToCursors>(&mut self) -> ParserReturn<'a, T> {
143 let output = match T::parse(self) {
144 Ok(output) => Some(output),
145 Err(error) => {
146 self.errors.push(error);
147 None
148 }
149 };
150 let remaining_non_trivia = !self.at_end() && self.peek_n(1) != Kind::Eof;
151 let at_end = self.peek_n_with_skip(1, KindSet::NONE) == Kind::Eof;
152
153 if !at_end {
154 let start = self.peek_n_with_skip(1, KindSet::NONE);
155 let mut end;
156 loop {
157 end = self.next();
158 if end == Kind::Eof {
159 break;
160 }
161 }
162 if remaining_non_trivia {
163 self.errors.push(Diagnostic::new(start, Diagnostic::expected_end).with_end_cursor(end));
164 }
165 }
166 let errors = mem::replace(&mut self.errors, Vec::new_in(self.bump));
167 let trivia = mem::replace(&mut self.trivia, Vec::new_in(self.bump));
168 ParserReturn::new(output, self.source_text, errors, trivia)
169 }
170
171 pub fn parse<T: Parse<'a>>(&mut self) -> Result<T> {
172 T::parse(self)

Callers 1

runMethod · 0.80

Calls 6

peek_nMethod · 0.80
peek_n_with_skipMethod · 0.80
with_end_cursorMethod · 0.80
parseFunction · 0.50
at_endMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected