-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support for Include in grammars #93
Comments
Are you familiar with the ability to I don't like the idea of appending the text of another file directly halfway through the parse. Instead, I could see this being a sort of extension on the
|
Sure I read the docs, but what I'd like to have is not to copy the basic rules. For example how would the reuse of a EOL or WS rule look like? not so nice with the current #parse syntax. Grammar inheritance which ends in basic class inheritance can also nice, but that restricts the grammar reuse to an inheritance chain. |
I'm just saying that plain text concatenation won't really work and that in the meantime all I can offer is what is currently supported. |
We need to consider cases where Grammar.peg references Lib1.peg and Lib2.peg which both reference a fourth file, Shared.peg Another thing to consider, how would you export rules imported from another file? A third case: Grammar.peg references Lib1.peg and Lib2.peg which both define a "WS" rule. Which one wins? |
Relevant discussion: pegjs/pegjs#38 |
I would like input on this syntax proposal which is inspired by TypeScript's modules.
Because this would be incompatible with the existing syntax for rules it would qualify as a breaking change. So, I would also like to propose a syntax option that is a non-breaking change:
|
i really like the typescript syntax |
It would be nice to have an @include "BaseRules.peg" statement, which can import the content of any other grammar file. To not to mess with the "first tag is the start tag by default" rule, those includes can be appended to the end of the grammar file.
Another restriction can be that the imported grammar cannot have settings in its front matter, just rules.
What do you think @otac0n ?
The text was updated successfully, but these errors were encountered: