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

Function whitespace

graphlite/src/ast/lexer.rs:1601–1610  ·  view source on GitHub ↗

Parse whitespace CRITICAL: This function was the source of infinite loops in the original implementation PROBLEM: The original implementation used `map(take_while(...), |_| Token::Whitespace)` which would return Token::Whitespace even when no whitespace was found, causing the lexer to never advance and get stuck in an infinite loop. SOLUTION: Explicitly check if whitespace was consumed and retu

(input: &str)

Source from the content-addressed store, hash-verified

1599/// 3. Function returns Error, allowing other parsers to try
1600/// 4. simple_patterns() successfully parses "MATCH"
1601fn whitespace(input: &str) -> IResult<&str, Token> {
1602 let (remaining, whitespace_chars) = take_while(|c: char| c.is_whitespace())(input)?;
1603 if whitespace_chars.is_empty() {
1604 return Err(nom::Err::Error(nom::error::Error::new(
1605 input,
1606 nom::error::ErrorKind::Tag,
1607 )));
1608 }
1609 Ok((remaining, Token::Whitespace))
1610}
1611
1612/// Parse comments
1613fn comment(input: &str) -> IResult<&str, &str> {

Callers

nothing calls this directly

Calls 2

ErrorEnum · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected