summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-06 03:46:20 (GMT)
committerGuido van Rossum <guido@python.org>1997-04-06 03:46:20 (GMT)
commit24dacb38c563bd1d76aea31ad9fd602d83cbcaec (patch)
tree19064e773bb1daf9fc8e087ef99bde84bf52f364 /Parser
parent5f5e817e001302c090ef3b04a66417fbc1c8a351 (diff)
downloadcpython-24dacb38c563bd1d76aea31ad9fd602d83cbcaec.zip
cpython-24dacb38c563bd1d76aea31ad9fd602d83cbcaec.tar.gz
cpython-24dacb38c563bd1d76aea31ad9fd602d83cbcaec.tar.bz2
Support for alternative string quotes (a"xx", b"xx", c"xx", ...).
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 75c1e4e..165e8be 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -538,9 +538,12 @@ tok_get(tok, p_start, p_end)
/* Identifier (most frequent token!) */
if (isalpha(c) || c == '_') {
- do {
+ c = tok_nextc(tok);
+ if (c == '"' || c == '\'')
+ goto letter_quote;
+ while (isalnum(c) || c == '_') {
c = tok_nextc(tok);
- } while (isalnum(c) || c == '_');
+ }
tok_backup(tok, c);
*p_start = tok->start;
*p_end = tok->cur;
@@ -640,9 +643,11 @@ tok_get(tok, p_start, p_end)
*p_end = tok->cur;
return NUMBER;
}
-
+
+ letter_quote:
/* String */
if (c == '\'' || c == '"') {
+ char *quote2 = tok->cur+1;
int quote = c;
int triple = 0;
int tripcount = 0;
@@ -663,7 +668,7 @@ tok_get(tok, p_start, p_end)
}
else if (c == quote) {
tripcount++;
- if (tok->cur == tok->start+2) {
+ if (tok->cur == quote2) {
c = tok_nextc(tok);
if (c == quote) {
triple = 1;