MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / identifier

Function identifier

graphlite/src/ast/parser.rs:2368–2417  ·  view source on GitHub ↗

Parse identifier (does NOT accept string literals - use identifier_or_quoted for that)

(tokens: &[Token])

Source from the content-addressed store, hash-verified

2366
2367/// Parse identifier (does NOT accept string literals - use identifier_or_quoted for that)
2368fn identifier(tokens: &[Token]) -> IResult<&[Token], String> {
2369 if let Some(token) = tokens.first() {
2370 let identifier_str = match token {
2371 Token::Identifier(s) => Some(s.clone()),
2372 // NOTE: String tokens should NOT be accepted here as it causes string literals
2373 // to be incorrectly parsed as variables in expressions
2374 // Allow certain keywords to be used as identifiers in contexts like aliases
2375 Token::Value => Some("value".to_string()),
2376 Token::Type => Some("type".to_string()),
2377 Token::User => Some("user".to_string()),
2378 Token::Role => Some("role".to_string()),
2379 Token::Schema => Some("schema".to_string()),
2380 Token::Data => Some("data".to_string()),
2381 Token::Graph => Some("graph".to_string()),
2382 Token::Node => Some("node".to_string()),
2383 Token::Edge => Some("edge".to_string()),
2384 Token::Path => Some("path".to_string()),
2385 Token::Table => Some("table".to_string()),
2386 Token::Property => Some("property".to_string()),
2387 Token::Source => Some("source".to_string()),
2388 Token::Destination => Some("destination".to_string()),
2389 Token::Zone => Some("zone".to_string()),
2390 Token::Time => Some("time".to_string()),
2391 Token::Parameter => Some("parameter".to_string()),
2392 Token::Order => Some("order".to_string()),
2393 Token::Contains => Some("contains".to_string()),
2394 Token::Next => Some("next".to_string()), // Allow NEXT as edge label
2395 Token::Start => Some("start".to_string()), // Allow START as identifier
2396 Token::End => Some("end".to_string()), // Allow END as identifier
2397 Token::Register => Some("register".to_string()), // Allow REGISTER as identifier
2398 Token::Unregister => Some("unregister".to_string()), // Allow UNREGISTER as identifier
2399 Token::Description => Some("description".to_string()), // Allow DESCRIPTION in YIELD clauses
2400 _ => None,
2401 };
2402
2403 if let Some(s) = identifier_str {
2404 Ok((&tokens[1..], s))
2405 } else {
2406 Err(nom::Err::Error(nom::error::Error::new(
2407 tokens,
2408 nom::error::ErrorKind::Tag,
2409 )))
2410 }
2411 } else {
2412 Err(nom::Err::Error(nom::error::Error::new(
2413 tokens,
2414 nom::error::ErrorKind::Tag,
2415 )))
2416 }
2417}
2418
2419/// Parse edge direction
2420fn edge_direction(tokens: &[Token]) -> IResult<&[Token], EdgeDirection> {

Callers 6

function_callFunction · 0.70
trim_function_callFunction · 0.70
alter_index_statementFunction · 0.70
optimize_index_statementFunction · 0.70
reindex_statementFunction · 0.70
parse_table_nameFunction · 0.70

Calls 3

ErrorEnum · 0.85
cloneMethod · 0.80
firstMethod · 0.45

Tested by

no test coverage detected