MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / lex_ident

Function lex_ident

nodedb/src/control/promql/lexer.rs:242–257  ·  view source on GitHub ↗
(bytes: &[u8], start: usize)

Source from the content-addressed store, hash-verified

240}
241
242fn lex_ident(bytes: &[u8], start: usize) -> (Token, usize) {
243 let mut i = start;
244 while i < bytes.len()
245 && (bytes[i].is_ascii_alphanumeric() || bytes[i] == b'_' || bytes[i] == b':')
246 {
247 i += 1;
248 }
249 let word = std::str::from_utf8(&bytes[start..i]).unwrap_or("");
250
251 // Special identifier-like tokens.
252 match word {
253 "Inf" | "inf" => (Token::Number(f64::INFINITY), i),
254 "NaN" | "nan" => (Token::Number(f64::NAN), i),
255 _ => (Token::Ident(word.to_string()), i),
256 }
257}
258
259#[cfg(test)]
260mod tests {

Callers 1

tokenizeFunction · 0.85

Calls 2

to_stringMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected