diff options
author | 2011-05-13 20:43:01 +0200 | |
---|---|---|
committer | 2011-05-13 20:43:01 +0200 | |
commit | 18d3d5d921ac8a5298119c9ecb2172be2614f23c (patch) | |
tree | b01bc74c85b78b0727065c25c94c6dd4582232c2 | |
parent | Not much, but it scans dirs :P (diff) | |
download | ebuildgen-18d3d5d921ac8a5298119c9ecb2172be2614f23c.tar.gz ebuildgen-18d3d5d921ac8a5298119c9ecb2172be2614f23c.tar.bz2 ebuildgen-18d3d5d921ac8a5298119c9ecb2172be2614f23c.zip |
Begin to look for includes
-rw-r--r-- | scanfiles.py | 47 | ||||
-rw-r--r-- | test.h | 8 |
2 files changed, 54 insertions, 1 deletions
diff --git a/scanfiles.py b/scanfiles.py index bbb63b8..13a1cad 100644 --- a/scanfiles.py +++ b/scanfiles.py @@ -1,5 +1,7 @@ import os import glob +from ply import lex +from ply import yacc needed_hfiles = {} @@ -11,4 +13,47 @@ def scandir(dir, filetype): files += scandir(dir + "/" + dir_path, filetype) return files + glob.glob(dir + "/*" + filetype) -print(scandir("/home/zed/Desktop/test/smw/", ".cpp")) +#print(scandir("/home/zed/Desktop/test/smw/", ".cpp")) + +#lex stuff begins here + +input_string = "" + +with open("test.h", encoding="utf-8") as inputfile: + input_string = inputfile.read() + print(input_string) + +tokens = ( + "INCLUDE", + "GLOBH", + "LOCALH" + ) + +t_ignore = " \t" + +def t_comment(t): + r'(/\*(.|\n)*\*/)|(//.*)' + pass + +def t_INCLUDE(t): + r"\#[Ii][Nn][Cc][Ll][Uu][Dd][Ee]" + return t + +def t_GLOBH(t): + r"<.*>" + return t + +def t_LOCALH(t): + r"\".*\"" + return t + +def t_error(t): + #print("Illegal character '%s'" % t.value[0]) + t.lexer.skip(1) + +lexer = lex.lex() + +lexer.input(input_string) + +for tok in lexer: + print(tok) @@ -0,0 +1,8 @@ +#include <1.h> +#include <2.h> +#include "3.h" +/* +#include "wrong.h" +sdasdasdasd */ +// #include "wrong.h" +#include "last.h" |