PHP Class PhpParser\ParserAbstract

Inheritance: implements phpparser\Parser
Mostra file Open project: nikic/PHP-Parser Class Usage Examples

Protected Properties

Property Type Description
$YY2TBLSTATE
$YYNLSTATES
$action Table of actions. Indexed according to $actionBase comment.
$actionBase Map of states to a displacement into the $action table. The corresponding action for this state/symbol pair is $action[$actionBase[$state] + $symbol]. If $actionBase[$state] is 0, the action is defaulted, i.e. $actionDefault[$state] should be used instead.
$actionCheck Table indexed analogously to $action. If $actionCheck[$actionBase[$state] + $symbol] != $symbol then the action is defaulted, i.e. $actionDefault[$state] should be used instead.
$actionDefault Map of states to their default action
$actionTableSize Size of $action table
$defaultAction Action number signifying default action
$endAttributeStack End attribute stack
$endAttributes End attributes of last *shifted* token
$errorHandler Error handler
$errorState Error state, used to avoid error floods
$errorSymbol Symbol number of error recovery token
$errors Errors collected during last parse
$goto Table of states to goto after reduction. Indexed according to $gotoBase comment.
$gotoBase Map of non-terminals to a displacement into the $goto table. The corresponding goto state for this non-terminal/state pair is $goto[$gotoBase[$nonTerminal] + $state] (unless defaulted)
$gotoCheck Table indexed analogously to $goto. If $gotoCheck[$gotoBase[$nonTerminal] + $state] != $nonTerminal then the goto state is defaulted, i.e. $gotoDefault[$nonTerminal] should be used.
$gotoDefault Map of non-terminals to the default state to goto after their reduction
$gotoTableSize Size of $goto table
$invalidSymbol Symbol number signifying an invalid token
$lexer Lexer that is used when parsing
$lookaheadStartAttributes Start attributes of last *read* token
$productions Names of the production rules (only necessary for debugging)
$ruleToLength Map of rules to the length of their right-hand side, which is the number of elements that have to be popped from the stack(s) on reduction.
$ruleToNonTerminal Map of rules to the non-terminal on their left-hand side, i.e. the non-terminal to use for determining the state to goto after reduction.
$semStack Semantic value stack (contains values of tokens and semantic action results)
$semValue Temporary value containing the result of last semantic action (reduction)
$specialNames
$stackPos Position in stacks (state stack, semantic value stack, attribute stack)
$startAttributeStack Start attribute stack
$symbolToName Map of symbols to their names
$tokenToSymbol Map of lexer tokens to internal symbols
$tokenToSymbolMapSize Size of $tokenToSymbol map
$unexpectedTokenRule Rule number signifying that an unexpected token was encountered

Public Methods

Method Description
__construct ( Lexer $lexer, array $options = [] ) Creates a parser instance.
parse ( string $code, phpparser\ErrorHandler $errorHandler = null ) : phpparser\Node[] | null Parses PHP code into a node tree.

Protected Methods

Method Description
checkClass ( Class_ $node, $namePos )
checkClassConst ( ClassConst $node, $modifierPos )
checkClassMethod ( ClassMethod $node, $modifierPos )
checkInterface ( Interface_ $node, $namePos )
checkModifier ( $a, $b, $modifierPos )
checkNamespace ( Namespace_ $node )
checkParam ( Param $node )
checkProperty ( Property $node, $modifierPos )
checkTryCatch ( TryCatch $node )
checkUseUse ( UseUse $node, $namePos )
emitError ( Error $error )
getAttributesAt ( $pos )
getErrorMessage ( $symbol, $state )
getExpectedTokens ( $state )
handleBuiltinTypes ( Name $name )
handleNamespaces ( array $stmts ) : phpparser\Node[] Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions.
parseLNumber ( $str, $attributes, $allowInvalidOctal = false )
parseNumString ( $str, $attributes )

Private Methods

Method Description
getNamespacingStyle ( array $stmts )

Method Details

__construct() public method

Creates a parser instance.
public __construct ( Lexer $lexer, array $options = [] )
$lexer Lexer A lexer
$options array Options array. Currently no options are supported.

checkClass() protected method

protected checkClass ( Class_ $node, $namePos )
$node PhpParser\Node\Stmt\Class_

checkClassConst() protected method

protected checkClassConst ( ClassConst $node, $modifierPos )
$node PhpParser\Node\Stmt\ClassConst

checkClassMethod() protected method

protected checkClassMethod ( ClassMethod $node, $modifierPos )
$node PhpParser\Node\Stmt\ClassMethod

checkInterface() protected method

protected checkInterface ( Interface_ $node, $namePos )
$node PhpParser\Node\Stmt\Interface_

checkModifier() protected method

protected checkModifier ( $a, $b, $modifierPos )

checkNamespace() protected method

protected checkNamespace ( Namespace_ $node )
$node PhpParser\Node\Stmt\Namespace_

checkParam() protected method

protected checkParam ( Param $node )
$node PhpParser\Node\Param

checkProperty() protected method

protected checkProperty ( Property $node, $modifierPos )
$node PhpParser\Node\Stmt\Property

checkTryCatch() protected method

protected checkTryCatch ( TryCatch $node )
$node PhpParser\Node\Stmt\TryCatch

checkUseUse() protected method

