Beispiel #1
0
 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));
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 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();
 }