def parsing_error_recov03(): s = "msg\na" c = 4 line, col = line_and_col(c, s) assert s[c] == 'a' assert line == 1 assert col == 0
def translate_where(where0, string): """ Take the first where; compute line, col according to where0.string, and find out the corresponding chars in the second string. This assumes that string and where0.string have the same lines. """ string0 = where0.string line, col = line_and_col(where0.character, string0) character2 = location(line, col, string) if where0.character_end is None: character_end2 = None else: line, col = line_and_col(where0.character_end, string0) character_end2 = location(line, col, string) where = Where(string=string, character=character2, character_end=character_end2) return where
def parsing_error_recov09(): """ Invalid HTML produced """ s="""# a! a""" ast_to_html_(s) s="""mcdp { a }kk""" for c in range(len(s)+1): line, col = line_and_col(c, s) c2 = location(line, col, s) print('c = %2d line = %2d col = %s c2 = %s' % (c, line, col ,c2)) assert c == c2, (c, line, col, c2)