Пример #1
0
 /**
  * This method will consume the next token in the token stream. It will
  * throw an exception if the type of this token is not identical with
  * <b>$tokenType</b>.
  *
  * @param  integer $tokenType The next expected token type.
  * @return \PDepend\Source\Tokenizer\Token
  * @throws \PDepend\Source\Parser\TokenStreamEndException
  * @throws \PDepend\Source\Parser\UnexpectedTokenException
  */
 protected function consumeToken($tokenType)
 {
     $token = $this->tokenizer->next();
     if ($token === Tokenizer::T_EOF) {
         throw new TokenStreamEndException($this->tokenizer);
     } elseif ($token->type == $tokenType) {
         return $this->tokenStack->add($token);
     }
     throw new UnexpectedTokenException($token, $this->tokenizer->getSourceFile());
 }
Пример #2
0
 /**
  * This method will consume the next token in the token stream. It will
  * throw an exception if the type of this token is not identical with
  * <b>$tokenType</b>.
  *
  * @param  integer $tokenType The next expected token type.
  * @return \PDepend\Source\Tokenizer\Token
  * @throws \PDepend\Source\Parser\TokenStreamEndException
  * @throws \PDepend\Source\Parser\UnexpectedTokenException
  */
 protected function consumeToken($tokenType)
 {
     switch ($this->tokenizer->peek()) {
         case $tokenType:
             return $this->tokenStack->add($this->tokenizer->next());
         case Tokenizer::T_EOF:
             throw new TokenStreamEndException($this->tokenizer);
     }
     $this->throwUnexpectedTokenException();
 }