code: public function expect($type, $value = null, $message = null)
      {
          $token = $this->tokens[$this->current];
          if (!$token->test($type, $value)) {
              $line = $token->getLine();
              throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).',
                  $message ? $message.'. ' : '',
                  Twig_Token::typeToEnglish($token->getType()), $token->getValue(),
                  Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
                  $line,
                  $this->source
              );
          }
          $this->next();
  
          return $token;
      }
docs: Tests a token and returns it or throws a syntax error.
  
  @return Twig_Token