From 63fd0813bdbc1f9d9a50a15ad27f5f9ca4a936b2 Mon Sep 17 00:00:00 2001 From: Joe Auricchio Date: Sat, 27 Nov 2010 02:19:36 -0500 Subject: [PATCH] ivlpp: Macros with `__ are checked for magicalness --- ivlpp/lexor.lex | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 07ef5deb0..9b85e6887 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -662,11 +662,13 @@ struct define_t }; static struct define_t* def_table = 0; +static struct define_t* magic_table = 0; -static struct define_t* def_lookup(const char*name) +/* + * helper function for def_lookup + */ +static struct define_t* def_lookup_internal(const char*name, struct define_t*cur) { - struct define_t* cur = def_table; - if (cur == 0) return 0; @@ -685,6 +687,24 @@ static struct define_t* def_lookup(const char*name) return 0; } +static struct define_t* def_lookup(const char*name) +{ + // first, try a magic macro + if(name[0] == '_' && name[1] == '_' && name[2] != '\0') + { + struct define_t* result = def_lookup_internal(name, magic_table); + if(result) + { + return result; + } + } + + // either there was no matching magic macro, or we didn't try looking + // look for a normal macro + return def_lookup_internal(name, def_table); +} + + static int is_defined(const char*name) { return def_lookup(name) != 0;