protected checkUseUse ( UseUse $node, $namePos )
$node PhpParser\Node\Stmt\UseUse

emitError() protected method

protected emitError ( Error $error )
$error Error

getAttributesAt() protected method

protected getAttributesAt ( $pos )

getErrorMessage() protected method

protected getErrorMessage ( $symbol, $state )

getExpectedTokens() protected method

protected getExpectedTokens ( $state )

handleBuiltinTypes() protected method

protected handleBuiltinTypes ( Name $name )
$name PhpParser\Node\Name

handleNamespaces() protected method

Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions.
protected handleNamespaces ( array $stmts ) : phpparser\Node[]
$stmts array
return phpparser\Node[]

parse() public method

If a non-throwing error handler is used, the parser will continue parsing after an error occurred and attempt to build a partial AST.
public parse ( string $code, phpparser\ErrorHandler $errorHandler = null ) : phpparser\Node[] | null
$code string The source code to parse
$errorHandler phpparser\ErrorHandler Error handler to use for lexer/parser errors, defaults to ErrorHandler\Throwing.
return phpparser\Node[] | null Array of statements (or null if the 'throwOnError' option is disabled and the parser was unable to recover from an error).

parseLNumber() protected method

protected parseLNumber ( $str, $attributes, $allowInvalidOctal = false )

parseNumString() protected method

protected parseNumString ( $str, $attributes )

Property Details

$YY2TBLSTATE protected_oe property

protected $YY2TBLSTATE

$YYNLSTATES protected_oe property

protected $YYNLSTATES

$action protected_oe property

Table of actions. Indexed according to $actionBase comment.
protected $action

$actionBase protected_oe property

Map of states to a displacement into the $action table. The corresponding action for this state/symbol pair is $action[$actionBase[$state] + $symbol]. If $actionBase[$state] is 0, the action is defaulted, i.e. $actionDefault[$state] should be used instead.
protected $actionBase

$actionCheck protected_oe property

Table indexed analogously to $action. If $actionCheck[$actionBase[$state] + $symbol] != $symbol then the action is defaulted, i.e. $actionDefault[$state] should be used instead.
protected $actionCheck

$actionDefault protected_oe property

Map of states to their default action
protected $actionDefault

$actionTableSize protected_oe property

Size of $action table
protected $actionTableSize

$defaultAction protected_oe property

Action number signifying default action
protected $defaultAction

$endAttributeStack protected_oe property

End attribute stack
protected $endAttributeStack

$endAttributes protected_oe property

End attributes of last *shifted* token
protected $endAttributes

$errorHandler protected_oe property

Error handler
protected $errorHandler

$errorState protected_oe property

Error state, used to avoid error floods
protected $errorState

$errorSymbol protected_oe property

Symbol number of error recovery token
protected $errorSymbol

$errors protected_oe property

Errors collected during last parse
protected $errors

$goto protected_oe property

Table of states to goto after reduction. Indexed according to $gotoBase comment.
protected $goto

$gotoBase protected_oe property

Map of non-terminals to a displacement into the $goto table. The corresponding goto state for this non-terminal/state pair is $goto[$gotoBase[$nonTerminal] + $state] (unless defaulted)
protected $gotoBase

$gotoCheck protected_oe property

Table indexed analogously to $goto. If $gotoCheck[$gotoBase[$nonTerminal] + $state] != $nonTerminal then the goto state is defaulted, i.e. $gotoDefault[$nonTerminal] should be used.
protected $gotoCheck

$gotoDefault protected_oe property

Map of non-terminals to the default state to goto after their reduction
protected $gotoDefault

$gotoTableSize protected_oe property

Size of $goto table
protected $gotoTableSize

$invalidSymbol protected_oe property

Symbol number signifying an invalid token
protected $invalidSymbol

$lexer protected_oe property

Lexer that is used when parsing
protected $lexer

$lookaheadStartAttributes protected_oe property

Start attributes of last *read* token
protected $lookaheadStartAttributes

$productions protected_oe property

Names of the production rules (only necessary for debugging)
protected $productions

$ruleToLength protected_oe property

Map of rules to the length of their right-hand side, which is the number of elements that have to be popped from the stack(s) on reduction.
protected $ruleToLength

$ruleToNonTerminal protected_oe property

Map of rules to the non-terminal on their left-hand side, i.e. the non-terminal to use for determining the state to goto after reduction.
protected $ruleToNonTerminal

$semStack protected_oe property

Semantic value stack (contains values of tokens and semantic action results)
protected $semStack

$semValue protected_oe property

Temporary value containing the result of last semantic action (reduction)
protected $semValue

$specialNames protected_oe static_oe property

protected static $specialNames

$stackPos protected_oe property

Position in stacks (state stack, semantic value stack, attribute stack)
protected $stackPos

$startAttributeStack protected_oe property

Start attribute stack
protected $startAttributeStack

$symbolToName protected_oe property

Map of symbols to their names
protected $symbolToName

$tokenToSymbol protected_oe property

Map of lexer tokens to internal symbols
protected $tokenToSymbol

$tokenToSymbolMapSize protected_oe property

Size of $tokenToSymbol map
protected $tokenToSymbolMapSize

$unexpectedTokenRule protected_oe property

Rule number signifying that an unexpected token was encountered
protected $unexpectedTokenRule