From 3b9a6b3ace8b7358eee5ecdfdd2b998a7fbacfb0 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Thu, 16 Aug 2012 20:49:58 +0200 Subject: [PATCH] Don't expand frame macros when they don't have a $ prefix --- data/parsing.qc | 2 +- lexer.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/data/parsing.qc b/data/parsing.qc index 5c61f8c..f75a136 100644 --- a/data/parsing.qc +++ b/data/parsing.qc @@ -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 c35a88c..5042c03 100644 --- 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; } -- 2.39.2