Q: Failing to detect match
Jmoore1127 opened this issue · comments
I am attempting to parse a very simple DSL. I am running into an error in my testing but can't determine if my grammar is wrong, I need a different lexer, or there is an actual bug somewhere. I assume the former since this is fairly straight forward.
A basic example
type RelNode struct {
Default bool `@'-->'?`
Reltype string `| ('-'@Ident'->')
}
This works
parser.ParseString("", "-COMPOSED->")
// RelNode {
// Default: false,
// Reltype: "COMPOSED",
// }
But this fails with an error
parser.ParseString("", "-->")
panic: 1:1: branch "-->"? was accepted but did not progress the lexer at 1:1 ("-") [recovered]
I am not sure I understand the error, if it matched (was accepted?) why wouldn't the lexer advance?
Edit:
I've tried various other tweaks which usually result in a token '-' not expected
error
e.g
type RelNode struct {
Default bool `(@'-->'`
Reltype string ` | '-'@Ident'->')`
}
//Other groupings / optionals