Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24dacb3

Browse files
committed
Support for alternative string quotes (a"xx", b"xx", c"xx", ...).
1 parent 5f5e817 commit 24dacb3

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Parser/tokenizer.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,12 @@ tok_get(tok, p_start, p_end)
538538

539539
/* Identifier (most frequent token!) */
540540
if (isalpha(c) || c == '_') {
541-
do {
541+
c = tok_nextc(tok);
542+
if (c == '"' || c == '\'')
543+
goto letter_quote;
544+
while (isalnum(c) || c == '_') {
542545
c = tok_nextc(tok);
543-
} while (isalnum(c) || c == '_');
546+
}
544547
tok_backup(tok, c);
545548
*p_start = tok->start;
546549
*p_end = tok->cur;
@@ -640,9 +643,11 @@ tok_get(tok, p_start, p_end)
640643
*p_end = tok->cur;
641644
return NUMBER;
642645
}
643-
646+
647+
letter_quote:
644648
/* String */
645649
if (c == '\'' || c == '"') {
650+
char *quote2 = tok->cur+1;
646651
int quote = c;
647652
int triple = 0;
648653
int tripcount = 0;
@@ -663,7 +668,7 @@ tok_get(tok, p_start, p_end)
663668
}
664669
else if (c == quote) {
665670
tripcount++;
666-
if (tok->cur == tok->start+2) {
671+
if (tok->cur == quote2) {
667672
c = tok_nextc(tok);
668673
if (c == quote) {
669674
triple = 1;

0 commit comments

Comments
 (0)