Skip to content
Browse files

BUGFIX: match_function had been partially refactored to take $value a…

…s an argument rather than from the instance variable, but that hadnt been completed, causing problems with E_STRICT. This completes that refactoring.
  • Loading branch information...
1 parent aa14a51 commit 7ae9f8af84afcd1fa90917f15fa7e9de95029fda @hafriedlander hafriedlander committed
Showing with 20 additions and 20 deletions.
  1. +20 −20 thirdparty/php-peg/Compiler.php
View
40 thirdparty/php-peg/Compiler.php
@@ -139,7 +139,7 @@ function __construct( $type, $value = NULL ) {
// abstract protected function match_code() ;
function compile() {
- $code = $this->match_code() ;
+ $code = $this->match_code($this->value) ;
$id = $this->varid() ;
@@ -254,8 +254,8 @@ protected function match_code( $value ) {
static $expression_rx = '/ \$(\w+) | { \$(\w+) } /x';
- function contains_expression(){
- return preg_match(self::$expression_rx, $this->value);
+ function contains_expression( $value ){
+ return preg_match(self::$expression_rx, $value);
}
function expression_replace($matches) {
@@ -275,15 +275,15 @@ function __construct( $value ) {
function match_code( $value ) {
// We inline single-character matches for speed
- if ( !$this->contains_expression() && strlen( eval( 'return '. $this->value . ';' ) ) == 1 ) {
- return $this->match_fail_conditional( 'substr($this->string,$this->pos,1) == '.$this->value,
+ if ( !$this->contains_expression($value) && strlen( eval( 'return '. $value . ';' ) ) == 1 ) {
+ return $this->match_fail_conditional( 'substr($this->string,$this->pos,1) == '.$value,
PHPBuilder::build()->l(
'$this->pos += 1;',
- $this->set_text( $this->value )
+ $this->set_text($value)
)
);
}
- return parent::match_code($this->value);
+ return parent::match_code($value);
}
}
@@ -299,7 +299,7 @@ function __construct( $value ) {
}
function match_code( $value ) {
- return parent::match_code("'{$this->value}'");
+ return parent::match_code("'{$value}'");
}
}
@@ -311,7 +311,7 @@ function __construct( $optional ) {
/* Call recursion indirectly */
function match_code( $value ) {
$code = parent::match_code( '' ) ;
- return $this->value ? $code->replace( array( 'FAIL' => NULL )) : $code ;
+ return $value ? $code->replace( array( 'FAIL' => NULL )) : $code ;
}
}
@@ -320,13 +320,13 @@ function __construct( $value ) {
parent::__construct( 'recurse', $value ) ;
}
- function match_function() {
- return "'".$this->function_name($this->value)."'";
+ function match_function( $value ) {
+ return "'".$this->function_name($value)."'";
}
- function match_code() {
- $function = $this->match_function() ;
- $storetag = $this->function_name( $this->tag ? $this->tag : $this->match_function() ) ;
+ function match_code( $value ) {
+ $function = $this->match_function($value) ;
+ $storetag = $this->function_name( $this->tag ? $this->tag : $this->match_function($value) ) ;
if ( ParserCompiler::$debug ) {
$debug_header = PHPBuilder::build()
@@ -373,8 +373,8 @@ function match_code() {
}
class TokenExpressionedRecurse extends TokenRecurse {
- function match_function() {
- return '$this->expression($result, $stack, \''.$this->value.'\')';
+ function match_function( $value ) {
+ return '$this->expression($result, $stack, \''.$value.'\')';
}
}
@@ -383,9 +383,9 @@ function __construct( $value ) {
parent::__construct( 'sequence', $value ) ;
}
- function match_code() {
+ function match_code( $value ) {
$code = PHPBuilder::build() ;
- foreach( $this->value as $token ) {
+ foreach( $value as $token ) {
$code->l(
$token->compile()->replace(array(
'MATCH' => NULL,
@@ -404,14 +404,14 @@ function __construct( $opt1, $opt2 ) {
parent::__construct( 'option', array( $opt1, $opt2 ) ) ;
}
- function match_code() {
+ function match_code( $value ) {
$id = $this->varid() ;
$code = PHPBuilder::build()
->l(
$this->save($id)
) ;
- foreach ( $this->value as $opt ) {
+ foreach ( $value as $opt ) {
$code->l(
$opt->compile()->replace(array(
'MATCH' => 'MBREAK',

0 comments on commit 7ae9f8a

Please sign in to comment.
Something went wrong with that request. Please try again.