Add #ifdef to preprocessor
parent
621a8937af
commit
d41b533008
10
mt2obj.py
10
mt2obj.py
|
@ -74,6 +74,16 @@ def pp_process(ctx, line):
|
||||||
else:
|
else:
|
||||||
ctx[0]['if_state'] = 2 # ignore current lines, expecting #else or #endif
|
ctx[0]['if_state'] = 2 # ignore current lines, expecting #else or #endif
|
||||||
return None
|
return None
|
||||||
|
elif line.startswith('#ifdef'): #e.g.: #ifdef name
|
||||||
|
tmp = line.split(' ')
|
||||||
|
if len(tmp) < 2:
|
||||||
|
raise Exception('Missing something..')
|
||||||
|
tmp = tmp[1]
|
||||||
|
if tmp in ctx[1].keys():
|
||||||
|
ctx[0]['if_state'] = 1 # don't ignore current lines, expecting #else or #endif
|
||||||
|
else:
|
||||||
|
ctx[0]['if_state'] = 2 # ignore current lines, expecting #else or #endif
|
||||||
|
return None
|
||||||
elif line.startswith('#else') and ctx[0]['if_state'] == 1:
|
elif line.startswith('#else') and ctx[0]['if_state'] == 1:
|
||||||
ctx[0]['if_state'] = 4 # ignore current lines, expecting #endif
|
ctx[0]['if_state'] = 4 # ignore current lines, expecting #endif
|
||||||
elif line.startswith('#else') and ctx[0]['if_state'] == 2:
|
elif line.startswith('#else') and ctx[0]['if_state'] == 2:
|
||||||
|
|
Loading…
Reference in New Issue