summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-10-26 15:19:44 (GMT)
committerGuido van Rossum <guido@python.org>1993-10-26 15:19:44 (GMT)
commit8054fad890bbb6668cb2eb2fb3118222bada5975 (patch)
tree787afe12459695c63d29abfca1fb111f918e0ba6 /Parser
parent546185075cbfde306021d8cbf913a1a575286eb0 (diff)
downloadcpython-8054fad890bbb6668cb2eb2fb3118222bada5975.zip
cpython-8054fad890bbb6668cb2eb2fb3118222bada5975.tar.gz
cpython-8054fad890bbb6668cb2eb2fb3118222bada5975.tar.bz2
Changes to accept double-quoted strings on input.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 725a2f1..6504e0c 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -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);