cmake2meson fix if nesting
@@ -139,6 +139,16 @@ class Parser:
while not self.accept('eof'):
yield(self.statement())
+def token_or_group(arg):
+ if isinstance(arg, Token):
+ return ' ' + arg.value
+ elif isinstance(arg, list):
+ line = ' ('
+ for a in arg:
+ line += ' ' + token_or_group(a)
+ line += ' )'
+ return line
+
class Converter:
ignored_funcs = {'cmake_minimum_required': True,
'enable_testing': True,
@@ -237,17 +247,16 @@ class Converter:
except AttributeError: # complex if statements
line = t.name
for arg in t.args:
- if isinstance(arg, Token):
- line += ' ' + arg.value
- elif isinstance(arg, list):
- line += ' ('
- for a in arg:
- line += ' ' + a.value
- line += ' )'
+ line += token_or_group(arg)
elif t.name == 'elseif':
preincrement = -1
postincrement = 1
+ try:
line = 'elif %s' % self.convert_args(t.args, False)
+ except AttributeError: # complex if statements
+ line = t.name
+ for arg in t.args:
+ line += token_or_group(arg)
elif t.name == 'else':
preincrement = -1
postincrement = 1
