mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Add blank lines to make the output somewhat prettier
Add blank lines between functions, between functions and states, between variables and functions or states, between states, and between events. Or more concisely: add blank lines between events and between all elements at the global level except between variables (that actually describes the algorithm). Some test cases expected no newlines; fix them.
This commit is contained in:
parent
fab3ce4d24
commit
fa547cd9e8
2 changed files with 19 additions and 4 deletions
|
@ -456,8 +456,14 @@ class outscript(object):
|
|||
|
||||
ret += self.dent() + '{\n'
|
||||
self.indentlevel += 1
|
||||
firstnode = True
|
||||
for stmt in node.ch:
|
||||
if stmt.nt == 'LAMBDA':
|
||||
continue
|
||||
if nt == 'STDEF' and not firstnode:
|
||||
ret += '\n'
|
||||
ret += self.OutCode(stmt)
|
||||
firstnode = False
|
||||
self.indentlevel -= 1
|
||||
return ret + self.dent() + '}\n'
|
||||
|
||||
|
@ -499,9 +505,18 @@ class outscript(object):
|
|||
self.indentlevel = 0
|
||||
self.globalmode = False
|
||||
self.listmode = False
|
||||
firstnode = True
|
||||
prevnt = None
|
||||
for node in self.tree:
|
||||
if node.nt == 'LAMBDA':
|
||||
# these don't produce output, skip
|
||||
continue
|
||||
if not firstnode and (node.nt != 'DECL' or prevnt != 'DECL'):
|
||||
ret += '\n'
|
||||
self.globalmode = node.nt == 'DECL'
|
||||
ret += self.OutCode(node)
|
||||
self.globalmode = False
|
||||
firstnode = False
|
||||
prevnt = node.nt
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue