]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Don't expand frame macros when they don't have a $ prefix
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 16 Aug 2012 18:49:58 +0000 (20:49 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 16 Aug 2012 18:49:58 +0000 (20:49 +0200)
data/parsing.qc
lexer.c

index 5c61f8cd752fd6ece5438fd9d9f125c4ffe697c4..f75a136da9fda7bd61581d7de7be167404f33582 100644 (file)
@@ -62,5 +62,5 @@ void() main = {
     print3("memb = ", ftos(pawn.memb), "\n");
     pawn.memb += -1;
     print3("memb = ", ftos(pawn.memb), "\n");
-    print3("Frame stand3 is ", ftos(stand3), " wooh\n");
+    print3("Frame stand3 is ", ftos($stand3), " wooh\n");
 };
diff --git a/lexer.c b/lexer.c
index c35a88c747dd6cbc8ddc81b513bc8737c633f8bb..5042c03f5ef941894e3dc714ef41e836fe2545e1 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -542,6 +542,8 @@ int lex_do(lex_file *lex)
        /* modelgen / spiritgen commands */
        if (ch == '$') {
            const char *v;
+           size_t frame;
+
            ch = lex_getch(lex);
            if (!isident_start(ch)) {
                lexerror(lex, "hanging '$' modelgen/spritegen command line");
@@ -618,6 +620,16 @@ int lex_do(lex_file *lex)
                    ch = lex_getch(lex);
                return lex_do(lex);
            }
+
+        for (frame = 0; frame < lex->frames_count; ++frame) {
+            if (!strcmp(v, lex->frames[frame].name)) {
+                lex->tok->constval.i = lex->frames[frame].value;
+                return (lex->tok->ttype = TOKEN_INTCONST);
+            }
+        }
+
+        lexerror(lex, "invalid frame macro");
+        return lex_do(lex);
        }
 
        /* single-character tokens */
@@ -738,7 +750,7 @@ int lex_do(lex_file *lex)
        if (isident_start(ch))
        {
                const char *v;
-               size_t frame;
+
                if (!lex_tokench(lex, ch))
                        return (lex->tok->ttype = TOKEN_FATAL);
                if (!lex_finish_ident(lex)) {
@@ -778,13 +790,6 @@ int lex_do(lex_file *lex)
                         !strcmp(v, "const"))
                        lex->tok->ttype = TOKEN_KEYWORD;
 
-        for (frame = 0; frame < lex->frames_count; ++frame) {
-            if (!strcmp(v, lex->frames[frame].name)) {
-                lex->tok->constval.i = lex->frames[frame].value;
-                return (lex->tok->ttype = TOKEN_INTCONST);
-            }
-        }
-
                return lex->tok->ttype;
        }