goffrie / lalr

CFGs to LALR(1) parse tables
Other
10 stars 1 forks source link

Conflict handling #5

Open jsinger67 opened 5 months ago

jsinger67 commented 5 months ago

I've been working on a more general solution for how to control the handling of conflicts during parse table generation.

The original implementation already provided two parameters reduce_on and priority_of that could properly resolve any conflicts. However, the problem with automatic parser generators is that it is not easy to describe which conflicts should be solved automatically and which should not.

I therefore wanted a way to create behavior like YACC, namely that in general all shift-reduce conflicts can be resolved by favoring shift.

In order not to inflate the call parameters of the lalr function excessively, I introduced a Config trait that allows the configuration of the behavior.

The previous functions reduce_on and priority_of are now part of this trait and ensure that the previous functionality is retained. The Config trait allows further configuration options, such as the YACC-like behavior described above. You can also configure whether such automatically resolved conflicts shall be reported as warnings.

I have provided tests for all new functionality.

I hope these extensions fit into the general concept of this crate. In any case, I am convinced that the expanded configuration options can appeal to more users.

jsinger67 commented 4 months ago

Hi @goffrie,

Since I need these changes for my own project I'm now in a difficult sitiuation. Maybe my changes don't fit into your concept which is totally fine for me. We all do this here in our spare time and nobody has the right to demand for anything. So, I would like to ask you if I could publish my fork to crates.io to be able to reference it. For this I will have to choose a different name for the crate and also have to change the author field in the Cargo.toml. Of course I will respect your license and name you as the original author in the README.

Greetings Jörg