diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2011-06-01 15:46:22 +0200 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2011-06-01 15:46:22 +0200 |
commit | 55851f2ae36d0eac1905488ac16a472846b1dc5e (patch) | |
tree | 47a59fec0ebabf9ba57c202d67070ce66b4b37d7 | |
parent | Worked more on ifdefs and made YACC not a big hack (diff) | |
download | ebuildgen-55851f2ae36d0eac1905488ac16a472846b1dc5e.tar.gz ebuildgen-55851f2ae36d0eac1905488ac16a472846b1dc5e.tar.bz2 ebuildgen-55851f2ae36d0eac1905488ac16a472846b1dc5e.zip |
I now handles ifdefs within ifdefs
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | scanfiles.py | 29 | ||||
-rw-r--r-- | test.h | 21 |
3 files changed, 43 insertions, 8 deletions
@@ -4,3 +4,4 @@ Handle "# include" implement ifndef #include "file.h" doesn't restict it to be a local include, add checks! Handle dlopen() "includes" +Perhaps multithread some stuff so the rest of the program doesn't have to wait for the parser to finish diff --git a/scanfiles.py b/scanfiles.py index df39c2f..3f31dea 100644 --- a/scanfiles.py +++ b/scanfiles.py @@ -116,12 +116,7 @@ def scanincludes(string,inclst): """ print("found ifdef!") if len(p) == 5: - if p[2] in p[1][2]: - p[1][2][p[2]][0] = p[1][2][p[2]][0] | p[3][0] - p[1][2][p[2]][1] = p[1][2][p[2]][1] | p[3][1] - else: - p[1][2][p[2]] = p[3] - + p[1][2] = addnewifdefs(p[1][2],{p[2] : p[3]}) p[0] = p[1] else: print("ifdef before any includes!") @@ -158,6 +153,28 @@ def scanincludes(string,inclst): print(yacc.parse(string)) return(inclst) +def addnewincludes(inclist1,inclist2): + #come up with better names!! + inclist1[0] = inclist1[0] | inclist2[0] + inclist1[1] = inclist1[1] | inclist2[1] + return(inclist1) + +def addnewifdefs(dict1,dict2): + if dict1 == {} and dict2 == {}: + #we are done here + return(dict()) + dups = dict1.keys() & dict2.keys() + if dups == set(): + #no duplicates, empty set() + for name in dict2: + dict1[name] = dict2[name] + return(dict1) + + for name in dups: + dict1[name][0] = dict1[name][0] | dict2[name][0] + dict1[name][1] = dict1[name][1] | dict2[name][1] + dict1[name][2] = addnewifdefs(dict1[name][2],dict2[name][2]) + return(dict1) def startscan(dir,filetypes): global_hfiles = set() @@ -1,3 +1,6 @@ +#ifdef IFDEF1 + #include "ifdef1.h" +#endif #include <glob1.h> #include <io> @@ -19,8 +22,22 @@ sdasdasdasd */ #include <if0_wrong.h> #endif -#ifdef SOUND - #include <sound.h> +#ifdef IFDEF2 + #include <ifdef2.h> #endif #include "loc3.h" + +#ifdef IFDEF2 + #include <ifdef2.h> + #ifdef IFDEF3 + #include "ifdef3.h" + #endif + #include "ifdef2.h" +#endif + +#ifdef IFDEF2 + #ifdef IFDEF3 + #include <ifdef3.h> + #endif +#endif |