class SyntaxTree::Parser
def find_token_error(location)
Returns the current location that is being looked at for the parser for
def find_token_error(location) if location # If we explicitly passed a location into this find_token_error method, # that means that's the source of the error, so we'll use that # information for our error object. lineno = location.start_line [lineno, location.start_char - line_counts[lineno - 1].start] elsif lineno && column # If there is a line number associated with the current ripper state, # then we'll use that information to generate the error. [lineno, column] elsif (location = tokens.last_deleted&.location) # If we've already deleted a token from the list of tokens that we are # consuming, then we'll fall back to that token's location. lineno = location.start_line [lineno, location.start_char - line_counts[lineno - 1].start] else # Finally, it's possible that when we hit this error the parsing thread # for ripper has died. In that case, lineno and column both return nil. # So we're just going to set it to line 1, column 0 in the hopes that # that makes any sense. [1, 0] end end