I would like to know: is there something like pyparsing (a recursive descent parser) for PHP?
I already looked for it, but it seems no one did it yet. I hope I am wrong.
Thank you in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t know any maintained parser generators written in PHP. But there are parser generators written in other languages with PHP as a target language. One I have personally used is kmyacc. There is a PHP and Windows compatible fork of it. The grammar for it is written in yacc format and can be compiled to PHP using this command:
Kmyacc already comes with a procedural parser prototype file for PHP, but I personally use a modified version of an OOP based prototype.
As an example: This grammar get’s compiled into this parser. (Note that the grammar is huge, that’s why the generated parser has two and a half thousand lines. A “normal” grammar would obviously be far smaller.)