From time to time, I find that I need to put a parser together. Most of the time I find that I need to do this in C for performance, but other times I just want something convenient, like PHP, and have been out of luck.
This thanksgiving I set out to remedy this and adapted lemon to optionally emit PHP code, and likewise with JLex.
You need a C compiler to build lemon and a java compiler and runtime to build and run JLexPHP, but after having translated your .y and .lex files with these tools, you're left with a pure PHP parser and lexer implementation.
The parser and lexer generators are available under a BSDish license:
See enclosed README files for more information.
Hi Wez,
http://pear.php.net/PHP_ParserGenerator http://pear.php.net/PHP_LexerGenerator
Both have been available since June. PHP_ParserGenerator is a pure PHP port of lemon, and PHP_LexerGenerator is a from-scratch lexer generator which is similar to Marcus's re2c
Would have saved you a lot of trouble if you had googled "php parser generator" first :)
I hope these are useful for you
I had my port of lemon for a couple of years already (since before I moved to the USA), so the only part I was missing was the lexer generator, and that only took me a couple of hours.
I did google and did find your bits; no disrespect to your efforts, but the lexer code in JLex has been around for years. I'm wouldn't be surprised if there are still a few edge cases in your code that were shaken out of JLex a while ago. Again, I'm not calling your code bad, it just seems better to me to invest a couple of hours in porting known good code rather than a couple of days to hit an edge case.
That's just me; I'm not seeking to discourage others, just publishing something that might be useful.
