aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2011-05-24 18:00:31 +0200
committerSebastian Parborg <darkdefende@gmail.com>2011-05-24 18:00:31 +0200
commitb915fd549bdd124d0c43b5caa02a4f531ae5e3e8 (patch)
tree2d4df243aeba331d1169fa18adc0ad5d8eb96dc9
parentCleaned up ifdef somemore. (diff)
downloadebuildgen-b915fd549bdd124d0c43b5caa02a4f531ae5e3e8.tar.gz
ebuildgen-b915fd549bdd124d0c43b5caa02a4f531ae5e3e8.tar.bz2
ebuildgen-b915fd549bdd124d0c43b5caa02a4f531ae5e3e8.zip
Got everything (hopefully) working again...
-rw-r--r--cli.py8
-rw-r--r--scanfiles.py25
-rw-r--r--test.h12
3 files changed, 27 insertions, 18 deletions
diff --git a/cli.py b/cli.py
index 0203cd4..6b6f8a5 100644
--- a/cli.py
+++ b/cli.py
@@ -19,9 +19,11 @@ args = parser.parse_args()
#print(args.dir)
#print(args.types)
-(globinc,localinc) = scanfiles.startscan(args.dir,args.types)
+#inclst is a list of includes. First in it is global then local.
+
+inclst = scanfiles.startscan(args.dir,args.types)
if args.ginc:
- print(globinc)
+ print(inclst[0])
if args.linc:
- print(localinc)
+ print(inclst[1])
diff --git a/scanfiles.py b/scanfiles.py
index 5c3b047..db96169 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -15,7 +15,7 @@ def scandir(dir, filetypes):
#lex stuff begins here
-def scanincludes(string,global_hfiles,local_hfiles):
+def scanincludes(string,inclst):
tokens = (
"INCLUDE",
"GLOBH",
@@ -58,7 +58,7 @@ def scanincludes(string,global_hfiles,local_hfiles):
r"\#ifdef"
t.lexer.push_state("com")
- def t_begin_IFDEF(t):
+ def t_IFDEF(t):
r"\#ifdef[ \t]+[a-zA-Z_][a-zA-Z0-9_]*"
t.value = t.value[6:].strip() #return the ifdef name
t.lexer.push_state("ifdef")
@@ -104,41 +104,48 @@ def scanincludes(string,global_hfiles,local_hfiles):
"""
includes : includes ginc
| includes linc
+ | includes buninc
+ | includes IFDEF includes ENDIF
"""
def p_includes(p):
"""
includes : ginc
| linc
+ | buninc
"""
def p_ginclude(p):
"ginc : INCLUDE GLOBH"
- global_hfiles.add(p[2])
+ inclst[0].add(p[2])
- def p_linclide(p):
+ def p_linclude(p):
"linc : INCLUDE LOCALH"
- local_hfiles.add(p[2])
+ inclst[1].add(p[2])
+
+ def p_bununclude(p):
+ "buninc : INCLUDE BUNDLEINC"
def p_error(p):
- #print("syntax error at '%s'" % p.value)
+ print("syntax error at '%s'" % p.value)
pass
yacc.yacc()
yacc.parse(string)
- return(global_hfiles,local_hfiles)
+ return(inclst)
def startscan(dir,filetypes):
global_hfiles = set()
local_hfiles = set()
+ inclst = [global_hfiles,local_hfiles]
for file in scandir(dir, filetypes):
print(file)
with open(file, encoding="utf-8", errors="replace") as inputfile:
- (global_hfiles,local_hfiles) = scanincludes(inputfile.read(),global_hfiles,local_hfiles)
+ inclst = scanincludes(inputfile.read(),inclst)
- return(global_hfiles,local_hfiles)
+ return(inclst)
diff --git a/test.h b/test.h
index 758ed83..93735de 100644
--- a/test.h
+++ b/test.h
@@ -1,16 +1,16 @@
-#include <1.h>
+#include <glob1.h>
#include <io>
-#include <2.h>
-#include "3.h"
+#include <glob2.h>
+#include "loc1.h"
/*
#include "comment.h"
sdasdasdasd */
// #include "linecom.h"
-#include "notlast.h"
+#include "loc2.h"
#include <strings>
/* ok... */
-#include <3.h>
+#include <glob3.h>
#if 0
#if 0
@@ -23,4 +23,4 @@ sdasdasdasd */
#include <sound.h>
#endif
-#include "last.h"
+#include "loc3.h"