PHP-Parser
PHP-Parser copied to clipboard
Code Generator Generator
Yo DawG - I heard you like generators...
first: i love this lib!
since i saw this Issue, i thought about a generator to generate the generator via templates. I think it should be possible parse a file, get the AST and then generate a generator script,using a GeneratorPrinter instead of the PrettyPrinter
this should make it easier to build generator scripts.
did someone try that?
Greetings
Hey, I think this is already covered by parser generation from grammar, right?
hey, thanks for reply.
what? how? could you provide me a link to some docs or examples or implementations?
I don't now much about these things, so pardon my possibly incorrect terminology.
This package should be used in the future to generate parser https://github.com/ircmaxell/PHP-Yacc
@TomasVotruba PHP-Yacc is for generating parsers, I think this issue is more about generation of PHP code, though I'm not sure what exactly is being suggested.
This library used to have support for templates, see https://github.com/nikic/PHP-Parser/blob/0.9/doc/4_Code_generation.markdown#templates. However, this was dropped in version 1.0 as the functionality was pretty limited and I don't think anyone was using it at the time.
I see.
Personally I prefer generating code directly by the builder. I have wrapper over it that suits more complex nodes and my personal needs.
@mo-ba Have you any proof of concept in mind?
hi guys!
i will make some prototype, when i find some time, this should explain my suggesteion
grtz
How did you end up solving this @mo-ba ?
Going to close this one as it's not really clear what is being asked. Worth noting that https://github.com/nikic/PHP-Parser/issues/566 links to a repo that can generate the code for constructing nodes from the AST.