Skip to content
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

Is it possible to extend PEG grammar? #92

Closed
al6x opened this issue Nov 2, 2012 · 2 comments
Closed

Is it possible to extend PEG grammar? #92

al6x opened this issue Nov 2, 2012 · 2 comments
Labels

Comments

@al6x
Copy link

al6x commented Nov 2, 2012

As far as I know one reason that original CoffeeScript is almost impossible to extend is generation of grammar at compile-time instead of runtime.

It seems that CoffeeScriptRedux also uses grammar rules defined as PEG grammar and generates the JS processor at compile-time. Is it possible to extend those grammar rules at runtime?

Thanks, Alex.

@michaelficarra
Copy link
Owner

This was a decision that had to be made very early on in the project. I could use a PEG to generate a parser with some very desirable properties or use parser combinators to define a parser with other desirable properties (namely, the runtime extensibility you mention). I went with the PEG and its linear-time parsing guarantee when memoised. Compiler/optimiser extensibility were important, so those have very versatile hooks built in. But, unfortunately, if you want to extend the syntax, you're going to need to fork it and modify the grammar.

@texastoland
Copy link

I looked into doing this with Redux last night. I expect just additions to grammar, compiler, and nodes files. These kinds of modifications could be abstracted if it's a common use case? I expect you have a vision for plugins though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants