tags:

views:

619

answers:

2

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

+6  A: 

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?

Bill Karwin
Have you ever used this? It hasn't been updated in almost two years now, and it has no filed bugs, open or closed, so I'm hesitant to trust that it's been tested or really used, ever.
Wang
No, I've never needed to implement a full-blown parser in PHP. The fact that it's abandonware, and no other tool exists, may be a clue that PHP is not the right tool for parsing jobs.
Bill Karwin
A: 

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.

chiborg