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

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

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

@param string $type Type of node

@throws \LogicException

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