(&mut self)
| 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) |
no test coverage detected