Friday, June 16. 2006a parser generator for PHP - *finally*Related Links:Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
I ported Lemon a while back for an SQL parser, never go it complete enough to release (documentation bleh.. ).
http://ren.dotgeek.org/expr/ http://ren.dotgeek.org/expr/expr.y
The files at http://pear.chiaraquartet.net/lemon (with the exception of Parser.y) are downloading as empty documents (probably because they're being parser at the server...)
Hmm... it would be nice if the links actually worked.
That being said, this parser generator sounds very interesting. I'd like to see it. BTW, you ought to link to the lemon site: http://www.hwaci.com/sw/lemon/ And... (does it have unit tests?)
So far, I've been concentrating on its correctness over the performance.
The generator itself can be somewhat slow, but I can generate the PHP parser (almost finished) for phpDocumentor in about 2 seconds on my computer. I haven't yet done any performance tests on the generated parser. The best part about all of this is that it can be optimized, but it will perform at the level of Lemon.
Thanks for doing this work!
What is the status for your work on lemon. It appears that the linked files have not been completely looked through. For instance, on Line 2787 of Main.php you have $this->{self::$options[$argv[$i][1]]['arg']}(substr($v, 2)); which is clearly an error because $v is a boolean. I would like to look more into lemon, but first I will ensure that you have abandoned your work. Would be really stupid for me to looke at the code if you have made lots of updates and just forgot to upload them.
Hi Rune,
The parser has been released as an official PEAR package at http://pear.php.net/PHP_ParserGenerator I've been using the code extensively for a number of parsers, including a parser for the PGN (chess) file format, a parser for PHP itself (working on that right now), a parser for docblocks in PHP, and there are others who have been using it as well for parsing lots of things. Try that package out and see if it works for you.
Thanks, this looks a lot better! :+)
I'll email you some more questions.
Your code in yy_is_expected_token does not work. The following small grammar should only accept the string "|1-1|". But if you pass it the string "|1-1-1|" then it gives a argument-type-warning, and accepts the string.
(sorry for br-tokens at end of lines. Seems like a bug in geshi) <br />
%name Bug_<br /> %include {<br /> $parser = new Bug_yyParser;<br /> $tokens['-'] = Bug_yyParser::DASH;<br /> $tokens['1'] = Bug_yyParser::NUMBER;<br /> $tokens['|'] = Bug_yyParser::EOP;<br /> <br /> $str = "|1-1-1|";<br /> <br /> for($i=0; $i< strlen($str); $i++) {<br /> $token = $tokens[$str{$i}];<br /> $parser->doParse($token,$val);<br /> }<br /> }<br /> %syntax_error {<br /> die("Syntax error!\n");<br /> }<br /> start ::= EOP interval EOP.<br /> interval ::= NUMBER DASH NUMBER.<br />
Is'nt so easy. I need an PHP parser script too and I try do understand....
Thx, admin!
I'm glad to see a parser generator written in PHP.
Have you considered writing a tutorial, with a full lexer/parser so that lemon n00bs could start using this package? A link to a working example would be almost as helpful.
What lexer and parser would you recommend for a template engine? Only thing that you could count on is default php installation. I know that PRADO and Smarty 3 are implementing house-made, but for performance and specialization reasons I would look further.
|
Calendar
CategoriesPopular EntriesSetting up your own PEAR channel with Chiara_PEAR_Server - the official way
(36) Do you develop a website? It is infinitely better to synchronize live and development sites using the PEAR Installer(25) How to put the FAIL in open source(22) doing the PEAR thing(19) Using PEAR 1.4.0 to install PEAR packages on a remote host(19) phpDocumentor and __get/__set/__call - give us your ideas (RFC)(17) PEAR now fits in a bottle: meet go-pear.phar(17) Mac OS X ships with security hole-laden PEAR - how to upgrade immediately(16) Introducing pecl extension phar(13) go-pear.phar works! In related news, PHP_Archive is now PHP 5.1.0+(12) |
|||||||||||||||||||||||||||||||||||||||||||||||||