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
Preprocessor? Regenerate source code #543
Comments
@mattkanwisher sorry, I dont quite understand what you mean by "regenerate" the source. |
Yeah produce code based on the AST, so I have to generate a compiler back to original source if I want to preprocess using this? |
@YemSalat is right, PEG.js is just a parser generator.
As you can see, PEG.js is only involved in the first step, so if you want to regenerate the source, you have to build a compiler yourself, or if a compiler or generator (toolchain) already exist's for the language, I suggest you either return AST compatible with the toolchain or add a transform that alters's the AST to be more compatible with the toolchain. Closing, as this is not actually an issue with PEG.js but your welcome to continue the discussion. |
So I figured it out. For anyone that lands on this bug post in the future. Just read the source code to "The super tiny compiler". After that I was able to use pegjs to build my preprocessor in a few hours |
I am building extensions to an existing language as a preprocessor. I was unable to figure out if there is a way to get pegjs to regenerate the source code. Basically I want it to parse the source, I want to modify the AST then regenerate the source. Anyway this is possible?
The text was updated successfully, but these errors were encountered: