cmake2meson fix if nesting (#6676)

pull/6685/head
Yann Dirson 5 years ago committed by GitHub
parent 8bf937b012
commit ee94cb6c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      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

Loading…
Cancel
Save