Generic parser and lexer sometimes allow partial strings to be parsed, without reaching EOF
cadmaticpgustafsson opened this issue · 7 comments
Hi,
It seems that when using the generic lexer EOF/EOS is perhaps not handled in the same way as with the regex lexer.
For example, I have a grammar which should only allow: + , however inputs such as 1 + 1 + parses into 2, which is unexpected. With the regex lexer you get an error.
This seems similar to this ticket (which is fixed): #351, just for generic lexing now.
- 1 + 1 => 2, is fine
- 1 + 1 + => 2, should probably be an error?
- 1 + 1 + + => error, this is fine
- 1 + 1 - => 2, should probably be an error?
Attached is a screenshot of an example run:
I also attach the project, you should just be able to run 'dotnet build' and then 'dotnet run' to use it. The program reads one line from the console, and then prints the result on the next line.
Sandbox.zip
@cadmaticpgustafsson , I'm starting to look at it
Hello @cadmaticpgustafsson , issue fixed. this was the same as #351 but for ENBF parsers .
A new 2.9.4.7 nuget will be soon available.
Thanks for reporting.
Do not forget to close the issue when ok.
v 2.9.4.7 is now published
Looks like the fix is not perfect. parsing 1 +1 + 1
I get a parsing error unexpected "PLUS [+] @line 0, column 6 on channel 0" (PLUS).
I have to rework it.
@b3b00 Ok good to know, thanks for the quick updates :). I tested quickly with 2.9.4.7 and it solves my problems. I'll wait for another version and then test with that as well.
Hello, @cadmaticpgustafsson. I 've checked the fix and in fact. the last issue seemed to come from your parser, still I don't well understand why. Using the ExpresionParser sample or simplifying your parser to
expression : INT PLUS expression expression : INT
which match the exact same language, is solving the 1 + 1 +1
parsing issue.
So ther will not be a be a new version as you say you're ok with the 2.9.4.7 version.
Are you ok with that ?
@b3b00 Ok, to me it's fine to only release the 2.9.7.4. I tested the fix a bit more and it seems to be working fine. It does not matter much that there is some bug in the parser I provided since that was mostly a quick test project, so the likelihood of there being some bug there is high :).
This issue can be closed in my opinion. Thanks for the quick fix again!