Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate rule name generates faulty Go-code. Should throw an error #157

Open
prydin opened this issue Feb 14, 2025 · 0 comments
Open

Duplicate rule name generates faulty Go-code. Should throw an error #157

prydin opened this issue Feb 14, 2025 · 0 comments

Comments

@prydin
Copy link

prydin commented Feb 14, 2025

If you accidentally define two rules with the same name, the parser generator will generate faulty code making it very difficult to troubleshoot. It should throw an error instead.

Example grammar:

#go:build grammars
# +build grammars

package experiments

type Test Peg {}

Expression <-
    FOO { fmt.Println("FOO") }
    BAR { fmt.Println("BAR") } !.

FOO <- "foo"
BAR <- "bar"
FOO <- "foo"

More specifically, the parser generator seems to omit one of the rules from the rule array, causing subsequent indices to mismatch and the wrong rules being invoked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant