Skip to content

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

Description

@prydin

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions