public
/
piyacc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
42898b3
)
Modify ast_text_to_python() to handle stray whitespace on otherwise blank line
author
Nick Downing
<nick@ndcode.org>
Sat, 18 Nov 2023 23:01:38 +0000
(10:01 +1100)
committer
Nick Downing
<nick@ndcode.org>
Sat, 18 Nov 2023 23:05:59 +0000
(10:05 +1100)
ndcode/piyacc/generate_py.py
patch
|
blob
|
history
diff --git
a/ndcode/piyacc/generate_py.py
b/ndcode/piyacc/generate_py.py
index
82478d9
..
c6c86ce
100644
(file)
--- a/
ndcode/piyacc/generate_py.py
+++ b/
ndcode/piyacc/generate_py.py
@@
-40,11
+40,12
@@
def ast_text_to_python(ast_text, indent):
#print(text)
prefix = lines[0][:j]
for j in range(len(lines)):
- if len(lines[j]) == 0:
- lines[j] = '\n'
- else:
- assert lines[j][:len(prefix)] == prefix
- lines[j] = '{0:s}{1:s}\n'.format(indent, lines[j][len(prefix):])
+ assert lines[j][:len(prefix)] == prefix[:len(lines[j])]
+ lines[j] = (
+ '\n'
+ if len(lines[j]) <= len(prefix) else
+ '{0:s}{1:s}\n'.format(indent, lines[j][len(prefix):])
+ )
return ''.join(lines)
def generate_py(