JLexPHP icon indicating copy to clipboard operation
JLexPHP copied to clipboard

A lexer generator for PHP. It is based on JLex and requires Java to generate the lexer. Once generated, the lexer only requires PHP to run.

JLexPHP: a Lexical Analyzer Generator for PHP, based on JLex. For copyright and licensing information, see the COPYING file.

This is an adaptation of some Java code that generates lexers from lex style input files.

The porting effort was pretty trivial, with the hardest part being the buffer management.

Usage is fairly typical of lexers; you'll want to create a lexer file like this:

----8<------

yytext(), "\n"; } . { echo "Something else ", $this->yytext(), "\n"; } ----8yylex()) ; A more complicated scanner will use the createToken() method to create a token object that can then be fed into a parser, such as a lemon based parser. You can see an example of that in the c.lex source file. It is designed to work in conjunction with it's corresponding c.y file in my lemon port for php. You can find more information on the lexer syntax in the JLex manual: http://www.cs.princeton.edu/~appel/modern/java/JLex/current/manual.html Enjoy! --Wez.