ridencww / goldengine

Java implementation of Devin Cook's GOLD Parser engine
Other
35 stars 14 forks source link

Parser fails with runaway group error if the last non-empty code line ends with a line comment #28

Open codemanyak opened 6 months ago

codemanyak commented 6 months ago

If the parsed source file contains a line comment (provided of course that the used grammar specifies line comments) in the last non-empty code line then the parser fails with error.group_runaway, no matter whether the file ends with a newline or not. Even if hundreds of newlines follow, the parsing will fail.

With end-standing block comments, the behaviour is correct (if the end symbol is missing, i.e., the group is actually unterminated then the error duefully occurs, otherwise it does not).

In the appendix, there is a combination of a Java grammar and a Java file that pass the test in GOLDBuilder but fail in the engine with the error described above. final_line_comment_failure.zip

codemanyak commented 6 months ago

A successfully tested bugfix proposal is available in pull request #29.

ridencww commented 6 months ago

Thank you for not only identifying an issue, but also supplying the fix. My time this week is limited, but early next week I will write a failing unit test, merge your PR, generate a new release, and upload it to Maven Central. I am glad to see others continue to use the Java engine and Devin's Builder, which is a good educational tool.

codemanyak commented 6 months ago

Revised the proposed fix. The first version had suppressed the comment token and yielded the EOF, the new one does it the other way round, which seemed more sensible, in particular with respect to issue #18).

ridencww commented 6 months ago

A quick update. last week I pulled the project down, updated the build file, and created a failing unit test. I ran out of time due to work constraints, but am picking this up again this week and making the actual code change. Will alert you when I've committed everything to the develop branch so you can have a look at it.