Skip to content

Commit

Permalink
Don't skip non-existent whitespace
Browse files Browse the repository at this point in the history
The current code's skip pattern matches zero whitespace characters when
skipping whitespace.  The result in the lalrpop lexer is that a
zero-length match on no whitespace is found as a possible match.  In the
common case where a longer match (the next token) was found, lalrpop
discards the shorter match and returns the longer.  If no longer match
was found, lalrpop has special handling to note that if only a
zero-length match was found, that means no valid ones were.  So matching
zero-length whitespace doesn't actually cause a problem, but it's also
useless.

So write the expression we intend, which is to skip actual whitespace.
  • Loading branch information
dburgener committed Oct 18, 2023
1 parent cc76833 commit 03aa5a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ IPv6: CascadeString = {

// lexing precedence
match {
r"[[:space:]]*" => { },
r"[[:space:]]+" => { },
r"//[^\n\r]*[\n\r]*" => { },
r"([[:digit:]]{1,3}\.){4}" => IPv4Regex,
"::1" => IPv6Regex, // TODO
Expand Down

0 comments on commit 03aa5a8

Please sign in to comment.