diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-12 22:34:45 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-12 22:34:45 -0700 |
commit | d44123cabaa730c778a0e2644c75dbfba6a7ab30 (patch) | |
tree | a24e90f9fc864ea5b1c5e1f13433f55ad7acd30b /html/repl.mu.html | |
parent | 1ae4e0d95f7e37dc7d0b146542fc39b4aed491de (diff) | |
download | mu-d44123cabaa730c778a0e2644c75dbfba6a7ab30.tar.gz |
1556
Diffstat (limited to 'html/repl.mu.html')
-rw-r--r-- | html/repl.mu.html | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/html/repl.mu.html b/html/repl.mu.html index 2a9f4d62..2ccd9f9b 100644 --- a/html/repl.mu.html +++ b/html/repl.mu.html @@ -13,14 +13,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1em; } -.Delimiter { color: #c000c0; } .muScenario { color: #00af00; } +.Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } -.muRecipe { color: #ff8700; } .CommentedCode { color: #6c6c6c; } +.muControl { color: #804000; } +.muRecipe { color: #ff8700; } --> </style> @@ -35,7 +35,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># interactive prompt for mu</span> <span class="muRecipe">recipe</span> main [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> switch-to-display msg:address:array:character<span class="Special"> <- </span>new <span class="Constant">[ready! type in an instruction, then hit enter. ctrl-d exits.</span> <span class="Constant">]</span> @@ -46,16 +46,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } ] <span class="muRecipe">recipe</span> color-session [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - keyboard:address<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - screen:address<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + keyboard:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> inst:address:array:character, keyboard:address, screen:address<span class="Special"> <- </span>read-instruction keyboard:address, screen:address - <span class="Identifier">break-unless</span> inst:address:array:character + <span class="muControl">break-unless</span> inst:address:array:character run-interactive inst:address:array:character - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> keyboard:address/same-as-ingredient:0, screen:address/same-as-ingredient:1 + <span class="muControl">reply</span> keyboard:address/same-as-ingredient:0, screen:address/same-as-ingredient:1 ] <span class="Comment"># basic keyboard input; just text and enter</span> @@ -90,45 +90,45 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Most of the complexity is for the printing to screen, to highlight strings</span> <span class="Comment"># and comments specially. Especially in the presence of backspacing.</span> <span class="muRecipe">recipe</span> read-instruction [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">60:literal</span> - k:address:keyboard<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">60:literal</span> + k:address:keyboard<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> result:address:buffer<span class="Special"> <- </span>init-buffer <span class="Constant">10:literal</span> <span class="Comment"># string to maybe add to</span> trace <span class="Constant">[app]</span>, <span class="Constant">[read-instruction]</span> <span class="Comment"># start state machine by calling slurp-regular-characters, which will return</span> <span class="Comment"># by calling the complete continuation</span> - complete:continuation<span class="Special"> <- </span><span class="Identifier">current-continuation</span> + complete:continuation<span class="Special"> <- </span><span class="muControl">current-continuation</span> <span class="Comment"># If result is not empty, we've run slurp-regular-characters below, called</span> <span class="Comment"># the continuation and so bounced back here. We're done.</span> len:number<span class="Special"> <- </span>get result:address:buffer/deref, length:offset completed?:boolean<span class="Special"> <- </span>greater-than len:number, <span class="Constant">0:literal</span> - <span class="Identifier">jump-if</span> completed?:boolean,<span class="Identifier"> +completed</span>:label + <span class="muControl">jump-if</span> completed?:boolean, <span class="Constant">+completed:label</span> <span class="Comment"># Otherwise we're just getting started.</span> result:address:buffer, k:address:keyboard, x:address:screen<span class="Special"> <- </span>slurp-regular-characters result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation <span class="CommentedCode">#? $print [aaa: ], result:address:buffer #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> trace <span class="Constant">[error]</span>, <span class="Constant">[slurp-regular-characters should never return normally]</span> - <span class="Identifier"> +completed</span> +<span class="Constant"> +completed</span> result2:address:array:character<span class="Special"> <- </span>buffer-to-array result:address:buffer <span class="CommentedCode">#? $print [bbb: ], result2:address:array:character #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> trace <span class="Constant">[app]</span>, <span class="Constant">[exiting read-instruction]</span> - <span class="Identifier">reply</span> result2:address:array:character, k:address:keyboard/same-as-ingredient:0, x:address:screen/same-as-ingredient:1 + <span class="muControl">reply</span> result2:address:array:character, k:address:keyboard/same-as-ingredient:0, x:address:screen/same-as-ingredient:1 ] <span class="Comment"># read characters from the keyboard, print them to the screen in *white*.</span> <span class="Comment"># Transition to other routines for comments and strings.</span> <span class="muRecipe">recipe</span> slurp-regular-characters [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - result:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - k:address:keyboard<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - complete:continuation<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + result:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + k:address:keyboard<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + complete:continuation<span class="Special"> <- </span><span class="Constant">next-ingredient</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters]</span> characters-slurped:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="CommentedCode">#? $run-depth #? 1</span> <span class="Delimiter">{</span> - <span class="Identifier"> +next-character</span> +<span class="Constant"> +next-character</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters: next]</span> <span class="CommentedCode">#? $print [a0 #? 1</span> <span class="CommentedCode">#? ] #? 1</span> @@ -142,46 +142,46 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="CommentedCode">#? $print [aaa] #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> ctrl-d?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">4:literal/ctrl-d/eof</span> - <span class="Identifier">break-unless</span> ctrl-d?:boolean + <span class="muControl">break-unless</span> ctrl-d?:boolean <span class="CommentedCode">#? $print [ctrl-d] #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters: ctrl-d]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Delimiter">{</span> null?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">0:literal/null</span> - <span class="Identifier">break-unless</span> null?:boolean + <span class="muControl">break-unless</span> null?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters: null]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Comment"># comment?</span> <span class="Delimiter">{</span> comment?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">35:literal/hash</span> - <span class="Identifier">break-unless</span> comment?:boolean + <span class="muControl">break-unless</span> comment?:boolean print-character x:address:screen, c:character, <span class="Constant">4:literal/blue</span> result:address:buffer<span class="Special"> <- </span>buffer-append result:address:buffer, c:character result:address:buffer, k:address:keyboard, x:address:screen<span class="Special"> <- </span>slurp-comment result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation <span class="Comment"># continue appending to this instruction, whether comment ended or was backspaced out of</span> - <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> <span class="Delimiter">}</span> <span class="Comment"># string</span> <span class="Delimiter">{</span> string?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">91:literal/open-bracket</span> - <span class="Identifier">break-unless</span> string?:boolean + <span class="muControl">break-unless</span> string?:boolean print-character x:address:screen, c:character, <span class="Constant">6:literal/cyan</span> result:address:buffer<span class="Special"> <- </span>buffer-append result:address:buffer, c:character result:address:buffer, _, k:address:keyboard, x:address:screen<span class="Special"> <- </span>slurp-string result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation - <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> <span class="Delimiter">}</span> <span class="Comment"># assignment</span> <span class="Delimiter">{</span> assign?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">60:literal/less-than</span> - <span class="Identifier">break-unless</span> assign?:boolean + <span class="muControl">break-unless</span> assign?:boolean print-character x:address:screen, c:character, <span class="Constant">1:literal/red</span> trace <span class="Constant">[app]</span>, <span class="Constant">[start of assignment: <]</span> result:address:buffer<span class="Special"> <- </span>buffer-append result:address:buffer, c:character result:address:buffer, k:address:keyboard, x:address:screen<span class="Special"> <- </span>slurp-assignment result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation - <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> <span class="Delimiter">}</span> <span class="Comment"># print</span> print-character x:address:screen, c:character <span class="Comment"># default color</span> @@ -196,7 +196,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="CommentedCode">#? ] #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> backspace?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8:literal/backspace</span> - <span class="Identifier">break-unless</span> backspace?:boolean + <span class="muControl">break-unless</span> backspace?:boolean <span class="CommentedCode">#? $print [a3 #? 1</span> <span class="CommentedCode">#? ] #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> @@ -205,8 +205,8 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="CommentedCode">#? $print [a4 #? 1</span> <span class="CommentedCode">#? ] #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> - done?:boolean<span class="Special"> <- </span>lesser-or-equal characters-slurped:number,<span class="Identifier"> -1</span>:literal - <span class="Identifier">break-unless</span> done?:boolean + done?:boolean<span class="Special"> <- </span>lesser-or-equal characters-slurped:number, <span class="Constant">-1:literal</span> + <span class="muControl">break-unless</span> done?:boolean <span class="CommentedCode">#? $print [a5 #? 1</span> <span class="CommentedCode">#? ] #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> @@ -214,9 +214,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="CommentedCode">#? $print [a6 #? 1</span> <span class="CommentedCode">#? ] #? 1</span> <span class="CommentedCode">#? move-cursor-down-on-display #? 1</span> - <span class="Identifier">reply</span> result:address:buffer, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> result:address:buffer, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> - <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> <span class="Delimiter">}</span> <span class="CommentedCode">#? $print [a9 #? 1</span> <span class="CommentedCode">#? ] #? 1</span> @@ -225,14 +225,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } characters-slurped:number<span class="Special"> <- </span>add characters-slurped:number, <span class="Constant">1:literal</span> <span class="Comment"># done with this instruction?</span> done?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal/newline</span> - <span class="Identifier">break-if</span> done?:boolean - <span class="Identifier">loop</span> + <span class="muControl">break-if</span> done?:boolean + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># newline encountered; terminate all recursive calls</span> <span class="CommentedCode">#? xx:address:array:character <- new [completing!] #? 1</span> <span class="CommentedCode">#? print-string x:address:screen, xx:address:array:character #? 1</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters: newline encountered; unwinding stack]</span> - <span class="Identifier">continue-from</span> complete:continuation + <span class="muControl">continue-from</span> complete:continuation ] <span class="Comment"># read characters from keyboard, print them to screen in the comment color.</span> @@ -240,30 +240,30 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Simpler version of slurp-regular-characters; doesn't handle comments or</span> <span class="Comment"># strings. Tracks an extra count in case we backspace out of it</span> <span class="muRecipe">recipe</span> slurp-comment [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - result:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - k:address:keyboard<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - complete:continuation<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + result:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + k:address:keyboard<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + complete:continuation<span class="Special"> <- </span><span class="Constant">next-ingredient</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-comment]</span> <span class="Comment"># use this to track when backspace should reset color</span> characters-slurped:number<span class="Special"> <- </span>copy <span class="Constant">1:literal</span> <span class="Comment"># for the initial '#' that's already appended to result</span> <span class="Delimiter">{</span> - <span class="Identifier"> +next-character</span> +<span class="Constant"> +next-character</span> <span class="Comment"># read character</span> c:character, k:address:keyboard<span class="Special"> <- </span>wait-for-key k:address:keyboard <span class="Comment"># quit?</span> <span class="Delimiter">{</span> ctrl-d?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">4:literal/ctrl-d/eof</span> - <span class="Identifier">break-unless</span> ctrl-d?:boolean + <span class="muControl">break-unless</span> ctrl-d?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-comment: ctrl-d]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Delimiter">{</span> null?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">0:literal/null</span> - <span class="Identifier">break-unless</span> null?:boolean + <span class="muControl">break-unless</span> null?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-comment: null]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Comment"># print</span> print-character x:address:screen, c:character, <span class="Constant">4:literal/blue</span> @@ -272,25 +272,25 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># backspace? decrement</span> <span class="Delimiter">{</span> backspace?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8:literal/backspace</span> - <span class="Identifier">break-unless</span> backspace?:boolean + <span class="muControl">break-unless</span> backspace?:boolean characters-slurped:number<span class="Special"> <- </span>subtract characters-slurped:number, <span class="Constant">1:literal</span> <span class="Delimiter">{</span> reset-color?:boolean<span class="Special"> <- </span>lesser-or-equal characters-slurped:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-unless</span> reset-color?:boolean + <span class="muControl">break-unless</span> reset-color?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-comment: too many backspaces; returning]</span> - <span class="Identifier">reply</span> result:address:buffer, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> result:address:buffer, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> - <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> <span class="Delimiter">}</span> <span class="Comment"># otherwise increment</span> characters-slurped:number<span class="Special"> <- </span>add characters-slurped:number, <span class="Constant">1:literal</span> <span class="Comment"># done with this instruction?</span> done?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal/newline</span> - <span class="Identifier">break-if</span> done?:boolean - <span class="Identifier">loop</span> + <span class="muControl">break-if</span> done?:boolean + <span class="muControl">loop</span> <span class="Delimiter">}</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters: newline encountered; unwinding stack]</span> - <span class="Identifier">continue-from</span> complete:continuation + <span class="muControl">continue-from</span> complete:continuation ] <span class="Comment"># read characters from keyboard, print them to screen in the string color and</span> @@ -301,36 +301,36 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># b) handles nested strings using recursive calls to itself. Tracks an extra</span> <span class="Comment"># count in case we backspace out of it.</span> <span class="muRecipe">recipe</span> slurp-string [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - result:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - k:address:keyboard<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - complete:continuation<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - nested-string?:boolean<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + result:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + k:address:keyboard<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + complete:continuation<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + nested-string?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-string]</span> <span class="Comment"># use this to track when backspace should reset color</span> characters-slurped:number<span class="Special"> <- </span>copy <span class="Constant">1:literal</span> <span class="Comment"># for the initial '[' that's already appended to result</span> <span class="Delimiter">{</span> - <span class="Identifier"> +next-character</span> +<span class="Constant"> +next-character</span> <span class="Comment"># read character</span> c:character, k:address:keyboard<span class="Special"> <- </span>wait-for-key k:address:keyboard <span class="Comment"># quit?</span> <span class="Delimiter">{</span> ctrl-d?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">4:literal/ctrl-d/eof</span> - <span class="Identifier">break-unless</span> ctrl-d?:boolean + <span class="muControl">break-unless</span> ctrl-d?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-string: ctrl-d]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Delimiter">{</span> null?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">0:literal/null</span> - <span class="Identifier">break-unless</span> null?:boolean + <span class="muControl">break-unless</span> null?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-string: null]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Comment"># string</span> <span class="Delimiter">{</span> string?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">91:literal/open-bracket</span> - <span class="Identifier">break-unless</span> string?:boolean + <span class="muControl">break-unless</span> string?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-string: open-bracket encountered; recursing]</span> print-character x:address:screen, c:character, <span class="Constant">6:literal/cyan</span> result:address:buffer<span class="Special"> <- </span>buffer-append result:address:buffer, c:character @@ -338,7 +338,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } result:address:buffer, tmp:number, k:address:keyboard, x:address:screen<span class="Special"> <- </span>slurp-string result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation, <span class="Constant">1:literal/nested?</span> <span class="Comment"># but if we backspace over a completed nested string, handle it in the caller</span> characters-slurped:number<span class="Special"> <- </span>add characters-slurped:number, tmp:number, <span class="Constant">1:literal</span> <span class="Comment"># for the leading '['</span> - <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> <span class="Delimiter">}</span> <span class="Comment"># print</span> print-character x:address:screen, c:character, <span class="Constant">6:literal/cyan</span> @@ -347,58 +347,58 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># backspace? decrement</span> <span class="Delimiter">{</span> backspace?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8:literal/backspace</span> - <span class="Identifier">break-unless</span> backspace?:boolean + <span class="muControl">break-unless</span> backspace?:boolean characters-slurped:number<span class="Special"> <- </span>subtract characters-slurped:number, <span class="Constant">1:literal</span> <span class="Delimiter">{</span> reset-color?:boolean<span class="Special"> <- </span>lesser-or-equal characters-slurped:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-unless</span> reset-color?:boolean + <span class="muControl">break-unless</span> reset-color?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-string: too many backspaces; returning]</span> - <span class="Identifier">reply</span> result:address:buffer/same-as-ingredient:0, <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> result:address:buffer/same-as-ingredient:0, <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> - <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">loop</span> <span class="Constant">+next-character:label</span> <span class="Delimiter">}</span> <span class="Comment"># otherwise increment</span> characters-slurped:number<span class="Special"> <- </span>add characters-slurped:number, <span class="Constant">1:literal</span> <span class="Comment"># done with this instruction?</span> done?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">93:literal/close-bracket</span> - <span class="Identifier">break-if</span> done?:boolean - <span class="Identifier">loop</span> + <span class="muControl">break-if</span> done?:boolean + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> nested-string?:boolean + <span class="muControl">break-unless</span> nested-string?:boolean <span class="Comment"># nested string? return like a normal recipe</span> - <span class="Identifier">reply</span> result:address:buffer, characters-slurped:number, k:address:keyboard, x:address:screen + <span class="muControl">reply</span> result:address:buffer, characters-slurped:number, k:address:keyboard, x:address:screen <span class="Delimiter">}</span> <span class="Comment"># top-level string call? recurse</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-string: close-bracket encountered; recursing to regular characters]</span> result:address:buffer, k:address:keyboard, x:address:screen<span class="Special"> <- </span>slurp-regular-characters result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation <span class="Comment"># backspaced back into this string</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-string: backspaced back into string; restarting]</span> - <span class="Identifier">jump</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">jump</span> <span class="Constant">+next-character:label</span> ] <span class="muRecipe">recipe</span> slurp-assignment [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - result:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - k:address:keyboard<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - complete:continuation<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + result:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + k:address:keyboard<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + complete:continuation<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> - <span class="Identifier"> +next-character</span> +<span class="Constant"> +next-character</span> <span class="Comment"># read character</span> c:character, k:address:keyboard<span class="Special"> <- </span>wait-for-key k:address:keyboard <span class="Comment"># quit?</span> <span class="Delimiter">{</span> ctrl-d?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">4:literal/ctrl-d/eof</span> - <span class="Identifier">break-unless</span> ctrl-d?:boolean + <span class="muControl">break-unless</span> ctrl-d?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-assignment: ctrl-d]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Delimiter">{</span> null?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">0:literal/null</span> - <span class="Identifier">break-unless</span> null?:boolean + <span class="muControl">break-unless</span> null?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-assignment: null]</span> - <span class="Identifier">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> <span class="Constant">0:literal</span>, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Comment"># print</span> print-character x:address:screen, c:character, <span class="Constant">1:literal/red</span> @@ -408,16 +408,16 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># backspace? return</span> <span class="Delimiter">{</span> backspace?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8:literal/backspace</span> - <span class="Identifier">break-unless</span> backspace?:boolean + <span class="muControl">break-unless</span> backspace?:boolean trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-assignment: backspace; returning]</span> - <span class="Identifier">reply</span> result:address:buffer/same-as-ingredient:0, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 + <span class="muControl">reply</span> result:address:buffer/same-as-ingredient:0, k:address:keyboard/same-as-ingredient:1, x:address:screen/same-as-ingredient:2 <span class="Delimiter">}</span> <span class="Delimiter">}</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-assignment: done, recursing to regular characters]</span> result:address:buffer, k:address:keyboard, x:address:screen<span class="Special"> <- </span>slurp-regular-characters result:address:buffer, k:address:keyboard, x:address:screen, complete:continuation <span class="Comment"># backspaced back into this string</span> trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-assignment: backspaced back into assignment; restarting]</span> - <span class="Identifier">jump</span><span class="Identifier"> +next-character</span>:label + <span class="muControl">jump</span> <span class="Constant">+next-character:label</span> ] <span class="muScenario">scenario</span> read-instruction-color-comment [ |