Constants

SYMBOL_NONE

SYMBOL_NONE = -1

Properties

$tokenToSymbolMapSize

$tokenToSymbolMapSize : integer

Type

integer — Size of $tokenToSymbol map

$actionTableSize

$actionTableSize : integer

Type

integer — Size of $action table

$gotoTableSize

$gotoTableSize : integer

Type

integer — Size of $goto table

$invalidSymbol

$invalidSymbol : integer

Type

integer — Symbol number signifying an invalid token

$errorSymbol

$errorSymbol : integer

Type

integer — Symbol number of error recovery token

$defaultAction

$defaultAction : integer

Type

integer — Action number signifying default action

$unexpectedTokenRule

$unexpectedTokenRule : integer

Type

integer — Rule number signifying that an unexpected token was encountered

$YY2TBLSTATE

$YY2TBLSTATE : 

Type

$YYNLSTATES

$YYNLSTATES : 

Type

$tokenToSymbol

$tokenToSymbol : array

Type

array — Map of lexer tokens to internal symbols

$symbolToName

$symbolToName : array

Type

array — Map of symbols to their names

$productions

$productions : array

Type

array — Names of the production rules (only necessary for debugging)

$actionBase

$actionBase : array

Type

array — 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.

$action

$action : array

Type

array — Table of actions. Indexed according to $actionBase comment.

$actionCheck

$actionCheck : array

Type

array — 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

$actionDefault : array

Type

array — Map of states to their default action

$gotoBase

$gotoBase : array

Type

array — 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)

$goto

$goto : array

Type

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

$gotoCheck

$gotoCheck : array

Type

array — 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

$gotoDefault : array

Type

array — Map of non-terminals to the default state to goto after their reduction

$ruleToNonTerminal

$ruleToNonTerminal : array

Type

array — 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.

$ruleToLength

$ruleToLength : array

Type

array — 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.

$lexer

$lexer : \PhpParser\Lexer

Type

\PhpParser\Lexer — Lexer that is used when parsing

$semValue

$semValue : mixed

Type

mixed — Temporary value containing the result of last semantic action (reduction)

$stackPos

$stackPos : integer

Type

integer — Position in stacks (state stack, semantic value stack, attribute stack)

$semStack

$semStack : array

Type

array — Semantic value stack (contains values of tokens and semantic action results)

$startAttributeStack

$startAttributeStack : array<mixed,array>

Type

array<mixed,array> — Start attribute stack

$endAttributeStack

$endAttributeStack : array<mixed,array>

Type

array<mixed,array> — End attribute stack

$endAttributes

$endAttributes : array

Type

array — End attributes of last *shifted* token

$lookaheadStartAttributes

$lookaheadStartAttributes : array

Type

array — Start attributes of last *read* token

$errors

$errors : array<mixed,\PhpParser\Error>

Type

array<mixed,\PhpParser\Error> — Errors collected during last parse

$errorState

$errorState : integer

Type

integer — Error state, used to avoid error floods

$specialNames

$specialNames : 

Type

Methods

__construct()

__construct(\PhpParser\Lexer  $lexer, array  $options = array()) 

Creates a parser instance.

Parameters

\PhpParser\Lexer $lexer

A lexer

array $options

Options array. Currently no options are supported.

parse()

parse(string  $code, \PhpParser\ErrorHandler|null  $errorHandler = null) : array<mixed,\PhpParser\Node>|null

Parses PHP code into a node tree.

If a non-throwing error handler is used, the parser will continue parsing after an error occurred and attempt to build a partial AST.

Parameters

string $code

The source code to parse

\PhpParser\ErrorHandler|null $errorHandler

Error handler to use for lexer/parser errors, defaults to ErrorHandler\Throwing.

Returns

array<mixed,\PhpParser\Node>|null —

Array of statements (or null if the 'throwOnError' option is disabled and the parser was unable to recover from an error).

emitError()

emitError(\PhpParser\Error  $error) 

Parameters

\PhpParser\Error $error

getErrorMessage()

getErrorMessage(  $symbol,   $state) 

Parameters

$symbol
$state

getExpectedTokens()

getExpectedTokens(  $state) 

Parameters

$state

handleNamespaces()

handleNamespaces(array<mixed,\PhpParser\Node>  $stmts) : array<mixed,\PhpParser\Node>

Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions.

Parameters

array<mixed,\PhpParser\Node> $stmts

Returns

array<mixed,\PhpParser\Node>

handleBuiltinTypes()

handleBuiltinTypes(\PhpParser\Node\Name  $name) 

Parameters

\PhpParser\Node\Name $name

getAttributesAt()

getAttributesAt(  $pos) 

Parameters

$pos

parseLNumber()

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

Parameters

$str
$attributes
$allowInvalidOctal

parseNumString()

parseNumString(  $str,   $attributes) 

Parameters

$str
$attributes

checkModifier()

checkModifier(  $a,   $b,   $modifierPos) 

Parameters

$a
$b
$modifierPos

getNamespacingStyle()

getNamespacingStyle(array  $stmts) 

Parameters

array $stmts