Compiler/lexical analyzer: Difference between revisions

m
Python, given character literal checks for invalid escape, string should also.
m (Python, given character literal checks for invalid escape, string should also.)
Line 15,113:
#*** "string"
def string_lit(start, err_line, err_col):
global the_ch
text = ""
 
Line 15,120 ⟶ 15,121:
if the_ch == '\n':
error(err_line, err_col, "EOL while scanning string literal")
if the_ch == '\\':
next_ch()
if the_ch != 'n':
error(err_line, err_col, "escape sequence unknown \\%c" % the_ch)
the_ch = '\n'
text += the_ch