diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2011-06-01 14:20:03 +0200 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2011-06-01 14:20:03 +0200 |
commit | de8d1b22568c750ce80abf288e086fa71283db10 (patch) | |
tree | e83d3b69d62019f8701654cd3fc8900b2643fe01 | |
parent | Fixed some bugs (diff) | |
download | ebuildgen-de8d1b22568c750ce80abf288e086fa71283db10.tar.gz ebuildgen-de8d1b22568c750ce80abf288e086fa71283db10.tar.bz2 ebuildgen-de8d1b22568c750ce80abf288e086fa71283db10.zip |
Worked more on ifdefs and made YACC not a big hack
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | scanfiles.py | 50 |
2 files changed, 43 insertions, 9 deletions
@@ -2,3 +2,5 @@ Fix issues with UTF-8 encoded filenames Handle #ifdef, #IFDEF, #IF 0 etc Handle "# include" implement ifndef +#include "file.h" doesn't restict it to be a local include, add checks! +Handle dlopen() "includes" diff --git a/scanfiles.py b/scanfiles.py index e6c493e..df39c2f 100644 --- a/scanfiles.py +++ b/scanfiles.py @@ -98,24 +98,56 @@ def scanincludes(string,inclst): def p_includes2(p): """ includes : includes ginc - | includes linc - | includes IFDEF includes ENDIF - | IFDEF includes ENDIF """ + p[1][0].add(p[2]) + p[0] = p[1] - def p_includes(p): + def p_lincludes(p): + """ + includes : includes linc """ - includes : ginc - | linc + p[1][1].add(p[2]) + p[0] = p[1] + + def p_ifdef(p): + """ + includes : includes IFDEF includes ENDIF + | IFDEF includes ENDIF """ + 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[0] = p[1] + else: + print("ifdef before any includes!") + ifdef = {} + ifdef[p[1]] = p[2] + p[0] = [set(),set(),ifdef] + + def p_ginc(p): + "includes : ginc" + globinc = set() + globinc.add(p[1]) + p[0] = [globinc,set(),{}] + + def p_linc(p): + "includes : linc" + locinc = set() + locinc.add(p[1]) + p[0] = [set(),locinc,{}] def p_ginclude(p): "ginc : GINCLUDE" - inclst[0].add(p[1]) + p[0] = p[1] def p_linclude(p): "linc : LINCLUDE" - inclst[1].add(p[1]) + p[0] = p[1] def p_error(p): #print("syntax error at '%s'" % p.type) @@ -123,7 +155,7 @@ def scanincludes(string,inclst): yacc.yacc() - yacc.parse(string) + print(yacc.parse(string)) return(inclst) |