-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature Request: Composing Grammars #18
Comments
Do you have a concrete use-case for composing grammars? The main problem with the naive approach here is that grammar represent a grouping of tokens that split the initial input stream into lexemes. Since the ordering/priority of tokens matter, it is not immediately clear how composing tokens sets from different grammars would behave or be intuitive for the users. Grammars also serve as a grouping for parsers, but this grouping is loose and does not have a runtime effect. For instance, nothing prevents from using parsers from other grammars, as long as they agree on the token set. However, this could lead to hard-to-debug problems if the tokens do diverge. |
I was porting an existing hand-written recursive decent parser into a Parsus grammar. The existing test suite tested different leaves of the grammar tree; whereas Parsus' API made it difficult (impossible?) to test a piece of the grammar in isolation. My solution was to isolate the units of the grammar and expose them via their own |
If you need that entirely for testing, then you can rely on the |
Context: I'm porting an existing handwritten parser to use parsus.
Right now, parsus is built on the presumption that a Grammar is complete. It would be helpful if Grammars could be composed.
Because it doesn't support this natively, I've resorted to this hack:
The text was updated successfully, but these errors were encountered: