什么是好的 php 解析器生成器? [英] What is a good parser generator for php?
问题描述
我需要解析用户可以在我的网站上输入的小型迷你语言".我想知道 lex 和 jacc 或 antlr 的对应物对于 php 世界来说是什么.
I need to parse a small 'mini language' which users can type on my site. I was wondering what the counterparts of lex and jacc or antlr are for the world of php.
推荐答案
我使用了 LIME Parser generator for PHP 几年前,它已经成熟和稳定.
I used LIME Parser generator for PHP a couple of years ago, and it was already mature and stable.
解析器生成器本身是用 PHP 编写的,这在任何技术意义上都无关紧要——因为我们只要求生成的解析器是用 PHP 编写的——但我仍然喜欢这个细节.这让我对用 PHP 编写软件感到不那么抱歉;-)
The parser generator itself is written in PHP, which doesn't really matter in any technical sense - as we require only that the generated parser be in PHP - but I like this detail nonetheless. It makes me feel less apologetic about writing software in PHP ;-)
我应该补充:
在我写使用"的地方,说我玩过"会更准确.我还没有使用石灰编写任何生产代码.但我认为没有理由不这样做.
Where I wrote "used" it would be more accurate to say that I "played with". I haven't written any production code using lime, yet. But I see no reason not to do so.
lim 提供的计算器示例"使用了 tokenize() 方法,该方法与 lex 的强大功能相去甚远.但是如果你需要一个真正的分词器,应该可以在前端"使用 lex 来将标记提供给后端"的石灰.
The "calculator example" provided with lime uses a tokenize() method which is very far from a real substitute for the power of lex. But if you need a real tokenizer it ought to be possible to use lex on the "front end" to feed tokens to lime on the "back end".
这篇关于什么是好的 php 解析器生成器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!