Skip to content

Commit

Permalink
BUGFIX: match_function had been partially refactored to take $value a…
Browse files Browse the repository at this point in the history
…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
Hamish Friedlander committed Apr 13, 2012
1 parent aa14a51 commit 7ae9f8a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions thirdparty/php-peg/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ;

Expand Down Expand Up @@ -254,8 +254,8 @@ abstract class TokenExpressionable extends TokenTerminal {

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) {
Expand All @@ -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);
}
}

Expand All @@ -299,7 +299,7 @@ function __construct( $value ) {
}

function match_code( $value ) {
return parent::match_code("'{$this->value}'");
return parent::match_code("'{$value}'");
}
}

Expand All @@ -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 ;
}
}

Expand All @@ -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()
Expand Down Expand Up @@ -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.'\')';
}
}

Expand All @@ -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,
Expand All @@ -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',
Expand Down

0 comments on commit 7ae9f8a

Please sign in to comment.