mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Changes to accept double-quoted strings on input.
This commit is contained in:
parent
546185075c
commit
8054fad890
2 changed files with 31 additions and 3 deletions
|
@ -564,7 +564,7 @@ tok_get(tok, p_start, p_end)
|
|||
return NUMBER;
|
||||
}
|
||||
|
||||
/* String */
|
||||
/* String (single quotes) */
|
||||
if (c == '\'') {
|
||||
for (;;) {
|
||||
c = tok_nextc(tok);
|
||||
|
@ -590,6 +590,32 @@ tok_get(tok, p_start, p_end)
|
|||
return STRING;
|
||||
}
|
||||
|
||||
/* String (double quotes) */
|
||||
if (c == '\"') {
|
||||
for (;;) {
|
||||
c = tok_nextc(tok);
|
||||
if (c == '\n' || c == EOF) {
|
||||
tok->done = E_TOKEN;
|
||||
tok->cur = tok->inp;
|
||||
return ERRORTOKEN;
|
||||
}
|
||||
if (c == '\\') {
|
||||
c = tok_nextc(tok);
|
||||
*p_end = tok->cur;
|
||||
if (c == '\n' || c == EOF) {
|
||||
tok->done = E_TOKEN;
|
||||
tok->cur = tok->inp;
|
||||
return ERRORTOKEN;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (c == '\"')
|
||||
break;
|
||||
}
|
||||
*p_end = tok->cur;
|
||||
return STRING;
|
||||
}
|
||||
|
||||
/* Line continuation */
|
||||
if (c == '\\') {
|
||||
c = tok_nextc(tok);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue