]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - lexer.c
properly fill the token string for TOKEN_ATTRIBUTE_*
[xonotic/gmqcc.git] / lexer.c
diff --git a/lexer.c b/lexer.c
index 7fc606c22d56962882702f7303568c5713c250ba..17fe093be8825206f85fa804013ef618d91b5123 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -50,8 +50,6 @@ static const char *keywords_fg[] = {
     "typedef",
     "goto",
 
-    "noreturn",
-
     "__builtin_debug_printtype"
 };
 static size_t num_keywords_fg = sizeof(keywords_fg) / sizeof(keywords_fg[0]);
@@ -1117,6 +1115,15 @@ int lex_do(lex_file *lex)
     switch (ch)
     {
         case '[':
+            nextch = lex_getch(lex);
+            if (nextch == '[') {
+                lex_tokench(lex, ch);
+                lex_tokench(lex, nextch);
+                lex_endtoken(lex);
+                return (lex->tok.ttype = TOKEN_ATTRIBUTE_OPEN);
+            }
+            lex_ungetch(lex, nextch);
+            /* FALL THROUGH */
         case '(':
         case ':':
         case '?':
@@ -1126,11 +1133,21 @@ int lex_do(lex_file *lex)
                 return (lex->tok.ttype = ch);
             else
                 return (lex->tok.ttype = TOKEN_OPERATOR);
+
+        case ']':
+            nextch = lex_getch(lex);
+            if (nextch == ']') {
+                lex_tokench(lex, ch);
+                lex_tokench(lex, nextch);
+                lex_endtoken(lex);
+                return (lex->tok.ttype = TOKEN_ATTRIBUTE_CLOSE);
+            }
+            lex_ungetch(lex, nextch);
+            /* FALL THROUGH */
         case ')':
         case ';':
         case '{':
         case '}':
-        case ']':
 
         case '#':
             lex_tokench(lex, ch);