Lexer/Parser implementation in PHP