<?php class CodeGen_PECL_Tools_ProtoParser { const PAR_OPEN = 1; const PAR_CLOSE = 2; const EQ = 3; const COMMA = 4; const SEMICOLON = 5; const VOID = 6; const BOOL = 7; const NUMVAL = 8; const STRVAL = 9; } class CodeGen_PECL_Tools_ProtoLexer { private $data; public $token; public $value; private $line; private $count; function __construct($data) { $this->data = $data; $this->count = 0; $this->line = 1; } /*!lex2php %input $this->data %counter $this->count %token $this->token %value $this->value %line $this->line %matchlongest 1 whitespace = /[ \t\n]+/ par_open = /\(/ par_close = /\)/ eq = /=/ comma = /,/ semicolon = /;/ void = /void/ bool = /bool(ean)?/ int = /int(eger)?|long/ float = /float|double/ string = /string/ array = /array/ class = /class|object/ resource = /resource/ mixed = /mixed/ callback = /callback/ stream = /stream/ ellipse = /\.\.\./ true = /true/ false = /false/ null = /null/ numval = /[0-9]+|0x[0-9a-fA-F]+/ strval = /"[^"]*"|'[^']*'/ name = /[_a-zA-Z][_a-zA-Z0-9]+/ */ /*!lex2php whitespace { return false; } par_open { $this->token = CodeGen_PECL_Tools_ProtoParser::PAR_OPEN; } par_close { $this->token = CodeGen_PECL_Tools_ProtoParser::PAR_CLOSE; } eq { $this->token = CodeGen_PECL_Tools_ProtoParser::EQ; } comma { $this->token = CodeGen_PECL_Tools_ProtoParser::COMMA; } semicolon { $this->token = CodeGen_PECL_Tools_ProtoParser::SEMICOLON; } void { $this->token = CodeGen_PECL_Tools_ProtoParser::VOID; } bool { $this->token = CodeGen_PECL_Tools_ProtoParser::BOOL; } numval { $this->token = CodeGen_PECL_Tools_ProtoParser::NUMVAL; } name { $this->token = CodeGen_PECL_Tools_ProtoParser::STRVAL; } */ } $a = new CodeGen_PECL_Tools_ProtoLexer('booler boolboolean boolean bool'); $a->yylex(); var_dump('advance: ' . $a->value); $a->yylex(); var_dump('advance: ' . $a->value); $a->yylex(); var_dump('advance: ' . $a->value); $a->yylex(); var_dump('advance: ' . $a->value);