Parser
in package
Parsers a token stream.
This parser implements a "Precedence climbing" algorithm.
Tags
Table of Contents
- OPERATOR_LEFT = 1
- OPERATOR_RIGHT = 2
- $binaryOperators : mixed
- $functions : mixed
- $names : mixed
- $stream : mixed
- $unaryOperators : mixed
- __construct() : mixed
- parse() : Node
- Converts a token stream to a node tree.
- parseArguments() : mixed
- Parses arguments.
- parseArrayExpression() : mixed
- parseExpression() : mixed
- parseHashExpression() : mixed
- parsePostfixExpression() : mixed
- parsePrimaryExpression() : mixed
- getPrimary() : mixed
- parseConditionalExpression() : mixed
Constants
OPERATOR_LEFT
public
mixed
OPERATOR_LEFT
= 1
OPERATOR_RIGHT
public
mixed
OPERATOR_RIGHT
= 2
Properties
$binaryOperators
private
mixed
$binaryOperators
$functions
private
mixed
$functions
$names
private
mixed
$names
$stream
private
mixed
$stream
$unaryOperators
private
mixed
$unaryOperators
Methods
__construct()
public
__construct(array<string|int, mixed> $functions) : mixed
Parameters
- $functions : array<string|int, mixed>
Return values
mixed —parse()
Converts a token stream to a node tree.
public
parse(TokenStream $stream[, array<string|int, mixed> $names = [] ]) : Node
The valid names is an array where the values are the names that the user can use in an expression.
If the variable name in the compiled PHP code must be different, define it as the key.
For instance, ['this' => 'container'] means that the variable 'container' can be used in the expression but the compiled code will use 'this'.
Parameters
- $stream : TokenStream
- $names : array<string|int, mixed> = []
-
An array of valid names
Tags
Return values
Node —A node tree
parseArguments()
Parses arguments.
public
parseArguments() : mixed
Return values
mixed —parseArrayExpression()
public
parseArrayExpression() : mixed
Return values
mixed —parseExpression()
public
parseExpression(mixed $precedence) : mixed
Parameters
- $precedence : mixed
Return values
mixed —parseHashExpression()
public
parseHashExpression() : mixed
Return values
mixed —parsePostfixExpression()
public
parsePostfixExpression(mixed $node) : mixed
Parameters
- $node : mixed
Return values
mixed —parsePrimaryExpression()
public
parsePrimaryExpression() : mixed
Return values
mixed —getPrimary()
protected
getPrimary() : mixed
Return values
mixed —parseConditionalExpression()
protected
parseConditionalExpression(mixed $expr) : mixed
Parameters
- $expr : mixed