MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / consume_global_variable_name

Method consume_global_variable_name

crates/gitql-parser/src/tokenizer.rs:415–442  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

413 }
414
415 fn consume_global_variable_name(&mut self) -> Result<Token, Box<Diagnostic>> {
416 let start_index = self.index;
417
418 // Advance `@`
419 self.advance();
420
421 // Make sure first character is alphabetic
422 if !self.is_current_char_func(|c| c.is_alphanumeric()) {
423 return Err(Diagnostic::error(
424 "Global variable name must start with alphabetic character",
425 )
426 .add_help("Add at least one alphabetic character after @")
427 .with_location(self.current_source_location())
428 .as_boxed());
429 }
430
431 while self.is_current_char_func(|c| c == '_' || c.is_alphanumeric()) {
432 self.advance();
433 }
434
435 // Identifier is being case-insensitive by default, convert to lowercase to be easy to compare and lookup
436 let literal = &self.content[start_index..self.index];
437 let mut string: String = literal.iter().collect();
438 string = string.to_lowercase();
439
440 let location = self.current_source_location();
441 Ok(Token::new(TokenKind::GlobalVariable(string), location))
442 }
443
444 fn consume_identifier(&mut self) -> Token {
445 let start_index = self.index;

Callers 1

tokenize_charactersMethod · 0.80

Calls 6

advanceMethod · 0.80
is_current_char_funcMethod · 0.80
as_boxedMethod · 0.80
with_locationMethod · 0.80
add_helpMethod · 0.80

Tested by

no test coverage detected