Kaydet (Commit) 24dacb38 authored tarafından Guido van Rossum's avatar Guido van Rossum

Support for alternative string quotes (a"xx", b"xx", c"xx", ...).

üst 5f5e817e
...@@ -538,9 +538,12 @@ tok_get(tok, p_start, p_end) ...@@ -538,9 +538,12 @@ tok_get(tok, p_start, p_end)
/* Identifier (most frequent token!) */ /* Identifier (most frequent token!) */
if (isalpha(c) || c == '_') { if (isalpha(c) || c == '_') {
do { c = tok_nextc(tok);
if (c == '"' || c == '\'')
goto letter_quote;
while (isalnum(c) || c == '_') {
c = tok_nextc(tok); c = tok_nextc(tok);
} while (isalnum(c) || c == '_'); }
tok_backup(tok, c); tok_backup(tok, c);
*p_start = tok->start; *p_start = tok->start;
*p_end = tok->cur; *p_end = tok->cur;
...@@ -640,9 +643,11 @@ tok_get(tok, p_start, p_end) ...@@ -640,9 +643,11 @@ tok_get(tok, p_start, p_end)
*p_end = tok->cur; *p_end = tok->cur;
return NUMBER; return NUMBER;
} }
letter_quote:
/* String */ /* String */
if (c == '\'' || c == '"') { if (c == '\'' || c == '"') {
char *quote2 = tok->cur+1;
int quote = c; int quote = c;
int triple = 0; int triple = 0;
int tripcount = 0; int tripcount = 0;
...@@ -663,7 +668,7 @@ tok_get(tok, p_start, p_end) ...@@ -663,7 +668,7 @@ tok_get(tok, p_start, p_end)
} }
else if (c == quote) { else if (c == quote) {
tripcount++; tripcount++;
if (tok->cur == tok->start+2) { if (tok->cur == quote2) {
c = tok_nextc(tok); c = tok_nextc(tok);
if (c == quote) { if (c == quote) {
triple = 1; triple = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment