Make Expr\Error nodes empty

Resolves issue #359.
This commit is contained in:
Nikita Popov 2017-02-26 23:38:32 +01:00
parent c12a4c8239
commit 48ec654d0c
2 changed files with 12 additions and 9 deletions

View File

@ -315,7 +315,10 @@ abstract class ParserAbstract implements Parser
//$this->traceShift($this->errorSymbol); //$this->traceShift($this->errorSymbol);
++$this->stackPos; ++$this->stackPos;
$stateStack[$this->stackPos] = $state = $action; $stateStack[$this->stackPos] = $state = $action;
$this->endAttributes = $this->endAttributeStack[$this->stackPos];
// We treat the error symbol as being empty, so we reset the end attributes
// to the end attributes of the last non-error symbol
$this->endAttributes = $this->endAttributeStack[$this->stackPos - 1];
break; break;
case 3: case 3:

View File

@ -248,11 +248,11 @@ $foo->
!!positions !!positions
Syntax error, unexpected ';', expecting T_STRING or T_VARIABLE or '{' or '$' from 3:1 to 3:1 Syntax error, unexpected ';', expecting T_STRING or T_VARIABLE or '{' or '$' from 3:1 to 3:1
array( array(
0: Expr_PropertyFetch[2:1 - 3:1]( 0: Expr_PropertyFetch[2:1 - 2:6](
var: Expr_Variable[2:1 - 2:4]( var: Expr_Variable[2:1 - 2:4](
name: foo name: foo
) )
name: Expr_Error[3:1 - 3:1]( name: Expr_Error[3:1 - 2:6](
) )
) )
) )
@ -272,11 +272,11 @@ array(
) )
returnType: null returnType: null
stmts: array( stmts: array(
0: Expr_PropertyFetch[3:5 - 4:1]( 0: Expr_PropertyFetch[3:5 - 3:10](
var: Expr_Variable[3:5 - 3:8]( var: Expr_Variable[3:5 - 3:8](
name: bar name: bar
) )
name: Expr_Error[4:1 - 4:1]( name: Expr_Error[4:1 - 3:10](
) )
) )
) )
@ -305,8 +305,8 @@ new
!!php7,positions !!php7,positions
Syntax error, unexpected EOF from 2:4 to 2:4 Syntax error, unexpected EOF from 2:4 to 2:4
array( array(
0: Expr_New[2:1 - 2:4]( 0: Expr_New[2:1 - 2:3](
class: Expr_Error[2:4 - 2:4]( class: Expr_Error[2:4 - 2:3](
) )
args: array( args: array(
) )
@ -850,8 +850,8 @@ array(
) )
) )
args: array( args: array(
0: Arg[3:5 - 3:10]( 0: Arg[3:5 - 3:9](
value: Expr_ClassConstFetch[3:5 - 3:10]( value: Expr_ClassConstFetch[3:5 - 3:9](
class: Name[3:5 - 3:7]( class: Name[3:5 - 3:7](
parts: array( parts: array(
0: Bar 0: Bar