Permalink
Browse files

Adding support for the {%if_dir } structure in preprocessor expression

  • Loading branch information...
1 parent 48eddaa commit 842f26981b4040ce482b62c21a3fc37f4d09dbb3 noid committed Apr 3, 2012
@@ -222,7 +222,11 @@ NasmParser::Parse(Object& object, Directives& dirs, Diagnostic& diags)
return;
}
- //fputs(result.c_str(), stdout); // for debugging
+ fputs("=================\n", stdout);
+ fputs("=================\n", stdout);
+ fputs(result.c_str(), stdout); // for debugging
+ fputs("=================\n", stdout);
+ fputs("=================\n", stdout);
// override main file with preprocessed source
const char* filename =
@@ -29,6 +29,7 @@ yasm::Object *yasm_object;
static scanner scan; /* Address of scanner routine */
static efunc error; /* Address of error reporting routine */
+static curl_eval curly_evaluator; /*curly structure processor func*/
static struct tokenval *tokval; /* The current token */
static int i; /* The t_type of tokval */
@@ -327,6 +328,17 @@ static bool expr6(Expr* e)
}
i = scan(scpriv, tokval);
return true;
+ } else if (i == '{' ) {
+ void* saved_priv = scpriv;
+ tokenval *saved_tok = tokval;
+ int j = curly_evaluator(scpriv);
+ scpriv = saved_priv;
+ tokval = saved_tok;
+ if( j == -1)
+ return false;
+ *e = Expr(IntNum(j));
+ i = scan(scpriv, tokval);
+ return true;
}
else if (i == TOKEN_NUM || i == TOKEN_ID ||
i == TOKEN_HERE || i == TOKEN_BASE)
@@ -368,14 +380,16 @@ static bool expr6(Expr* e)
}
Expr *nasm_evaluate (scanner sc, void *scprivate, struct tokenval *tv,
- int critical, efunc report_error)
+ int critical, efunc report_error,
+ curl_eval _curly_evaluator)
{
if (critical & CRITICAL) {
critical &= ~CRITICAL;
bexpr = rexp0;
} else
bexpr = expr0;
+ curly_evaluator = _curly_evaluator;
scan = sc;
scpriv = scprivate;
tokval = tv;
@@ -21,7 +21,9 @@ extern yasm::Object* yasm_object;
* The evaluator itself.
*/
yasm::Expr *nasm_evaluate (scanner sc, void *scprivate, struct tokenval *tv,
- int critical, efunc report_error);
+ int critical, efunc report_error,
+ curl_eval _curly_evaluator);
+
} // namespace nasm
Oops, something went wrong.

0 comments on commit 842f269

Please sign in to comment.