diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-28 18:57:20 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-28 18:57:20 -0700 |
commit | 80964951224af24407fc18a69f66fc7a7a03aaab (patch) | |
tree | 9e927b6fcfc7806e31558ed4da95229d7dd95b0b | |
parent | 1185ccc974f967b84e7bb0fa087d30d0b4a55477 (diff) | |
download | mu-80964951224af24407fc18a69f66fc7a7a03aaab.tar.gz |
1511 - repl finally passing all its tests again
But I'm sure the next bug is nearby. And even if there's a solution around here, the logic is now quite convoluted, with strings sometimes returning on completion and sometimes recursing further in. We'll need to rethink this.
-rw-r--r-- | repl.mu | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/repl.mu b/repl.mu index ea0bf263..ad98624f 100644 --- a/repl.mu +++ b/repl.mu @@ -214,6 +214,7 @@ recipe slurp-string [ k:address:keyboard <- next-ingredient x:address:screen <- next-ingredient complete:continuation <- next-ingredient + nested-string?:boolean <- next-ingredient trace [app], [slurp-string] # use this to track when backspace should reset color characters-slurped:number <- copy 1:literal # for the initial '[' that's already appended to result @@ -242,7 +243,7 @@ recipe slurp-string [ print-character x:address:screen, c:character, 6:literal/cyan result:address:buffer <- buffer-append result:address:buffer, c:character # make a recursive call to handle nested strings - result:address:buffer, tmp:number, k:address:keyboard, x:address:screen <- slurp-string result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation + result:address:buffer, tmp:number, k:address:keyboard, x:address:screen <- slurp-string result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation, 1:literal/nested? # but if we backspace over a completed nested string, handle it in the caller characters-slurped:number <- add characters-slurped:number, tmp:number, 1:literal # for the leading '[' loop +next-character:label @@ -271,6 +272,12 @@ recipe slurp-string [ break-if done?:boolean loop } + { + break-unless nested-string?:boolean + # nested string? return like a normal recipe + reply result:address:buffer, characters-slurped:number, k:address:keyboard, x:address:screen + } + # top-level string call? recurse trace [app], [slurp-string: close-bracket encountered; recursing to regular characters] result:address:buffer, k:address:keyboard, x:address:screen <- slurp-regular-characters result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation # backspaced back into this string @@ -500,7 +507,7 @@ scenario read-instruction-color-string-inside-string [ #? $start-tracing #? 1 read-instruction keyboard:address, screen:address #? $stop-tracing #? 1 - $browse-trace +#? $browse-trace #? 1 ] screen-should-contain [ .abc [string [inner string]] . |