(self, tok_pattern)
Accepts a token, or raises a ParserError if not found.

        Args:
          tok_pattern: The lexer.Token subclass or subclass instance
            to match, as described by TokenBuffer.accept().

        Returns:
          The token under the cursor if it matches, otherwise None.

        Raises:
          ParserError: The pattern doesn't match the next token.
Accepts a token, or raises a ParserError if not found.
Accepts a token or raises a ParserError if not found .
def _expect(self, tok_pattern):
        """Accepts a token, or raises a ParserError if not found.

        Args:
          tok_pattern: The lexer.Token subclass or subclass instance
            to match, as described by TokenBuffer.accept().

        Returns:
          The token under the cursor if it matches, otherwise None.

        Raises:
          ParserError: The pattern doesn't match the next token.
        """
        tok = self._accept(tok_pattern)
        if tok is not None:
            return tok
        if isinstance(tok_pattern, type):
            name = getattr(tok_pattern, 'name', tok_pattern.__name__)
            raise ParserError('Expected {}'.format(name),
                              token=self._peek())
        raise ParserError('Expected {}'.format(tok_pattern._data),
                          token=self._peek())
def _expect ( self , tok_pattern ) : tok = self . _accept ( tok_pattern ) if tok is not None : return tok if isinstance ( tok_pattern , type ) : name = getattr ( tok_pattern , 'name' , tok_pattern . __name__ ) raise ParserError ( 'Expected {}' . format ( name ) , token = self . _peek ( ) ) raise ParserError ( 'Expected {}' . format ( tok_pattern . _data ) , token = self . _peek ( ) )