fix: Fixes skipping empty or comment lines in groups and dialogs (#429)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-11-07 23:46:13 +01:00
committed by GitHub
parent 53967dfd0b
commit 8b70448bf7
2 changed files with 12 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ func _test_basic() -> bool:
say player "Test3" [test2]
# Third group
>
say player "Test4"
# Fourth group
>
@@ -177,11 +178,10 @@ func _test_event_flags() -> bool:
var script = escoria.esc_compiler.compile(esc.split("\n"))
var subject = script.events
assert(subject.keys().size() == 4)
assert(subject.keys().size() == 3)
assert("test" in subject.keys())
assert("test2" in subject.keys())
assert("test3" in subject.keys())
assert("test4" in subject.keys())
subject = script.events["test"]
assert(subject.name == "test")
@@ -279,7 +279,7 @@ func _test_dialog() -> bool:
subject = script.events["test"].statements[0].options[3]
assert(subject is ESCDialogOption)
assert(subject.option == "TEST:Option 4")
assert(subject.option == "TEST")
return true

View File

@@ -139,6 +139,9 @@ func _compile(lines: Array) -> Array:
var group_lines = []
while lines.size() > 0:
var next_line = lines.pop_front()
if comment_regex.search(next_line) or \
empty_regex.search(next_line):
continue
var next_line_indent = \
escoria.utils.get_re_group(
indent_regex.search(next_line),
@@ -162,6 +165,9 @@ func _compile(lines: Array) -> Array:
var dialog_lines = []
while lines.size() > 0:
var next_line = lines.pop_front()
if comment_regex.search(next_line) or \
empty_regex.search(next_line):
continue
var end_line = dialog_end_regex.search(next_line)
if end_line and \
escoria.utils.get_re_group(
@@ -189,6 +195,9 @@ func _compile(lines: Array) -> Array:
var dialog_option_lines = []
while lines.size() > 0:
var next_line = lines.pop_front()
if comment_regex.search(next_line) or \
empty_regex.search(next_line):
continue
var next_line_indent = \
escoria.utils.get_re_group(
indent_regex.search(next_line),