Herb-AI / HerbGrammar.jl

Grammars for Herb.jl
https://herb-ai.github.io/
MIT License
0 stars 2 forks source link

Make `expr2csgrammar` use `add_rule!` internally #72

Closed ReubenJ closed 5 months ago

ReubenJ commented 5 months ago

Currently, duplicate rules are ignored when using add_rule!:

https://github.com/Herb-AI/HerbGrammar.jl/blob/e3bc05c99b5678bdd79af054b0c990777cc839d9/test/test_csg.jl#L53-L59

However, they are not when using @csgrammar. This new test fails with the current implementation.

https://github.com/Herb-AI/HerbGrammar.jl/blob/e3bc05c99b5678bdd79af054b0c990777cc839d9/test/test_csg.jl#L31-L34

This PR makes the behavior of @csgrammar and add_rule! more similar (hopefully identical) by using add_rule! when constructing the grammar using the @csgrammar macro.

Mainly, I've added the test above to show the unexpected behavior of @csgrammar and updated expr2csgrammar.