cvs: pear /PHP_LexerGenerator package.xml /PHP_LexerGenerator/LexerGenerator Parser.php Parser.y /PHP_LexerGenerator/tests bug8259.php bug8259.plex
| From: | Greg Beaver | Date: | Wed, 30 Aug 2006 20:10:49 +0000 |
| Subject: | cvs: pear /PHP_LexerGenerator package.xml /PHP_LexerGenerator/LexerGenerator Parser.php Parser.y /PHP_LexerGenerator/tests bug8259.php bug8259.plex | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-41932@lists.php.net to get a copy of this message | ||
cellog Wed Aug 30 20:10:49 2006 UTC
Added files:
/pear/PHP_LexerGenerator/tests bug8259.php bug8259.plex
Modified files:
/pear/PHP_LexerGenerator/LexerGenerator Parser.php Parser.y
/pear/PHP_LexerGenerator package.xml
Log:
- fix Bug #8259: Strange regex generated
- fix Bug #8593: if no statename "const 1=1" inserted
prepare for release of 0.2.2
http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/LexerGenerator/Parser.php?r1=1.1&r2=1.2&diff_format=u Index: pear/PHP_LexerGenerator/LexerGenerator/Parser.php diff -u pear/PHP_LexerGenerator/LexerGenerator/Parser.php:1.1 pear/PHP_LexerGenerator/LexerGenerator/Parser.php:1.2 --- pear/PHP_LexerGenerator/LexerGenerator/Parser.php:1.1 Tue Jul 18 00:47:06 2006 +++ pear/PHP_LexerGenerator/LexerGenerator/Parser.php Wed Aug 30 20:10:49 2006 @@ -140,7 +140,7 @@ * @author Gregory Beaver <cellog@php.net> * @copyright 2006 Gregory Beaver * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Parser.php,v 1.1 2006/07/18 00:47:06 cellog Exp $ + * @version CVS: $Id: Parser.php,v 1.2 2006/08/30 20:10:49 cellog Exp $ * @since File available since Release 0.1.0 */ /** @@ -316,7 +316,7 @@ } // end function '); - if ($statename) { + if (is_string($statename)) { fwrite($this->out, ' const ' . $statename . ' = ' . $ruleindex . '; '); @@ -1419,10 +1419,10 @@ $this->yystack[$this->yyidx + -1]->minor = $this->yystack[$this->yyidx + -1]->minor[0]; $this->yystack[$this->yyidx + -1]->minor = $this->_validatePattern($this->yystack[$this->yyidx + -1]->minor); $this->_patternIndex += $this->yystack[$this->yyidx + -1]->minor['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - $this->_retvalue = array(array('pattern' => str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns'])); + $this->_retvalue = array(array('pattern' => str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns'])); } #line 1433 "Parser.php" #line 553 "Parser.y" @@ -1432,10 +1432,10 @@ $this->yystack[$this->yyidx + -1]->minor = $this->yystack[$this->yyidx + -1]->minor[0]; $this->yystack[$this->yyidx + -1]->minor = $this->_validatePattern($this->yystack[$this->yyidx + -1]->minor); $this->_patternIndex += $this->yystack[$this->yyidx + -1]->minor['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - $this->_retvalue[] = array('pattern' => str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns']); + $this->_retvalue[] = array('pattern' => str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns']); } #line 1446 "Parser.php" #line 565 "Parser.y" http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/LexerGenerator/Parser.y?r1=1.1&r2=1.2&diff_format=u Index: pear/PHP_LexerGenerator/LexerGenerator/Parser.y diff -u pear/PHP_LexerGenerator/LexerGenerator/Parser.y:1.1 pear/PHP_LexerGenerator/LexerGenerator/Parser.y:1.2 --- pear/PHP_LexerGenerator/LexerGenerator/Parser.y:1.1 Tue Jul 18 00:47:06 2006 +++ pear/PHP_LexerGenerator/LexerGenerator/Parser.y Wed Aug 30 20:10:49 2006 @@ -45,7 +45,7 @@ * @author Gregory Beaver <cellog@php.net> * @copyright 2006 Gregory Beaver * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Parser.y,v 1.1 2006/07/18 00:47:06 cellog Exp $ + * @version CVS: $Id: Parser.y,v 1.2 2006/08/30 20:10:49 cellog Exp $ * @since File available since Release 0.1.0 */ /** @@ -225,7 +225,7 @@ } // end function '); - if ($statename) { + if (is_string($statename)) { fwrite($this->out, ' const ' . $statename . ' = ' . $ruleindex . '; '); @@ -545,10 +545,10 @@ B = B[0]; B = $this->_validatePattern(B); $this->_patternIndex += B['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', B['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', B['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - A = array(array('pattern' => str_replace('/', '\\', B->string), 'code' => C, 'subpatterns' => B['subpatterns'])); + A = array(array('pattern' => str_replace('/', '\\/', B->string), 'code' => C, 'subpatterns' => B['subpatterns'])); } rule(A) ::= rule(R) rule_subpattern(B) CODE(C).{ A = R; @@ -556,10 +556,10 @@ B = B[0]; B = $this->_validatePattern(B); $this->_patternIndex += B['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', B['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', B['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - A[] = array('pattern' => str_replace('/', '\\', B->string), 'code' => C, 'subpatterns' => B['subpatterns']); + A[] = array('pattern' => str_replace('/', '\\/', B->string), 'code' => C, 'subpatterns' => B['subpatterns']); } rule_subpattern(A) ::= QUOTE(B). { http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/package.xml?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_LexerGenerator/package.xml diff -u pear/PHP_LexerGenerator/package.xml:1.2 pear/PHP_LexerGenerator/package.xml:1.3 --- pear/PHP_LexerGenerator/package.xml:1.2 Wed Jul 19 00:27:00 2006 +++ pear/PHP_LexerGenerator/package.xml Wed Aug 30 20:10:49 2006 @@ -22,7 +22,7 @@ </lead> <date>2006-07-18</date> <version> - <release>0.2.1</release> + <release>0.2.2</release> <api>0.1.0</api> </version> <stability> @@ -31,11 +31,8 @@ </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license> <notes> - - allow underscore in subpattern names - - fix documentation for class - - fix bug in regex parsing where backreferences could not have a multiplier - like +, *, or {0,1} - - disallow (?R), this can't work in a multi-regex lexer generator, unfortunately + - fix Bug #8259: Strange regex generated + - fix Bug #8593: if no statename "const 1=1" inserted </notes> <contents> <dir baseinstalldir="PHP" name="/"> @@ -75,6 +72,10 @@ <tasks:replace from="@php-dir@" to="php_dir" type="pear-config"/> <tasks:windowseol/> </file> + <dir name="tests"> + <file name="bug8259.plex" role="test" /> + <file name="bug8259.php" role="test" /> + </dir> <!-- /tests --> </dir> <!-- / --> </contents> <dependencies> @@ -102,8 +103,6 @@ <license uri="http://www.php.net/license/3_01.txt">PHP License 3.01</license> <notes>initial release</notes> </release> - </changelog> - <changelog> <release> <version> <release>0.2.0</release> @@ -122,8 +121,6 @@ - use PEAR_Exception </notes> </release> - </changelog> - <changelog> <release> <version> <release>0.2.1</release> @@ -143,5 +140,21 @@ - disallow (?R), this can't work in a multi-regex lexer generator, unfortunately </notes> </release> + <release> + <version> + <release>0.2.2</release> + <api>0.1.0</api> + </version> + <stability> + <release>alpha</release> + <api>alpha</api> + </stability> + <date>2006-08-13</date> + <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license> + <notes> + - fix Bug #8259: Strange regex generated + - fix Bug #8593: if no statename "const 1=1" inserted + </notes> + </release> </changelog> </package> http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/tests/bug8259.php?view=markup&rev=1.1 Index: pear/PHP_LexerGenerator/tests/bug8259.php +++ pear/PHP_LexerGenerator/tests/bug8259.php <?php class blah { private $_yy_state = 1; private $_yy_stack = array(); function yylex() { return $this->{'yylex' . $this->_yy_state}(); } function yypushstate($state) { array_push($this->_yy_stack, $this->_yy_state); $this->_yy_state = $state; } function yypopstate() { $this->_yy_state = array_pop($this->_yy_stack); } function yybegin($state) { $this->_yy_state = $state; } function yylex1() { $tokenMap = array ( 1 => 1, ); if ($this->N >= strlen($this->data)) { return false; // end of input } $yy_global_pattern = "/^(\/?:([a-zA-Z0-9_]+)\/?)/"; do { if (preg_match($yy_global_pattern, substr($this->data, $this->N), $yymatches)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if (!count($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . 'an empty string. Input "' . substr($this->data, $this->N, 5) . '... state 1'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number if ($tokenMap[$this->token]) { // extract sub-patterns for passing to lex function $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]); } else { $yysubmatches = array(); } $this->value = current($yymatches); // token value $r = $this->{'yy_r1_' . $this->token}($yysubmatches); if ($r === null) { $this->N += strlen($this->value); $this->line += substr_count("\n", $this->value); // accept this token return true; } elseif ($r === true) { // we have changed state // process this token in the new state return $this->yylex(); } elseif ($r === false) { $this->N += strlen($this->value); $this->line += substr_count("\n", $this->value); if ($this->N >= strlen($this->data)) { return false; // end of input } // skip this token continue; } else { $yy_yymore_patterns = array( 1 => "", ); // yymore is needed do { if (!strlen($yy_yymore_patterns[$this->token])) { throw new Exception('cannot do yymore for the last token'); } if (preg_match($yy_yymore_patterns[$this->token], substr($this->data, $this->N), $yymatches)) { $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns next($yymatches); // skip global match $this->token = key($yymatches); // token number $this->value = current($yymatches); // token value $this->line = substr_count("\n", $this->value); } } while ($this->{'yy_r1_' . $this->token}() !== null); // accept $this->N += strlen($this->value); $this->line += substr_count("\n", $this->value); return true; } } else { throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->N]); } break; } while (true); } // end function function yy_r1_1($yy_subpatterns) { $a = 1; } } ?> http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/tests/bug8259.plex?view=markup&rev=1.1 Index: pear/PHP_LexerGenerator/tests/bug8259.plex +++ pear/PHP_LexerGenerator/tests/bug8259.plex <?php class blah { /*!lex2php %input $this->data %counter $this->N %token $this->token %value $this->value %line $this->line variable = @/?:([a-zA-Z0-9_]+)/?@ */ /*!lex2php variable {$a = 1;} */ } ?>
http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/LexerGenerator/Parser.php?r1=1.1&r2=1.2&diff_format=u Index: pear/PHP_LexerGenerator/LexerGenerator/Parser.php diff -u pear/PHP_LexerGenerator/LexerGenerator/Parser.php:1.1 pear/PHP_LexerGenerator/LexerGenerator/Parser.php:1.2 --- pear/PHP_LexerGenerator/LexerGenerator/Parser.php:1.1 Tue Jul 18 00:47:06 2006 +++ pear/PHP_LexerGenerator/LexerGenerator/Parser.php Wed Aug 30 20:10:49 2006 @@ -140,7 +140,7 @@ * @author Gregory Beaver <cellog@php.net> * @copyright 2006 Gregory Beaver * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Parser.php,v 1.1 2006/07/18 00:47:06 cellog Exp $ + * @version CVS: $Id: Parser.php,v 1.2 2006/08/30 20:10:49 cellog Exp $ * @since File available since Release 0.1.0 */ /** @@ -316,7 +316,7 @@ } // end function '); - if ($statename) { + if (is_string($statename)) { fwrite($this->out, ' const ' . $statename . ' = ' . $ruleindex . '; '); @@ -1419,10 +1419,10 @@ $this->yystack[$this->yyidx + -1]->minor = $this->yystack[$this->yyidx + -1]->minor[0]; $this->yystack[$this->yyidx + -1]->minor = $this->_validatePattern($this->yystack[$this->yyidx + -1]->minor); $this->_patternIndex += $this->yystack[$this->yyidx + -1]->minor['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - $this->_retvalue = array(array('pattern' => str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns'])); + $this->_retvalue = array(array('pattern' => str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns'])); } #line 1433 "Parser.php" #line 553 "Parser.y" @@ -1432,10 +1432,10 @@ $this->yystack[$this->yyidx + -1]->minor = $this->yystack[$this->yyidx + -1]->minor[0]; $this->yystack[$this->yyidx + -1]->minor = $this->_validatePattern($this->yystack[$this->yyidx + -1]->minor); $this->_patternIndex += $this->yystack[$this->yyidx + -1]->minor['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - $this->_retvalue[] = array('pattern' => str_replace('/', '\\', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns']); + $this->_retvalue[] = array('pattern' => str_replace('/', '\\/', $this->yystack[$this->yyidx + -1]->minor->string), 'code' => $this->yystack[$this->yyidx + 0]->minor, 'subpatterns' => $this->yystack[$this->yyidx + -1]->minor['subpatterns']); } #line 1446 "Parser.php" #line 565 "Parser.y" http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/LexerGenerator/Parser.y?r1=1.1&r2=1.2&diff_format=u Index: pear/PHP_LexerGenerator/LexerGenerator/Parser.y diff -u pear/PHP_LexerGenerator/LexerGenerator/Parser.y:1.1 pear/PHP_LexerGenerator/LexerGenerator/Parser.y:1.2 --- pear/PHP_LexerGenerator/LexerGenerator/Parser.y:1.1 Tue Jul 18 00:47:06 2006 +++ pear/PHP_LexerGenerator/LexerGenerator/Parser.y Wed Aug 30 20:10:49 2006 @@ -45,7 +45,7 @@ * @author Gregory Beaver <cellog@php.net> * @copyright 2006 Gregory Beaver * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: Parser.y,v 1.1 2006/07/18 00:47:06 cellog Exp $ + * @version CVS: $Id: Parser.y,v 1.2 2006/08/30 20:10:49 cellog Exp $ * @since File available since Release 0.1.0 */ /** @@ -225,7 +225,7 @@ } // end function '); - if ($statename) { + if (is_string($statename)) { fwrite($this->out, ' const ' . $statename . ' = ' . $ruleindex . '; '); @@ -545,10 +545,10 @@ B = B[0]; B = $this->_validatePattern(B); $this->_patternIndex += B['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', B['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', B['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - A = array(array('pattern' => str_replace('/', '\\', B->string), 'code' => C, 'subpatterns' => B['subpatterns'])); + A = array(array('pattern' => str_replace('/', '\\/', B->string), 'code' => C, 'subpatterns' => B['subpatterns'])); } rule(A) ::= rule(R) rule_subpattern(B) CODE(C).{ A = R; @@ -556,10 +556,10 @@ B = B[0]; B = $this->_validatePattern(B); $this->_patternIndex += B['subpatterns'] + 1; - if (@preg_match('/' . str_replace('/', '\\', B['pattern']) . '/', '')) { + if (@preg_match('/' . str_replace('/', '\\/', B['pattern']) . '/', '')) { $this->error('Rule "' . $name . '" can match the empty string, this will break lexing'); } - A[] = array('pattern' => str_replace('/', '\\', B->string), 'code' => C, 'subpatterns' => B['subpatterns']); + A[] = array('pattern' => str_replace('/', '\\/', B->string), 'code' => C, 'subpatterns' => B['subpatterns']); } rule_subpattern(A) ::= QUOTE(B). { http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/package.xml?r1=1.2&r2=1.3&diff_format=u Index: pear/PHP_LexerGenerator/package.xml diff -u pear/PHP_LexerGenerator/package.xml:1.2 pear/PHP_LexerGenerator/package.xml:1.3 --- pear/PHP_LexerGenerator/package.xml:1.2 Wed Jul 19 00:27:00 2006 +++ pear/PHP_LexerGenerator/package.xml Wed Aug 30 20:10:49 2006 @@ -22,7 +22,7 @@ </lead> <date>2006-07-18</date> <version> - <release>0.2.1</release> + <release>0.2.2</release> <api>0.1.0</api> </version> <stability> @@ -31,11 +31,8 @@ </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license> <notes> - - allow underscore in subpattern names - - fix documentation for class - - fix bug in regex parsing where backreferences could not have a multiplier - like +, *, or {0,1} - - disallow (?R), this can't work in a multi-regex lexer generator, unfortunately + - fix Bug #8259: Strange regex generated + - fix Bug #8593: if no statename "const 1=1" inserted </notes> <contents> <dir baseinstalldir="PHP" name="/"> @@ -75,6 +72,10 @@ <tasks:replace from="@php-dir@" to="php_dir" type="pear-config"/> <tasks:windowseol/> </file> + <dir name="tests"> + <file name="bug8259.plex" role="test" /> + <file name="bug8259.php" role="test" /> + </dir> <!-- /tests --> </dir> <!-- / --> </contents> <dependencies> @@ -102,8 +103,6 @@ <license uri="http://www.php.net/license/3_01.txt">PHP License 3.01</license> <notes>initial release</notes> </release> - </changelog> - <changelog> <release> <version> <release>0.2.0</release> @@ -122,8 +121,6 @@ - use PEAR_Exception </notes> </release> - </changelog> - <changelog> <release> <version> <release>0.2.1</release> @@ -143,5 +140,21 @@ - disallow (?R), this can't work in a multi-regex lexer generator, unfortunately </notes> </release> + <release> + <version> + <release>0.2.2</release> + <api>0.1.0</api> + </version> + <stability> + <release>alpha</release> + <api>alpha</api> + </stability> + <date>2006-08-13</date> + <license uri="http://www.opensource.org/licenses/bsd-license.php">New BSD License</license> + <notes> + - fix Bug #8259: Strange regex generated + - fix Bug #8593: if no statename "const 1=1" inserted + </notes> + </release> </changelog> </package> http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/tests/bug8259.php?view=markup&rev=1.1 Index: pear/PHP_LexerGenerator/tests/bug8259.php +++ pear/PHP_LexerGenerator/tests/bug8259.php <?php class blah { private $_yy_state = 1; private $_yy_stack = array(); function yylex() { return $this->{'yylex' . $this->_yy_state}(); } function yypushstate($state) { array_push($this->_yy_stack, $this->_yy_state); $this->_yy_state = $state; } function yypopstate() { $this->_yy_state = array_pop($this->_yy_stack); } function yybegin($state) { $this->_yy_state = $state; } function yylex1() { $tokenMap = array ( 1 => 1, ); if ($this->N >= strlen($this->data)) { return false; // end of input } $yy_global_pattern = "/^(\/?:([a-zA-Z0-9_]+)\/?)/"; do { if (preg_match($yy_global_pattern, substr($this->data, $this->N), $yymatches)) { $yysubmatches = $yymatches; $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns if (!count($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . 'an empty string. Input "' . substr($this->data, $this->N, 5) . '... state 1'); } next($yymatches); // skip global match $this->token = key($yymatches); // token number if ($tokenMap[$this->token]) { // extract sub-patterns for passing to lex function $yysubmatches = array_slice($yysubmatches, $this->token + 1, $tokenMap[$this->token]); } else { $yysubmatches = array(); } $this->value = current($yymatches); // token value $r = $this->{'yy_r1_' . $this->token}($yysubmatches); if ($r === null) { $this->N += strlen($this->value); $this->line += substr_count("\n", $this->value); // accept this token return true; } elseif ($r === true) { // we have changed state // process this token in the new state return $this->yylex(); } elseif ($r === false) { $this->N += strlen($this->value); $this->line += substr_count("\n", $this->value); if ($this->N >= strlen($this->data)) { return false; // end of input } // skip this token continue; } else { $yy_yymore_patterns = array( 1 => "", ); // yymore is needed do { if (!strlen($yy_yymore_patterns[$this->token])) { throw new Exception('cannot do yymore for the last token'); } if (preg_match($yy_yymore_patterns[$this->token], substr($this->data, $this->N), $yymatches)) { $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns next($yymatches); // skip global match $this->token = key($yymatches); // token number $this->value = current($yymatches); // token value $this->line = substr_count("\n", $this->value); } } while ($this->{'yy_r1_' . $this->token}() !== null); // accept $this->N += strlen($this->value); $this->line += substr_count("\n", $this->value); return true; } } else { throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->N]); } break; } while (true); } // end function function yy_r1_1($yy_subpatterns) { $a = 1; } } ?> http://cvs.php.net/viewvc.cgi/pear/PHP_LexerGenerator/tests/bug8259.plex?view=markup&rev=1.1 Index: pear/PHP_LexerGenerator/tests/bug8259.plex +++ pear/PHP_LexerGenerator/tests/bug8259.plex <?php class blah { /*!lex2php %input $this->data %counter $this->N %token $this->token %value $this->value %line $this->line variable = @/?:([a-zA-Z0-9_]+)/?@ */ /*!lex2php variable {$a = 1;} */ } ?>