-
Notifications
You must be signed in to change notification settings - Fork 1
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
Parse error due to select option order #7
Comments
What version of the package are you using? |
I'm adding this as a automated test case just in case for future builds, however NPM is down for me and I want to make sure the two syntaxes from the different BNFs should make identical output syntax trees |
"bnf-parser": "^3.1.1", I will try to make a better report. (already deleted everything after it failed xD) |
I managed to replicate your error - I have no idea how I didn't run into this when I have an actual programming language running off this as the syntax parser 😅 |
All good. I needed a bnf parser yesterday and started to built one. Then I realized that, what I reported above, won't be handled by my parser and so I started to look out for existing solutions. (yours is the first I checked) |
I thought it was a bug just like you, but I realized it's actually expected behavior - the library assumes not parsing the whole string is a failure. So in your second case it would match the "a", then the program ends, but there is still a remaining character so it fails. For both cases to be valid you would need to write it like this:
Ideally you should order your selects so options are ordered with the most unique and complex elements first. |
Yeh, that's basically why I started mine as well, plus why I adapted BNF syntax to have the ommit character for easy clean up and stuff - the only thing I'm really unhappy with atm is the fact that sometimes it gives the wrong reference range for a syntax error.
|
@tippfelher, this might be a bit late, but I was thinking there are probably other people like you who expect a more non-deterministic select statement. It wouldn't be that hard to implement, since I am already comparing 'best result' of errors on a switch, so it returns the error from the option that got the furthest in consuming |
Edit by @AjaniBilby:
Answer
The text was updated successfully, but these errors were encountered: