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

Weird behavior with alternivies. #108

Open
lolbinarycat opened this issue Aug 21, 2020 · 2 comments
Open

Weird behavior with alternivies. #108

lolbinarycat opened this issue Aug 21, 2020 · 2 comments

Comments

@lolbinarycat
Copy link

I have the following files:
main.go:

package main

func main() {
	p := &Parser{Buffer:"test"}
	p.Init()
	err := p.Parse()
	if err != nil {panic(err)}
}

grammer.peg

package main

type Parser Peg {}

Rule <- ( "t"  / "test" ) !. 

running peg grammar.go && go run . results in the following error:

panic: 
parse error near Unknown (line 1 symbol 1 - line 1 symbol 1):
""


goroutine 1 [running]:
main.main()
        /home/binarycat/go/src/github.com/lolbinarycat/peg-bug/main.go:7 +0xb4
exit status 2

This doesn't seem intended, as it makes lots of things much harder to do. If it was intended, then this behavior should be clarified on the readme.

@pointlander
Copy link
Owner

More specific rules need to be first in alternates.

@lolbinarycat
Copy link
Author

Yeah, obviously I know that know, but it would have been nice to know that 2 failed projects ago. The only thing in the readme that's remotely close to an explanation of this, is the line "rules are attempted in order". This should be updated to make this more clear. The readme needs to be updated in general, actually.

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

2 participants