ridencww / goldengine

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

Is there a chance to resume the parsing process after an error? #19

Closed codemanyak closed 10 months ago

codemanyak commented 6 years ago

Due to the restrictions of LALR(1) grammars, some GOLD grammars provoke ambiguous situations for totally legal code. It's not always straightforward how to tweak the grammar for the engine to cope, it may not even be possible. As far as I can see, the engine always stops on detecting an error. As workaround, the parsed code may be preprocessed, of course, in a trial and error manner, which is very time-consuming for large source files. In some cases, however, it might be relatively easy to intervene manually and interactively to advise the engine which way to go in order to rerail the parsing process and resume. Might there be a chance to allow an embedding application to do this, e.g. to skip a line, assign a token type or to decide for a certain reduction among a limited choice, and to resume the parsing process from that very point? See e.g. these issues for details: https://github.com/fesch/Structorizer.Desktop/issues/470 and https://github.com/fesch/Structorizer.Desktop/issues/472. Regards, Kay

ridencww commented 6 years ago

I've looked at this issue and #18. I like your suggestions and they follow closely what I generally would do. As I mentioned in the README, it was my intent to port Devin's original engine as closely as possible to make it easier to incorporate incremental changes to the engine design, if any would come along.

It's been about 8 years since I started on this port and 7 years since the 5.0.0 release, so the code could stand some analysis and refactoring. As with anything, it is a matter of time and resources. Based on feedback, enough people use the engine to make it worthwhile to enhance the engine, so I will continue to chisel away on a new engine, but is has to be on "as time available" basis.

codemanyak commented 6 years ago

I highly appreciate the engine and your efforts. Together with the GOLDBuilder it makes language analysis and parser construction easy enough. Please don't feel urged. Though sometimes it doesn't need a complete redesign to improve this or that detail. Thanks anyway.

ridencww commented 6 years ago

I agree that a refactor isn't always necessary. For me, it is a matter of getting time to immerse myself into the code again so it can be determined what the best approach would be. I am preparing for a presentation at present, but I will have a look after the first week of August and see what can be done.

Thank you for the comments. The reason I ported the engine in the first place was to have a working Java engine available for my projects since the original port wasn't being maintained and didn't support later versions of the builder. Having others find value in the engine makes all the work worthwhile.

GitMensch commented 6 years ago

@ridencww Any update on this or the possibility to come back to this issue?