diff --git a/examples/labels/main.hank b/examples/labels/main.hank index 9085265..eeb269d 100644 --- a/examples/labels/main.hank +++ b/examples/labels/main.hank @@ -7,7 +7,7 @@ B: {choice_b} C: {choice_c} * (choice_a) Choice A * (choice_b) Choice B -* (choice_c) {choice_b && choice_a} Choice C +* (choice_c) {choice_b && choice_a}? Choice C -> end - (gather) -> start diff --git a/examples/main/extra.hank b/examples/main/extra.hank index afc7000..e4d27a7 100644 --- a/examples/main/extra.hank +++ b/examples/main/extra.hank @@ -16,7 +16,7 @@ You can include choices for the player. ~ flag = true; ~ var what_happened = "mouse"; + Door B []opens but the room on the other side is {word}! -* {flag} Choices can depend on logical conditions being truthy. +* {flag}? Choices can depend on logical conditions being truthy. -> final_choice - -> choice_example // a hyphen gathers all choices to the same place. diff --git a/examples/mindfuck/main.hank b/examples/mindfuck/main.hank index fd5ac50..f3275db 100644 --- a/examples/mindfuck/main.hank +++ b/examples/mindfuck/main.hank @@ -9,8 +9,8 @@ if (start <= 2) { Loop #: {start} * A series of choices * In Hank script embedded in Haxe script embedded in Hank script! - * {start == 1} What could be more fun? - * {start == 2} Gosh this sucks + * {start == 1}? What could be more fun? + * {start == 2}? Gosh this sucks - -> sanity ,,, } else { diff --git a/hank/HankBuffer.hx b/hank/HankBuffer.hx index 1e2c80d..b6485fa 100644 --- a/hank/HankBuffer.hx +++ b/hank/HankBuffer.hx @@ -321,7 +321,7 @@ class HankBuffer { /** If the given expression comes next in the buffer, take its contents. Otherwise, return None **/ public function expressionIfNext(o:String, c:String):Option { - if (cleanBuffer.startsWith(o)) { + if (cleanBuffer.startsWith(o) && cleanBuffer.indexOf(c) != -1) { drop(o); var end = cleanBuffer.indexOf(c); var content = take(end); diff --git a/hank/Parser.hx b/hank/Parser.hx index 1f0c30d..01d7dae 100644 --- a/hank/Parser.hx +++ b/hank/Parser.hx @@ -13,8 +13,17 @@ import hank.HankBuffer; @:allow(tests.ParserTest) class Parser { static var symbols:ArrayHankBuffer.Position->ExprType>> = [ - ['INCLUDE ' => include], ['<-' => thread], ['->' => divert], ['===' => knot], ['==' => knot], ['=' => stitch], ['~' => haxeLine], - ['```' => haxeBlock], ['-' => gather], ['*' => choice], ['+' => choice]]; + ['INCLUDE ' => include], + ['<-' => thread], + ['->' => divert], + ['===' => knot], + ['==' => knot], + ['=' => stitch], + ['~' => haxeLine], + ['```' => haxeBlock], + ['-' => gather], + ['*' => choice], + ['+' => choice]]; var buffers:Array = []; var ast:HankAST = []; @@ -198,7 +207,7 @@ class Parser { buffer.skipWhitespace(); var label = buffer.expressionIfNext('(', ')'); buffer.skipWhitespace(); - var condition = buffer.expressionIfNext('{', '}'); + var condition = buffer.expressionIfNext('{', '}?'); buffer.skipWhitespace(); var output = Output.parse(buffer); var divertTarget = output.takeInlineDivert();