Ejemplo n.º 1
0
 public function parse(Parser $parser, Stream $stream)
 {
     if ($stream->nextTokenIf(Token::IDENTIFIER)) {
         $token = $stream->expectCurrent(Token::IDENTIFIER, ['off', 'on', 'auto', 'disabled', 'enabled']);
     } else {
         $token = $stream->expect(Token::STRING);
     }
     switch ($token->getValue()) {
         case 'disabled':
         case 'off':
             $strategy = 0;
             break;
         case 'on':
         case 'enabled':
         case 'auto':
             $strategy = 1;
             break;
         default:
             $strategy = $token->getValue();
             break;
     }
     $node = new TagNode($this, ['strategy' => $strategy]);
     $stream->expect(Token::TAG_END);
     $node->addChild($parser->parseBlock($stream, 'endautofilter'), 'body');
     $stream->expect(Token::TAG_END);
     return $node;
 }
Ejemplo n.º 2
0
 private function parseConditional()
 {
     //Only instantiate ConditionalOperator when there is a possibility of it being used
     if (!isset($this->conditionalOperator)) {
         $this->conditionalOperator = new ConditionalOperator();
     }
     $left = $this->operandStack->pop();
     // Check whether the current expression is a simplified conditional
     // expression (expr1 ?: expr3)
     if (!$this->stream->nextTokenIf(Token::PUNCTUATION, ':')) {
         $middle = $this->parseExpression(true);
         $this->stream->expectCurrent(Token::PUNCTUATION, ':');
     } else {
         $middle = null;
     }
     $right = $this->parseExpression(true);
     $this->operandStack->push($this->conditionalOperator->createNode($left, $right, $middle));
 }