Q: Failing to detect match #285
-
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("", "-->")
I am not sure I understand the error, if it matched (was accepted?) why wouldn't the lexer advance? Edit: type RelNode struct {
Default bool `(@'-->'`
Reltype string ` | '-'@Ident'->')`
}
//Other groupings / optionals |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Assuming you're using the default lexer, this is almost certainly because that lexer does not return |
Beta Was this translation helpful? Give feedback.
Assuming you're using the default lexer, this is almost certainly because that lexer does not return
-->
as a single token, it will return['-', '-', '>']
. You'll either need a custom lexer, or to accept each token individually in your grammar.