Commit d02556c8e288c42a549c0b0b20ada1b7b0723528
1 parent
3c7d42b6
dodana obsługa #else
git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/morfeusz@158 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing
1 changed file
with
7 additions
and
1 deletions
fsabuilder/morfeuszbuilder/segrules/preprocessor.py
... | ... | @@ -76,6 +76,7 @@ def _processLine(lineNum, line, defines, filename): |
76 | 76 | def preprocess(inputLines, defs, filename): |
77 | 77 | defines = {} |
78 | 78 | ifdefsStack = [] |
79 | + wasElse = False | |
79 | 80 | for lineNum, line in inputLines: |
80 | 81 | if line.startswith('#define'): |
81 | 82 | parsedDefine = list(pyparseString(define, lineNum, line, filename)) |
... | ... | @@ -92,8 +93,13 @@ def preprocess(inputLines, defs, filename): |
92 | 93 | name = pyparseString(ifdef, lineNum, line, filename)[0] |
93 | 94 | # name = ifdef.parseString(line)[0] |
94 | 95 | ifdefsStack.append(name) |
95 | - elif line.startswith('#endif'): | |
96 | + elif line.startswith('#else'): | |
96 | 97 | ifdefsStack.pop() |
98 | + wasElse = True | |
99 | + elif line.startswith('#endif'): | |
100 | + if not wasElse: | |
101 | + ifdefsStack.pop() | |
102 | + wasElse = False | |
97 | 103 | elif line.startswith('#'): |
98 | 104 | yield lineNum, line |
99 | 105 | elif len(ifdefsStack) == 0 or all(map(lambda name: name in defs, ifdefsStack)): |
... | ... |