|
|
|
@ -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 |
|
|
|
|