public function expect($type)
    {
        $token = $this->current();
        if (!$this->is($type)) {
            if (is_array($type)) {
                $type = implode(' or ', $type);
            }
            $actual = sprintf('<%s:%s>', $token->getType(), $token->getValue());
            throw new \LogicException(sprintf('Syntax Error: %s expected %s given at line %d', $type, $actual, $token->getLine()));
        }
        $this->next();

        return $token;
    }
public function expect($type)
    {
        $token = $this->current();
        if (!$this->is($type)) {
            if (is_array($type)) {
                $type = implode(' or ', $type);
            }
            $actual = sprintf('<%s:%s>', $token->getType(), $token->getValue());
            throw new \LogicException(sprintf('Syntax Error: %s expected %s given at line %d', $type, $actual, $token->getLine()));
        }
        $this->next();

        return $token;
    }
public function expect ( $ type ) { $ token = $ this -> current ( ) ; if ( ! $ this -> is ( $ type ) ) { if ( is_array ( $ type ) ) { $ type = implode ( ' or ' , $ type ) ; } $ actual = sprintf ( '<%s:%s>' , $ token -> getType ( ) , $ token -> getValue ( ) ) ; throw new \ LogicException ( sprintf ( 'Syntax Error: %s expected %s given at line %d' , $ type , $ actual , $ token -> getLine ( ) ) ) ; } $ this -> next ( ) ; return $ token ; }
Returns a Token if type is matched, otherwise fails the parser

@param string $type Type of token

@throws \LogicException

@return Token
Returns a Token if type is matched otherwise fails the parser