开发者

Is it possible to parse PHP using PEG?

The question is very straightforward: Is it possible t开发者_开发问答o parse PHP using PEG? I want to use a PEG parser-generator to parse PHP. Please kindly advise. Thank you!


You can make most parser technologies parse most languages, with sufficient effort.

Whether PEG will parse PHP without a lot of effort is a different question.

AFAIK, PHP itself uses Bison (LALR) so I assume PEG will likely handle the grammar supplied by the PHP distribution or something similar. And if you're going to use the PHP distribution, why not just use their supplied parser?

If you don't use the PHP distribution, your problems with parsing PHP are likely to be hard because you'll have to guess the language syntax from the online reference manual, (I've been there, and done that) which is frankly one of the worst ways to define a langauge I've ever seen: all it is is a bunch of examples.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