aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2011-05-13 22:20:09 +0200
committerSebastian Parborg <darkdefende@gmail.com>2011-05-13 22:20:09 +0200
commitb3155735b1f98617eb24c196ae30ccd834e8a4ca (patch)
tree1f7dfc8840d8a660104dc1927dac568d238b5da9
parentBegin to look for includes (diff)
downloadebuildgen-b3155735b1f98617eb24c196ae30ccd834e8a4ca.tar.gz
ebuildgen-b3155735b1f98617eb24c196ae30ccd834e8a4ca.tar.bz2
ebuildgen-b3155735b1f98617eb24c196ae30ccd834e8a4ca.zip
More work on includes
-rw-r--r--scanfiles.py53
-rw-r--r--test.h2
2 files changed, 48 insertions, 7 deletions
diff --git a/scanfiles.py b/scanfiles.py
index 13a1cad..0de0ead 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -3,7 +3,8 @@ import glob
from ply import lex
from ply import yacc
-needed_hfiles = {}
+global_hfiles = set()
+local_hfiles = set()
def scandir(dir, filetype):
files = []
@@ -26,7 +27,8 @@ with open("test.h", encoding="utf-8") as inputfile:
tokens = (
"INCLUDE",
"GLOBH",
- "LOCALH"
+ "LOCALH",
+ "BUNDLEINC"
)
t_ignore = " \t"
@@ -40,11 +42,17 @@ def t_INCLUDE(t):
return t
def t_GLOBH(t):
- r"<.*>"
+ r"<.*\.h>"
+ t.value = t.value[1:-1] #strip <>
return t
def t_LOCALH(t):
- r"\".*\""
+ r"\".*\.h\""
+ t.value = t.value[1:-1] #strip ""
+ return t
+
+def t_BUNDLEINC(t): #for <string> etc.
+ r"<.*>"
return t
def t_error(t):
@@ -53,7 +61,38 @@ def t_error(t):
lexer = lex.lex()
-lexer.input(input_string)
+#lexer.input(input_string)
+#
+#for tok in lexer:
+# print(tok)
+#
+#YACC stuff here
+
+def p_includes2(p):
+ """
+ includes : includes ginc
+ | includes linc
+ """
+
+def p_includes(p):
+ """
+ includes : ginc
+ | linc
+ """
+
+def p_ginclude(p):
+ "ginc : INCLUDE GLOBH"
+ needed_hfiles.add(p[2])
+
+def p_linclide(p):
+ "linc : INCLUDE LOCALH"
+ needed_hfiles.add(p[2])
+
+def p_error(p):
+ #print("syntax error at '%s'" % p.value)
+ pass
+
+yacc.yacc()
-for tok in lexer:
- print(tok)
+print(yacc.parse(input_string))
+print(needed_hfiles)
diff --git a/test.h b/test.h
index 15d1289..1676292 100644
--- a/test.h
+++ b/test.h
@@ -1,4 +1,5 @@
#include <1.h>
+#include <io>
#include <2.h>
#include "3.h"
/*
@@ -6,3 +7,4 @@
sdasdasdasd */
// #include "wrong.h"
#include "last.h"
+#include <strings>