Esempio n. 1
0
 /**
  * This method implements a decision point between compound-variables and
  * variable-variable. It expects that the next token in the token-stream is
  * of type <b>T_DOLLAR</b> and removes it from the stream. Then this method
  * peeks the next available token when it is of type <b>T_CURLY_BRACE_OPEN</b>
  * this is compound variable, otherwise it can be a variable-variable or a
  * compound-variable.
  *
  * @return \PDepend\Source\AST\ASTNode
  * @throws \PDepend\Source\Parser\ParserException
  * @throws UnexpectedTokenException
  * @since  0.9.6
  */
 private function parseCompoundVariableOrVariableVariable()
 {
     $this->tokenStack->push();
     // Read the dollar token
     $token = $this->consumeToken(Tokens::T_DOLLAR);
     $this->consumeComments();
     // Get next token type
     $tokenType = $this->tokenizer->peek();
     // T_DOLLAR|T_VARIABLE === Variable variable,
     // T_CURLY_BRACE_OPEN === Compound variable
     switch ($tokenType) {
         case Tokens::T_DOLLAR:
         case Tokens::T_VARIABLE:
             $variable = $this->builder->buildAstVariableVariable($token->image);
             $variable->addChild($this->parseCompoundVariableOrVariableVariableOrVariable());
             break;
         default:
             $variable = $this->parseCompoundVariable($token);
             break;
     }
     return $this->setNodePositionsAndReturn($variable);
 }