aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2011-05-24 17:10:01 +0200
committerSebastian Parborg <darkdefende@gmail.com>2011-05-24 17:10:01 +0200
commit84e34703eb4315ffcf6e51b02eee0e7f4844d63f (patch)
tree9efa6d352cb94659db888f9fa01d3cf27aea4d27
parentFixed comments being greedy and begun on ifdefs (diff)
downloadebuildgen-84e34703eb4315ffcf6e51b02eee0e7f4844d63f.tar.gz
ebuildgen-84e34703eb4315ffcf6e51b02eee0e7f4844d63f.tar.bz2
ebuildgen-84e34703eb4315ffcf6e51b02eee0e7f4844d63f.zip
Cleaned up ifdef somemore.
-rw-r--r--TODO1
-rw-r--r--scanfiles.py15
2 files changed, 13 insertions, 3 deletions
diff --git a/TODO b/TODO
index c885cd8..c0c5402 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,3 @@
Fix issues with UTF-8 encoded filenames
Handle #ifdef, #IFDEF, #IF 0 etc
+Handle "# include"
diff --git a/scanfiles.py b/scanfiles.py
index 306fcb9..5c3b047 100644
--- a/scanfiles.py
+++ b/scanfiles.py
@@ -20,7 +20,9 @@ def scanincludes(string,global_hfiles,local_hfiles):
"INCLUDE",
"GLOBH",
"LOCALH",
- "BUNDLEINC"
+ "BUNDLEINC",
+ "IFDEF",
+ "ENDIF",
)
states = (
@@ -52,13 +54,20 @@ def scanincludes(string,global_hfiles,local_hfiles):
t.lexer.pop_state()
pass
- def t_ANY_ifdef(t):
+ def t_com_ifdef(t):
r"\#ifdef"
+ t.lexer.push_state("com")
+
+ def t_begin_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")
+ return t
- def t_ifdef_endif(t):
+ def t_ifdef_ENDIF(t):
r"\#endif"
t.lexer.pop_state()
+ return t
def t_INCLUDE(t):
r"\#[Ii][Nn][Cc][Ll][Uu][Dd][Ee]"