WIP almost have the last edge cases

This commit is contained in:
2019-03-16 21:58:32 -06:00
parent 65bc082b9f
commit c3a363ab45
3 changed files with 23 additions and 2 deletions

View File

@@ -15,5 +15,5 @@ You can {
You can have diverts inline. -> somewhere_else
You can have diverts as branches of a sequence {> -> first_time|-> second_time}
You can have partial output[.]that changes after a choice is made!
You can have partial output[.] that changes after a choice is made!
You can have partial output [{really_tricky_now} with expressions inside it!] that changes after a choice is made!

View File

@@ -26,6 +26,23 @@ class Output {
var parts = [];
// First of all, split up the optional segments (ToggleOutputs) and parse them separately
// TODO this doesn't work because it seeks ahead to the next bracket through ALL LINES of the buffer. This needs to only run when we're on an individual line
var findBracketExpression = buffer.findNestedExpression('[', ']');
switch (findBracketExpression) {
case Some(slice):
var part1 = buffer.take(slice.start);
buffer.take(1);
var part2 = buffer.take(slice.length-2);
buffer.take(1);
var parts = parse(HankBuffer.Dummy(part1)).parts;
parts.push(ToggleOutput(parse(HankBuffer.Dummy(part2)), false));
parts.push(ToggleOutput(parse(buffer), true));
return new Output(parts);
case None:
// This is an individual Output to parse
}
while (!buffer.isEmpty()) {

View File

@@ -75,7 +75,11 @@ class ParserTest extends utest.Test {
])
]))
])));
trace(nextExpr());
assertNextExpr(EOutput(new Output([
Text("You can have partial output"),
ToggleOutput(new Output([Text(".")]), false),
ToggleOutput(new Output([Text(" that changes after a choice is made!")]), true)
])));
trace(nextExpr());
}