PHP中的Flex / Bison类功能

时间:2022-06-07 00:41:46

I'm looking for a way to get Flex/Bison (or Lex/Yacc, et. al.) support in PHP. Specifically, I'm implementing a boolean query parser in a web UI and would rather keep all operations inside of PHP (as opposed to calling a C parser, or passing things off to Python, etc.).

我正在寻找一种在PHP中获得Flex / Bison(或Lex / Yacc等人)支持的方法。具体来说,我正在Web UI中实现一个布尔查询解析器,而宁愿将所有操作保留在PHP中(而不是调用C解析器,或者将事物传递给Python等)。

3 个解决方案

#1


LIME Parser Generator for PHP:

用于PHP的LIME分析器生成器:

Complete LALR(1) parser generator and engine (like BISON or YACC) but it's all done in PHP, and the input grammar is easier and more maintainable. Write your actions in PHP. Generate PHP output code. Drive your parser with PHP. Wanna make a language?

完成LALR(1)解析器生成器和引擎(如BISON或YACC),但它们都是用PHP完成的,输入语法更容易,更易于维护。用PHP编写动作。生成PHP输出代码。用PHP驱动你的解析器。想做一门语言?


update:

Since I wrote the above, I see that there are some other tools for parser generation, announced here:

自从我写了上面的内容后,我发现还有一些其他的解析器生成工具,在这里宣布:

http://wezfurlong.org/blog/2006/nov/parser-and-lexer-generators-for-php/

Not sure if these are any better maintained now in 2014, but I know Wez Furlong, he was the original developer of PDO, and he is a very good developer.

不确定这些在2014年是否有更好的维护,但我知道Wez Furlong,他是PDO的原始开发人员,他是一个非常好的开发人员。

#2


The PEAR library has the classes LexerGenerator and ParserGenerator. The LexerGenerator syntax is compatible with re2c, ParserGenerator syntax is compatible with the Lemon Parser generator.

PEAR库有类LexerGenerator和ParserGenerator。 LexerGenerator语法与re2c兼容,ParserGenerator语法与Lemon Parser生成器兼容。

#3


Have you tried looking at PEG parser generators in PHP: https://github.com/maetl/php-peg ?

您是否尝试过在PHP中查看PEG解析器生成器:https://github.com/maetl/php-peg?

Or a parser combinator approach: http://qntm.org/locoparser ?

或解析器组合方法:http://qntm.org/locoparser?

#1


LIME Parser Generator for PHP:

用于PHP的LIME分析器生成器:

Complete LALR(1) parser generator and engine (like BISON or YACC) but it's all done in PHP, and the input grammar is easier and more maintainable. Write your actions in PHP. Generate PHP output code. Drive your parser with PHP. Wanna make a language?

完成LALR(1)解析器生成器和引擎(如BISON或YACC),但它们都是用PHP完成的,输入语法更容易,更易于维护。用PHP编写动作。生成PHP输出代码。用PHP驱动你的解析器。想做一门语言?


update:

Since I wrote the above, I see that there are some other tools for parser generation, announced here:

自从我写了上面的内容后,我发现还有一些其他的解析器生成工具,在这里宣布:

http://wezfurlong.org/blog/2006/nov/parser-and-lexer-generators-for-php/

Not sure if these are any better maintained now in 2014, but I know Wez Furlong, he was the original developer of PDO, and he is a very good developer.

不确定这些在2014年是否有更好的维护,但我知道Wez Furlong,他是PDO的原始开发人员,他是一个非常好的开发人员。

#2


The PEAR library has the classes LexerGenerator and ParserGenerator. The LexerGenerator syntax is compatible with re2c, ParserGenerator syntax is compatible with the Lemon Parser generator.

PEAR库有类LexerGenerator和ParserGenerator。 LexerGenerator语法与re2c兼容,ParserGenerator语法与Lemon Parser生成器兼容。

#3


Have you tried looking at PEG parser generators in PHP: https://github.com/maetl/php-peg ?

您是否尝试过在PHP中查看PEG解析器生成器:https://github.com/maetl/php-peg?

Or a parser combinator approach: http://qntm.org/locoparser ?

或解析器组合方法:http://qntm.org/locoparser?