public function parse(Parser $parser, Stream $stream) { if (!$parser->inMainScope()) { throw new ParseException("Extends tags must be placed in the main scope. Unexpected extends tag", $stream->current()->getLine()); } $parser->getCurrentClassNode()->setParentTemplate($parser->parseExpression($stream)); }
public function parse(Parser $parser, Stream $stream) { $node = new TagNode($this); do { $node->addChild($parser->parseExpression($stream)); } while ($stream->current()->test(Token::PUNCTUATION, ',')); return $node; }
public function parse(Parser $parser, Stream $stream) { $node = new RootNode(); do { $left = $parser->parseExpression($stream); $stream->expectCurrent(Token::PUNCTUATION, ':'); $right = $parser->parseExpression($stream); $setOperator = $parser->getEnvironment()->getBinaryOperators()->getOperator(':'); $varNode = $setOperator->createNode($left, $right); $node->addChild(new ExpressionNode($varNode)); } while ($stream->current()->test(Token::PUNCTUATION, ',')); return $node; }
private function compareToStackTop(Operator $operator) { $top = $this->operatorStack->top(); if ($top === null) { return false; } if ($this->binaryOperators->exists($operator) && $operator === $top) { if ($operator->isAssociativity(Operator::LEFT)) { return true; } if ($operator->isAssociativity(Operator::RIGHT)) { return false; } //e.g. (5 is divisible by 2 is divisible by 3) is not considered valid $symbols = $operator->operators(); if (is_array($symbols)) { $symbols = implode(', ', $symbols); } throw new ParseException("Binary operator '{$symbols}' is not associative", $this->stream->current()->getLine()); } return $top->getPrecedence() >= $operator->getPrecedence(); }