Parser.php
public function parse(TokenStream $stream, $names = array())
    {
        $this->stream = $stream;
        $this->names = $names;

        $node = $this->parseExpression();
        if (!$stream->isEOF()) {
            throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s"', $stream->current->type, $stream->current->value), $stream->current->cursor);
        }

        return $node;
    }
public function parse(TokenStream $stream, $names = array())
    {
        $this->stream = $stream;
        $this->names = $names;

        $node = $this->parseExpression();
        if (!$stream->isEOF()) {
            throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s"', $stream->current->type, $stream->current->value), $stream->current->cursor);
        }

        return $node;
    }
public function parse ( TokenStream $ stream , $ names = array ( ) ) { $ this -> stream = $ stream ; $ this -> names = $ names ; $ node = $ this -> parseExpression ( ) ; if ( ! $ stream -> isEOF ( ) ) { throw new SyntaxError ( sprintf ( 'Unexpected token "%s" of value "%s"' , $ stream -> current -> type , $ stream -> current -> value ) , $ stream -> current -> cursor ) ; } return $ node ; }
Converts a token stream to a node tree.

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'.

@param TokenStream $stream A token stream instance
@param array       $names  An array of valid names

@return Node\Node A node tree

@throws SyntaxError
Converts a token stream to a node tree .