]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Lexer: [[ and ]] are now TOKEN_ATTRIBUTE_{OPEN,CLOSE}
authorWolfgang Bumiller <blub@speed.at>
Sat, 22 Dec 2012 17:00:51 +0000 (18:00 +0100)
committerWolfgang Bumiller <blub@speed.at>
Sat, 22 Dec 2012 17:00:51 +0000 (18:00 +0100)
lexer.c
lexer.h

diff --git a/lexer.c b/lexer.c
index 7fc606c22d56962882702f7303568c5713c250ba..be984a77695f1c57a1411513e501bb606aa547cd 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -1117,6 +1117,14 @@ int lex_do(lex_file *lex)
     switch (ch)
     {
         case '[':
+            nextch = lex_getch(lex);
+            if (nextch == '[') {
+                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 +1134,20 @@ 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, 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);
diff --git a/lexer.h b/lexer.h
index e419794eda9f867e150e9f26064cd3ef849c9ec6..e5493734881d6240d3796b4b7a5f41332b46a79d 100644 (file)
--- a/lexer.h
+++ b/lexer.h
@@ -73,6 +73,9 @@ enum {
 
     TOKEN_DOTS, /* 3 dots, ... */
 
+    TOKEN_ATTRIBUTE_OPEN,  /* [[ */
+    TOKEN_ATTRIBUTE_CLOSE, /* ]] */
+
     TOKEN_STRINGCONST, /* not the typename but an actual "string" */
     TOKEN_CHARCONST,
     TOKEN_VECTORCONST,