From: karim hamidou Date: Fri, 24 Apr 2009 20:32:22 +0000 (+0200) Subject: refactoring... X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=5de8f27a10c3b536daa0283421b1d3583188f572;p=croma.git refactoring... --- diff --git a/macro.h b/macro.h index 34cfbca..a62ab23 100644 --- a/macro.h +++ b/macro.h @@ -8,7 +8,14 @@ #include "dynstring.h" +/* + croma_arg is the structure representing a macro in memory. + */ + +enum { T_STRING, T_ARG }; + struct croma_arg { + int type; /* T_STRING, T_ARG, ... */ char *name; char *value; TAILQ_ENTRY(croma_arg) params; diff --git a/parse.c b/parse.c index d6b2a7b..6216380 100644 --- a/parse.c +++ b/parse.c @@ -197,33 +197,12 @@ void parse_block(struct croma_block *b) int t = yylex(); - while (t != RBRACKET && i < 8192) { + while (t != RBRACKET) { switch(t) { case WORD: - defblock = lookup_symbol(yytext); - if (defblock != NULL) { - struct croma_block *env = copy_block(defblock); - if (env == NULL) - fail("Unable to allocate memory for macro environment"); - - - expect(LPAREN); - - struct croma_arg *a; - TAILQ_FOREACH(a, &env->args_head, params) { - t = yylex(); - if (t == RPAREN) - break; - - a->value = strdup(yytext); - } - - expand_macro(env); - } } - strncat(s->contents, yytext, 8192 - i); - i += strlen(yytext); + t = yylex(); }