aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-08-13 20:25:00 -0700
committerMichael Forney <mforney@mforney.org>2019-08-13 20:25:00 -0700
commit61a51797ed1b372f76d318cf328870b718dd61e2 (patch)
tree2958e8951de9642ef5ff596472eee48b3e2d746e
parentdb4b798e1fbd032b46fbd2a39d3c9797aa1dd34a (diff)
downloadcproc-61a51797ed1b372f76d318cf328870b718dd61e2.tar.xz
scan: Add `::` operator
This is needed for attributes, added in C2X (n2335).
-rw-r--r--cc.h1
-rw-r--r--scan.c5
-rw-r--r--token.c1
3 files changed, 6 insertions, 1 deletions
diff --git a/cc.h b/cc.h
index 9b0989e..4054dcd 100644
--- a/cc.h
+++ b/cc.h
@@ -93,6 +93,7 @@ enum tokenkind {
TLOR,
TQUESTION,
TCOLON,
+ TCOLONCOLON,
TSEMICOLON,
TELLIPSIS,
TASSIGN,
diff --git a/scan.c b/scan.c
index 489b599..5464cde 100644
--- a/scan.c
+++ b/scan.c
@@ -367,7 +367,10 @@ again:
return TQUESTION;
case ':':
nextchar(s);
- return TCOLON;
+ if (s->chr != ':')
+ return TCOLON;
+ nextchar(s);
+ return TCOLONCOLON;
case ';':
nextchar(s);
return TSEMICOLON;
diff --git a/token.c b/token.c
index 5e1a977..da5d597 100644
--- a/token.c
+++ b/token.c
@@ -92,6 +92,7 @@ const char *tokstr[] = {
[TLOR] = "||",
[TQUESTION] = "?",
[TCOLON] = ":",
+ [TCOLONCOLON] = "::",
[TSEMICOLON] = ";",
[TELLIPSIS] = "...",
[TASSIGN] = "=",