def Parse(self): try: self.Next() # can raise TdopParseError node = self.ParseUntil(0) except TdopParseError as e: # TODO: attribute to token or word err = util.ParseError(str(e)) self.error_stack.append(err) return None return node
def Parse(self, lexer, start_symbol): # type: (Lexer, int) -> Tuple[PNode, token] # Reuse the parser self.push_parser.setup(start_symbol) try: last_token = _PushOilTokens(self.push_parser, lexer, self.gr) except parse.ParseError as e: #log('ERROR %s', e) # TODO: # - Describe what lexer mode we're in (Invalid syntax in regex) # - Maybe say where the mode started # - Id.Unknown_Tok could say "This character is invalid" raise util.ParseError('Invalid syntax', token=e.opaque) return self.push_parser.rootnode, last_token
def Parse(self, lexer, start_symbol): # type: (Lexer, int) -> Tuple[PNode, token] # Reuse the parser self.push_parser.setup(start_symbol) try: last_token = _PushOilTokens(self.parse_ctx, self.gr, self.push_parser, lexer) except parse.ParseError as e: #log('ERROR %s', e) # TODO: # - Describe what lexer mode we're in (Invalid syntax in regex) # - Maybe say where the mode started # - Id.Unknown_Tok could say "This character is invalid" # ParseError has a "too much input" case but I haven't been able to # tickle it. Mabye it's because of the Eof tokens? #raise util.ParseError('Syntax error in expression (%r)', e, token=e.tok) raise util.ParseError('Syntax error in expression', token=e.tok) return self.push_parser.rootnode, last_token
def AddErrorContext(self, msg, *args, **kwargs): err = util.ParseError(msg, *args, **kwargs) self.error_stack.append(err)