ircmaxell / PHP-Yacc

A PHP port of kmyacc
Other
150 stars 14 forks source link

PHP7 example: invalid PHP code #8

Open TiMESPLiNTER opened 6 years ago

TiMESPLiNTER commented 6 years ago

The code generated from the yacc file in the example directory for php7 is not valid. All the class instantiations have square brackets instead of normal ones.

It seems that it‘s the same template copied over from the php parser. There the square brackets get replaced during parser generation.

What‘s the correct thing to do now? Add a feature to this lib to convert the square brackets or fix the yacc file in the example dir?

nikic commented 6 years ago

Fix this lib to convert the square brackets or fix the yacc file in the example dir?

Fix the yacc file.

TiMESPLiNTER commented 6 years ago

@nikic alright. Should I fix it in the php parser repo and adjust the parser generation behavior there to be ready for this lib?

Or is there e specific reason why you chose square brackets over normal ones in your php parser?

nikic commented 6 years ago

Right now the square brackets only add a new and an attributes argument (https://github.com/nikic/PHP-Parser/blob/master/grammar/rebuildParsers.php#L103), though this used to be a larger transformation previously.

In any case, for the purpose of the example in this repository, we simply need to include the generated tmp_parser.y file instead of the original one.