Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex/Bison-like functionality within PHP

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.).

like image 539
Chris Tonkinson Avatar asked Jun 16 '09 21:06

Chris Tonkinson


People also ask

Is Flex and Lex same?

Flex (fast lexical analyzer generator) is a free and open-source software alternative to lex. It is a computer program that generates lexical analyzers (also known as "scanners" or "lexers").

What do you mean by Flex lex yacc and bison?

Lex and Yacc were the first popular and efficient lexers and parsers generators, flex and Bison were the first widespread open-source versions compatible with the original software. Each of these software has more than 30 years of history, which is an achievement in itself.


1 Answers

LIME Parser Generator for PHP:

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?


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.

like image 81
Bill Karwin Avatar answered Oct 11 '22 21:10

Bill Karwin