(
&mut self,
token: T,
expected: Expected,
)
| 124 | } |
| 125 | |
| 126 | fn validate_token<'source, T>( |
| 127 | &mut self, |
| 128 | token: T, |
| 129 | expected: Expected, |
| 130 | ) -> Result<T, LexerDiagnostic> |
| 131 | where |
| 132 | T: AsRef<Token<'source>>, |
| 133 | { |
| 134 | let token_ref = token.as_ref(); |
| 135 | let syntax_kind = token_ref.kind.syntax(); |
| 136 | |
| 137 | match expected { |
| 138 | Expected::Hint(_) => return Ok(token), |
| 139 | Expected::Validate(set) if set.contains(syntax_kind) => { |
| 140 | return Ok(token); |
| 141 | } |
| 142 | Expected::Validate(_) => {} |
| 143 | } |
| 144 | |
| 145 | let span = self.insert_range(token_ref.span); |
| 146 | |
| 147 | Err(unexpected_token(span, syntax_kind, expected.into_set())) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /// Represents expectations for token validation in the parser. |
no test coverage detected