Skip to content

Instantly share code, notes, and snippets.

@shixzie
Created May 29, 2017 02:04
Show Gist options
  • Save shixzie/5a6eaa607c2b8a790c8d1b920c13b805 to your computer and use it in GitHub Desktop.
Save shixzie/5a6eaa607c2b8a790c8d1b920c13b805 to your computer and use it in GitHub Desktop.
literal rule definition overrided by regex
// Excluding first block
Let <- "let" // This is overrided by the following, same happens if i put this rule below the Identifier rule
Identifier <- ([a-z_]i+([a-z0-9_]i)*) {
return string(c.text), nil
}
@shixzie
Copy link
Author

shixzie commented May 29, 2017

Of course happens to all keyword like rules

If <- "if" // and so on . . .

@breml
Copy link

breml commented May 29, 2017

I guess, this is part of a much larger peg file, right? It looks like the relevant/important section is missing in this gist. My assumption is, that you have a choice expression some where and that the order in your choice expression is wrong. you have to put the most specific conditions first in your choice expression followed by the more generic ones. See https://godoc.org/github.com/mna/pigeon#hdr-Choice_expression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment