MCPcopy Create free account
hub / github.com/hashintel/hash / validate_token

Method validate_token

libs/@local/hashql/syntax-jexpr/src/parser/state.rs:126–148  ·  view source on GitHub ↗
(
        &mut self,
        token: T,
        expected: Expected,
    )

Source from the content-addressed store, hash-verified

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.

Callers 2

advanceMethod · 0.80
peek_expectMethod · 0.80

Calls 8

OkInterface · 0.85
ErrInterface · 0.85
unexpected_tokenFunction · 0.85
syntaxMethod · 0.80
into_setMethod · 0.80
as_refMethod · 0.45
containsMethod · 0.45
insert_rangeMethod · 0.45

Tested by

no test coverage detected