News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Greg Beaver's Blog:
PHP_ParserGenerator and PHP_LexerGenerator
June 25, 2006 @ 17:00:41

Greg Beaver has blogged today with more about the port he's been wokring on of the Lemon parser generator to PHP5, this time discussion the creation of two packages - PHP_ParserGenerator and PHP_LexerGenerator.

Last week, I blogged about completing a port of the Lemon parser generator to PHP 5, which I thought was pretty cool. However, in an email, Alex Merz pointed out that without a lexer generator to accompany lemon, it's pretty difficult to write a decent parser.

After Alex's email, I started thinking about what it would take to write a lexer generator. Basically, a lexer generator requires parsing and compiling regular expressions, then scanning the source one character at a time to find matches. So, it occurred to me that perhaps simply combining regular expressions with sub-patterns could accomplish this task quite easily.

He goes on to explain this process, showing how a simple regular expresion call (and a look at its return arguments) could create a simple, easy solution. Since the re2c format is still unsupported in PHP (without a goto to go to), he opts to stick with the regular expressions and creates a "lex2php" format instead.

He's packaged up both halves of this setup and has already posted proposals for them to the PEAR site:

0 comments voice your opinion now!
pear lexer generator parser package lemon port php5 pear lexer generator parser package lemon port php5


blog comments powered by Disqus

Similar Posts

ONLamp.com: Quick and Clean PHP Forms

HowTo Forge: How To Harden PHP5 With Suhosin (Debian Etch/Ubuntu)

Pierre-Alain Joye's Blog: MnoGoSearch, first PECL release

DevShed: Throwing Basic Exceptions When Auto Loading Classes in PHP 5

NetTuts.com: Setting Up a Local Mirror for Composer Packages With Satis


Community Events





Don't see your event here?
Let us know!


code community zendserver bugfix podcast conference release interview language tips deployment api introduction framework threedevsandamaybe list voicesoftheelephpant laravel series symfony

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework