PHP implementation with lexer