-
Notifications
You must be signed in to change notification settings - Fork 208
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
User Defined Macros #1004
Comments
A possible complex macro example would be This may be too complex for to introduce the concepts of macros though... |
I would be interested in writing my own macro. Any pointers on where to get started? My use case is extending my parser to have a |
I don't think this would be possible, Macros are just "sugar" for patterns which are already possible with Chevrotain. You could implement it with back-tracking but it would be in-efficient. |
FYI, |
Description
Now that Chevrotain no longer depends on Function.prototype.toString
it is possible to allow end users to define their own MACROS.
This means create their own Parsing DSL methods, e.g:
Repetition
-> Identical to MANY but simply named differently.This is effectively already supported, This feature is mainly about creating relevant docs and examples.
Tasks
many(1, ()=>{})
instead ofMANY1(()=>{})
to provide easy to use building blocks for users constructing macros.Bonus Task
Not sure if this should be done/with/after this topic. Anyhow the MANY_SEP and AT_LEAST_ONE_SEP methods could be replaced with macros thus simplifying the internals of the Parser, this is even more interesting when one considers that the _SEP methods have limitations and are not quite consistent with the other APIs provided by Chevrotain:
The text was updated successfully, but these errors were encountered: