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

PHP7 example: invalid PHP code

Open TiMESPLiNTER opened this issue 7 years ago • 3 comments

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?

TiMESPLiNTER avatar Feb 23 '18 16:02 TiMESPLiNTER

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

Fix the yacc file.

nikic avatar Feb 23 '18 16:02 nikic

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

TiMESPLiNTER avatar Feb 23 '18 17:02 TiMESPLiNTER

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.

nikic avatar Feb 23 '18 22:02 nikic