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

merge_grammars! interacts weirdly with HerbBenchmarks.PBE_SLIA_.. grammars. #71

Closed
THinnerichs opened this issue Apr 30, 2024 · 2 comments · Fixed by #74
Closed

merge_grammars! interacts weirdly with HerbBenchmarks.PBE_SLIA_.. grammars. #71

THinnerichs opened this issue Apr 30, 2024 · 2 comments · Fixed by #74

Comments

@THinnerichs
Copy link
Member

all_rule_grammar = deepcopy(@cfgrammar begin end)
for g in HerbBenchmarks.all_grammars(PBE_SLIA_Track_2019)
           merge_grammars!(all_rule_grammar, g)
end

end up with a very long grammar. I don't know why the rules are not merged properly.

@THinnerichs
Copy link
Member Author

This breaks down to

julia> all_rule_grammar
1: Real = 5


julia> add(x,y) = x+y
add (generic function with 1 method)

julia> add_rule!(all_rule_grammar, :(Real = add(Real, Real)))
1: Real = 5
2: Real = add(Real, Real)


julia> add_rule!(all_rule_grammar, :(Real = add(Real, Real)))
1: Real = 5
2: Real = add(Real, Real)
3: Real = add(Real, Real)


julia> add_rule!(all_rule_grammar, :(Real = add(Real, Real)))
1: Real = 5
2: Real = add(Real, Real)
3: Real = add(Real, Real)
4: Real = add(Real, Real)

@ReubenJ
Copy link
Member

ReubenJ commented Apr 30, 2024

This is due to strict equality checks:

if !any(r === rule for rule g.rules)

I remember now that we did this because the terminals 1 and true were treated as the same, meaning that whichever one was added first was the only rule allowed in the grammar.

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 a pull request may close this issue.

2 participants