Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.4.0

Bug #11808 yymore broken
Submitted: 2007-08-09 19:05 UTC
From: eagerlearner Assigned: cellog
Status: Closed Package: PHP_LexerGenerator (version 0.3.3)
PHP Version: 5.2.3 OS: Windows Vista Business
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 30 - 6 = ?

 
 [2007-08-09 19:05 UTC] eagerlearner (William Kisman)
Description: ------------ Error on the regular expression, seems like if I make return 'more' at MATH_OPERATOR { if($this->prevTokenType != NUMBER) { return 'more'; //cycle to the next matching rule } echo 'operator: '.$this->value.'<br>'; } Test script: --------------- <?php define('UNDEFINED',0); define('INTEGER',1); define('FLOAT',2); define('NUMBER',3); class lexer { private $counter; public $token; public $value; private $line; private $input; public $state = 1; private $prevTokenType = UNDEFINED; function __construct($input) { $this->input = $input; $this->N = 0; $this->line = 1; } /*!lex2php %counter {$this->counter} %input {$this->input} %token {$this->token} %value {$this->value} %line {$this->line} WHITESPACE = /[ \t\n]/ WORD = /[a-zA-Z]+/ FLOAT = /[+-]?([0-9]+\.[0-9]+|\.[0-9]+|[0-9]+\.)/ INTEGER = /[+-]?[0-9]+/ MATH_OPERATOR = /[\^*\/%+-]/ UNKNOWN = /./ */ /*!lex2php %statename START WHITESPACE { return false; //ignore this token } WORD { echo 'word: '.$this->value.'<br>'; } MATH_OPERATOR { if($this->prevTokenType != NUMBER) { return 'more'; //cycle to the next matching rule } echo 'operator: '.$this->value.'<br>'; } FLOAT { echo 'float: '.$this->value.'<br>'; // Important FLOAT must have higher precedence than INTEGER $this->prevTokenType = NUMBER; } INTEGER { echo 'Integer :'.$this->value.'<br>'; $this->prevTokenType = NUMBER; } UNKNOWN { echo 'Unknown : '.$this->value.'<br>'; } */ } $lex = new lexer('-2+1'); while($lex->yylex() != false) { } ?> Expected result: ---------------- Integer :-2 operator: + Integer :1 Actual result: -------------- Warning: preg_match() [function.preg-match]: Unknown modifier '(' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\lexer.php on line 121 Warning: Missing argument 1 for lexer::yy_r1_3(), called in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\lexer.php on line 128 and defined in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\lexer.php on line 162 Warning: preg_match() [function.preg-match]: Unknown modifier '(' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\lexer.php on line 121 Warning: Missing argument 1 for lexer::yy_r1_3(), called in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\lexer.php on line 128 and defined in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\lexer.php on line 162

Comments

 [2007-08-09 19:35 UTC] eagerlearner (William Kisman)
The generated $yy_yymore_patterns should have delimited regex with / or @.
 [2007-08-18 23:50 UTC] cellog (Greg Beaver)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.