diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/cmake2meson.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tools/cmake2meson.py b/tools/cmake2meson.py index 5a27a51..05acd8f 100755 --- a/tools/cmake2meson.py +++ b/tools/cmake2meson.py @@ -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 - line = 'elif %s' % self.convert_args(t.args, False) + 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 |