aboutsummaryrefslogtreecommitdiff
path: root/scan.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-03-12 17:58:54 -0700
committerMichael Forney <mforney@mforney.org>2019-03-12 18:06:16 -0700
commitd77cb90330efd684416cd8b85b95f74bce253716 (patch)
treebbbc22e6754755834a53457307494787dd29e02a /scan.c
parent9c824820b0add0bd840fb559fa4e98afea65986b (diff)
scan: Add support for prefixed string literals and character constants
Diffstat (limited to 'scan.c')
-rw-r--r--scan.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/scan.c b/scan.c
index 59861de..3c3b3da 100644
--- a/scan.c
+++ b/scan.c
@@ -122,8 +122,8 @@ static int
ident(struct scanner *s)
{
s->usebuf = true;
- do nextchar(s);
- while (isalnum(s->chr) || s->chr == '_');
+ while (isalnum(s->chr) || s->chr == '_')
+ nextchar(s);
return TIDENT;
}
@@ -285,7 +285,6 @@ again:
return op2(s, TMOD, TMODASSIGN);
case '&':
return op3(s, TBAND, TBANDASSIGN, TLAND);
- // TODO: u8, U, and L string literals
case '\'':
return charconst(s);
case '*':
@@ -367,6 +366,25 @@ again:
case ',':
nextchar(s);
return TCOMMA;
+ case 'L':
+ case 'U':
+ case 'u':
+ s->usebuf = true;
+ nextchar(s);
+ switch (s->chr) {
+ case '\'':
+ return charconst(s);
+ case '8':
+ if (s->buf.str[0] != 'u')
+ break;
+ nextchar(s);
+ if (s->chr != '"')
+ break;
+ /* fallthrough */
+ case '"':
+ return stringlit(s);
+ }
+ return ident(s);
case EOF:
return TEOF;
default: