-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add to support load multiple grammars for derive generator. #758
Conversation
04347d8
to
bac664c
Compare
use
load partial for Pest grammars.
fbf1f57
to
30c15cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thanks! I think that multi-derive generator approach (i.e. this commit 157f159 ) is simple and can address the basic use cases, so I'd be happy to merge that right away -- perhaps could you split it into two PRs?
For the meta grammar extension (i.e. this commit 30c15cf ), I think it's fine, but would want more feedback from other folks. If my understanding of this use <filename>
feature is correct, it'll simply concat all definitions into one grammar (i.e. it's unlike that previous work by @bobbbay #660 that tried to add module-level scoping). Is that correct? If so, what is the advantage of writing use ...
inside a grammar over writing multiple derive annotations?
If this meta grammar extension is to be added, it's maybe worth adding more complex tests (e.g. use statements across multiple files A.pest -> B.pest -> C.pest, or multiple use statements in one file) and documenting this feature in the grammar reference in rustdocs/readme/book (especially its limitations or what one needs to watch for... I assume for this concat approach, there can't be a cycle / mutual dependency, one needs to make sure each grammar file is included only once...?).
30c15cf
to
2949085
Compare
I have splitted #759 |
use
load partial for Pest grammars.
I agree that using concat for multiple I'm pretty firmly against implementing a If it's spelled Footnotes
|
Resolve pest-parser#197 Example: ```rust #[derive(Parser)] #[grammar = "base.pest"] #[grammar = "json.pest"] pub struct JSONParser; ``` For supports sharing rules between grammars.
2949085
to
c825a36
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, the meta grammar extension can comments can continue on #759
* Add doc for load multiple pest files and `include!` syntax. Ref: - pest-parser/pest#759 - pest-parser/pest#758 * Apply suggestions from code review --------- Co-authored-by: Tomas Tauber <[email protected]>
Resolve #197 #333
What New
Allows load multiple grammar files for derive generator.
Example:
By this changes, we can split the sharing rules in to a single file, and then load it for other grammar files.
In my AutoCorrect case, this will useful, because there have so many duplicate rules (e.g.
space
,comment
,newline
) defined in each grammars.https://github.com/huacnlee/autocorrect/tree/v2.5.5/autocorrect/grammar