-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
enh(parser) Compiler extensions (for grammars + plugins) #2834
enh(parser) Compiler extensions (for grammars + plugins) #2834
Conversation
8150e7f
to
3aa5ab4
Compare
Ping. |
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.
This looks good to me. Some comments have become dated though and should be updated for accuracy
eb46a45
to
da26973
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.
It's really cool. The feature can be easily abused, but it's a powerful tool.
I mentioned some points regarding the documentation.
docs/plugin-api.rst
Outdated
@@ -130,3 +130,41 @@ language | |||
The language determined from the class attribute (or undefined). | |||
|
|||
It returns nothing. | |||
|
|||
|
|||
before:compile(mode, parent) |
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.
There are actially before:compileEarly
and before:compileLate
, right?
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.
I need to rework all the docs (which is why this isn't merged). No one has asked for this as a plugin so I'm probably going to rip that out completely (plus I'm not sure a world where to install grammar xyz you also need plugin 123 and 234 is a great place to end up, so we can push off that decision into the future)... so the new capability is just that languages can define their own sugar (and of course the more modular compiler setup)... and then inside the library we can "test" new extensions in a single language first... and if that goes well they can be promoted to the compiler.
So these docs are probably moving into compilerExtensions
inside the mode docs.
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.
Moved docs into the mode reference.
Co-authored-by: Vladimir Jimenez <allejo@me.com>
54c6d38
to
e36c915
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.
I really like it.
The feature is great, the added docs are clear.
Closes #2794. Works towards #2520. Closes #2833.
Changes
Implements #2833 with the key
compilerExtensions
on a grammar which is anarray of extensions that takes the mode (and it's parent) as input.
Inside the compiler (for all grammars):
illegal
being an array of illegal expressions seamlessly compiled into a single regexR grammar:
beforeMatch
(alternative to look-behind) as a candidate for future inclusion in the compiler.It also adds two plugin hooks that take the same input:before:compileEarlybefore:compileLateThe plugin hooks were removed for now.
Overall this allows grammars (and plugins) to add syntactic sugar to their own definitions.
Checklist
CHANGES.md
AUTHORS.txt
, under Contributors