61a51797ed1b372f76d318cf328870b718dd61e2 — Michael Forney 3 months ago db4b798
scan: Add `::` operator

This is needed for attributes, added in C2X (n2335).
3 files changed, 6 insertions(+), 1 deletions(-)

M cc.h
M scan.c
M token.c
M cc.h => cc.h +1 -0
@@ 93,6 93,7 @@ enum tokenkind {
 	TLOR,
 	TQUESTION,
 	TCOLON,
+	TCOLONCOLON,
 	TSEMICOLON,
 	TELLIPSIS,
 	TASSIGN,

M scan.c => scan.c +4 -1
@@ 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;

M token.c => token.c +1 -0
@@ 92,6 92,7 @@ const char *tokstr[] = {
 	[TLOR] = "||",
 	[TQUESTION] = "?",
 	[TCOLON] = ":",
+	[TCOLONCOLON] = "::",
 	[TSEMICOLON] = ";",
 	[TELLIPSIS] = "...",
 	[TASSIGN] = "=",