[wmlparser2] Fixed issue with .plain file parsing

For example defined strings with empty lines would not work. The problem
was a direct check for newlines which failed if there were chr(254)
commands on the same line.
This commit is contained in:
Allefant 2014-01-04 23:54:16 +01:00
parent 855ffbe358
commit 5ad589066c

View file

@ -351,6 +351,17 @@ class Parser:
else:
for i, segment in enumerate(line.split("+")):
segment = segment.lstrip(" ")
empty = not segment.strip()
# if a plus sign is followed by only whitespace on that line,
# we need to ignore the following empty lines to find the
# continuation
if i > 0 and empty:
self.skip_newlines = True
elif not empty:
self.skip_newlines = False
if not segment: continue
if segment[0] == "_":
@ -358,10 +369,6 @@ class Parser:
segment = segment[1:].lstrip(" ")
if not segment: continue
if i > 0 and segment == "\n":
self.skip_newlines = True
elif segment != "\n":
self.skip_newlines = False
self.handle_value(segment)
def handle_tag(self, line):
@ -702,6 +709,18 @@ foo="bar"+
foo='bar' .. 'baz'
""", "multi line string")
test(
"""
#define baz
"baz"
#enddef
foo="bar"+{baz}
""",
"""
foo='bar' .. 'baz'
""", "defined multi line string")
test2(
"""
[test]