PHP-Parser icon indicating copy to clipboard operation
PHP-Parser copied to clipboard

Code Generator Generator

Open mo-ba opened this issue 8 years ago • 7 comments

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

mo-ba avatar Aug 23 '16 01:08 mo-ba

Hey, I think this is already covered by parser generation from grammar, right?

TomasVotruba avatar Oct 28 '17 16:10 TomasVotruba

hey, thanks for reply.

what? how? could you provide me a link to some docs or examples or implementations?

mo-ba avatar Nov 01 '17 03:11 mo-ba

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 avatar Nov 01 '17 08:11 TomasVotruba

@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.

nikic avatar Nov 04 '17 13:11 nikic

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?

TomasVotruba avatar Nov 04 '17 14:11 TomasVotruba

hi guys!

i will make some prototype, when i find some time, this should explain my suggesteion

grtz

mo-ba avatar Nov 16 '17 13:11 mo-ba

How did you end up solving this @mo-ba ?

TomasVotruba avatar Dec 16 '18 15:12 TomasVotruba

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.

nikic avatar May 21 '23 16:05 nikic