Skip to content
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

Fix skipping of new repeated rules #86

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

kwasielewski
Copy link
Contributor

@kwasielewski kwasielewski commented Aug 22, 2024

This PR add an extra check to ensure that the rule is skipped only if both lhs and rhs together are already present in the grammar.

Minimal example of a grammar affected by the change:

g = @cfgrammar begin
           S = 1 + A
           S = 2 * B
           A = 1
           B = 1
           B = 2
       end

Previously rule B = 1 would be skipped.

@sebdumancic
Copy link
Member

thank you for the fix! this makes sense; it is a case we have overlooked.

Copy link

codecov bot commented Aug 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.95%. Comparing base (ce15a3a) to head (1330d9c).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #86   +/-   ##
=======================================
  Coverage   45.95%   45.95%           
=======================================
  Files           8        8           
  Lines         457      457           
=======================================
  Hits          210      210           
  Misses        247      247           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ReubenJ
Copy link
Member

ReubenJ commented Aug 26, 2024

Makes sense to me, too, @kwasielewski. Thanks for the contribution! Before we merge, can you add a test for this?

Also, I would like to get @THinnerichs' input, as I think we discussed this change at some point and held off on it for some reason. Now I can't remember why.

Multiple rules with different lhs are now allowed to have the same rhs
@kwasielewski kwasielewski force-pushed the allow-rules-with-same-rhs branch from d8488ef to 1330d9c Compare August 27, 2024 07:25
@kwasielewski
Copy link
Contributor Author

I added a testset for this change

@ReubenJ ReubenJ merged commit 97b0e62 into Herb-AI:master Aug 27, 2024
5 checks passed
@THinnerichs
Copy link
Member

For future reference:
We pushed that off to the "grammar designer" to solve. As the number of search nodes is exponential in the grammar width, we want to keep the grammar as slim as possible. If you have repetitions like that, you can always re-design the grammar such that only one of the rules is needed.

With our typed system that should not matter. We should indeed only check on entirely repeated rules, checking both left- and right-hand side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants