Compiler/lexical analyzer: Difference between revisions
Content added Content deleted
m (Python, given character literal checks for invalid escape, string should also.) |
|||
Line 15,113: | Line 15,113: | ||
#*** "string" |
#*** "string" |
||
def string_lit(start, err_line, err_col): |
def string_lit(start, err_line, err_col): |
||
global the_ch |
|||
text = "" |
text = "" |
||
Line 15,120: | Line 15,121: | ||
if the_ch == '\n': |
if the_ch == '\n': |
||
error(err_line, err_col, "EOL while scanning string literal") |
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 |
text += the_ch |
||