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 | |
parent | 1ae4e0d95f7e37dc7d0b146542fc39b4aed491de (diff) | |
download | mu-d44123cabaa730c778a0e2644c75dbfba6a7ab30.tar.gz |
1556
65 files changed, 1203 insertions, 642 deletions
diff --git a/html/000organization.cc.html b/html/000organization.cc.html index fe24b8aa..c64fef78 100644 --- a/html/000organization.cc.html +++ b/html/000organization.cc.html @@ -13,7 +13,7 @@ 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; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .Comment { color: #8080ff; } .Constant { color: #008080; } .PreProc { color: #c000c0; } diff --git a/html/001help.cc.html b/html/001help.cc.html index b3b91e07..bed37ea9 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .PreProc { color: #c000c0; } --> </style> diff --git a/html/002test.cc.html b/html/002test.cc.html index 22e6cad1..6b2f883a 100644 --- a/html/002test.cc.html +++ b/html/002test.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .PreProc { color: #c000c0; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/003trace.cc.html b/html/003trace.cc.html index 3aa9636d..12d04729 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/010vm.cc.html b/html/010vm.cc.html index c61f82a8..97703c55 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/011load.cc.html b/html/011load.cc.html index 0da90c1b..547e81ce 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/012transform.cc.html b/html/012transform.cc.html index 4d1e9358..425e4efe 100644 --- a/html/012transform.cc.html +++ b/html/012transform.cc.html @@ -17,7 +17,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/013literal_string.cc.html b/html/013literal_string.cc.html index 7ff3b23e..c81057d7 100644 --- a/html/013literal_string.cc.html +++ b/html/013literal_string.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/014literal_noninteger.cc.html b/html/014literal_noninteger.cc.html index 8e73bb5f..e49f12fc 100644 --- a/html/014literal_noninteger.cc.html +++ b/html/014literal_noninteger.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/020run.cc.html b/html/020run.cc.html index 8881ac37..497766fa 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -22,7 +22,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/021arithmetic.cc.html b/html/021arithmetic.cc.html index da4f4d2e..69c07668 100644 --- a/html/021arithmetic.cc.html +++ b/html/021arithmetic.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/022boolean.cc.html b/html/022boolean.cc.html index 6b10aaec..836117eb 100644 --- a/html/022boolean.cc.html +++ b/html/022boolean.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/023jump.cc.html b/html/023jump.cc.html index 824eca47..3f66359a 100644 --- a/html/023jump.cc.html +++ b/html/023jump.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/024compare.cc.html b/html/024compare.cc.html index 996aabe5..86581fda 100644 --- a/html/024compare.cc.html +++ b/html/024compare.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/025trace.cc.html b/html/025trace.cc.html index 2d28e978..5af8da24 100644 --- a/html/025trace.cc.html +++ b/html/025trace.cc.html @@ -17,7 +17,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/026assert.cc.html b/html/026assert.cc.html index 9a707b26..0f86b9bf 100644 --- a/html/026assert.cc.html +++ b/html/026assert.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Constant { color: #008080; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/027debug.cc.html b/html/027debug.cc.html index 52920149..5dbf28a9 100644 --- a/html/027debug.cc.html +++ b/html/027debug.cc.html @@ -16,7 +16,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/030container.cc.html b/html/030container.cc.html index 6c4a51c4..851c5357 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -21,7 +21,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/031address.cc.html b/html/031address.cc.html index 5eb089a2..88e8c294 100644 --- a/html/031address.cc.html +++ b/html/031address.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/032array.cc.html b/html/032array.cc.html index f585d288..f0850f2f 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/034exclusive_container.cc.html b/html/034exclusive_container.cc.html index f4bbc147..5dc88c30 100644 --- a/html/034exclusive_container.cc.html +++ b/html/034exclusive_container.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/035call.cc.html b/html/035call.cc.html index 663aa29d..c493e9dc 100644 --- a/html/035call.cc.html +++ b/html/035call.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .PreProc { color: #c000c0; } .CommentedCode { color: #6c6c6c; } --> diff --git a/html/036call_ingredient.cc.html b/html/036call_ingredient.cc.html index f791cfa3..995bbbcf 100644 --- a/html/036call_ingredient.cc.html +++ b/html/036call_ingredient.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/037call_reply.cc.html b/html/037call_reply.cc.html index 1bc51e77..711bc8c4 100644 --- a/html/037call_reply.cc.html +++ b/html/037call_reply.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/038scheduler.cc.html b/html/038scheduler.cc.html index 518440ce..6dda74ca 100644 --- a/html/038scheduler.cc.html +++ b/html/038scheduler.cc.html @@ -22,7 +22,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/039wait.cc.html b/html/039wait.cc.html index fdeafc37..92798fcd 100644 --- a/html/039wait.cc.html +++ b/html/039wait.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/040brace.cc.html b/html/040brace.cc.html index 7e7a4b5f..9b81bc98 100644 --- a/html/040brace.cc.html +++ b/html/040brace.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/041name.cc.html b/html/041name.cc.html index 0e862bbc..76fa114e 100644 --- a/html/041name.cc.html +++ b/html/041name.cc.html @@ -21,7 +21,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/042new.cc.html b/html/042new.cc.html index 06cd95a4..f1ca46a1 100644 --- a/html/042new.cc.html +++ b/html/042new.cc.html @@ -22,7 +22,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } .PreProc { color: #c000c0; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/043space.cc.html b/html/043space.cc.html index 89d68498..005e1e9e 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -21,7 +21,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/044space_surround.cc.html b/html/044space_surround.cc.html index 4c01e4fc..c82e9e2f 100644 --- a/html/044space_surround.cc.html +++ b/html/044space_surround.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/045closure_name.cc.html b/html/045closure_name.cc.html index 09f2abde..d3aa6f01 100644 --- a/html/045closure_name.cc.html +++ b/html/045closure_name.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/046tangle.cc.html b/html/046tangle.cc.html index faf34c4f..40afd84d 100644 --- a/html/046tangle.cc.html +++ b/html/046tangle.cc.html @@ -18,7 +18,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/047jump_label.cc.html b/html/047jump_label.cc.html index 8e2670f4..abff627d 100644 --- a/html/047jump_label.cc.html +++ b/html/047jump_label.cc.html @@ -21,7 +21,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/048call_variable.cc.html b/html/048call_variable.cc.html index eb9eb331..404abffc 100644 --- a/html/048call_variable.cc.html +++ b/html/048call_variable.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/049continuation.cc.html b/html/049continuation.cc.html index 8455e720..9852638d 100644 --- a/html/049continuation.cc.html +++ b/html/049continuation.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index a7b09c28..18576b21 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -22,7 +22,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/051scenario_test.mu.html b/html/051scenario_test.mu.html index 028b89ca..1b65f9a3 100644 --- a/html/051scenario_test.mu.html +++ b/html/051scenario_test.mu.html @@ -13,10 +13,10 @@ 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; } +.muScenario { color: #00af00; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } --> </style> diff --git a/html/060string.mu.html b/html/060string.mu.html index 18869d3c..43ecdd77 100644 --- a/html/060string.mu.html +++ b/html/060string.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; } -.CommentedCode { color: #6c6c6c; } +.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } --> </style> @@ -35,40 +35,40 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Some useful helpers for dealing with strings.</span> <span class="muRecipe">recipe</span> string-equal [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - a:address:array:character<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> + a:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> a-len:number<span class="Special"> <- </span>length a:address:array:character/deref - b:address:array:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + b:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> b-len:number<span class="Special"> <- </span>length b:address:array:character/deref <span class="Comment"># compare lengths</span> <span class="Delimiter">{</span> trace <span class="Constant">[string-equal]</span>, <span class="Constant">[comparing lengths]</span> length-equal?:boolean<span class="Special"> <- </span>equal a-len:number, b-len:number - <span class="Identifier">break-if</span> length-equal?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal</span> + <span class="muControl">break-if</span> length-equal?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal</span> <span class="Delimiter">}</span> <span class="Comment"># compare each corresponding character</span> trace <span class="Constant">[string-equal]</span>, <span class="Constant">[comparing characters]</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, a-len:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean a2:character<span class="Special"> <- </span>index a:address:array:character/deref, i:number b2:character<span class="Special"> <- </span>index b:address:array:character/deref, i:number <span class="Delimiter">{</span> chars-match?:boolean<span class="Special"> <- </span>equal a2:character, b2:character - <span class="Identifier">break-if</span> chars-match?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal</span> + <span class="muControl">break-if</span> chars-match?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal</span> <span class="Delimiter">}</span> i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> <span class="Constant">1:literal</span> + <span class="muControl">reply</span> <span class="Constant">1:literal</span> ] <span class="muScenario">scenario</span> string-equal-reflexive [ run [ - <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> x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> 3:boolean/<span class="Special">raw <- </span>string-equal x:address:array:character, x:address:array:character ] @@ -79,7 +79,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> string-equal-identical [ run [ - <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> x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> 3:boolean/<span class="Special">raw <- </span>string-equal x:address:array:character, y:address:array:character @@ -91,7 +91,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> string-equal-distinct-lengths [ run [ - <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> x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> 3:boolean/<span class="Special">raw <- </span>string-equal x:address:array:character, y:address:array:character @@ -109,7 +109,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> string-equal-with-empty [ run [ - <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> x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[]</span> y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abcd]</span> 3:boolean/<span class="Special">raw <- </span>string-equal x:address:array:character, y:address:array:character @@ -121,7 +121,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muScenario">scenario</span> string-equal-common-lengths-but-distinct [ run [ - <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> x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abc]</span> y:address:array:character<span class="Special"> <- </span>new <span class="Constant">[abd]</span> 3:boolean/<span class="Special">raw <- </span>string-equal x:address:array:character, y:address:array:character @@ -138,23 +138,23 @@ container buffer [ ] <span class="muRecipe">recipe</span> init-buffer [ - <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> <span class="CommentedCode">#? $print default-space:address:array:location, [</span> <span class="CommentedCode">#? ]</span> result:address:buffer<span class="Special"> <- </span>new buffer:type len:address:number<span class="Special"> <- </span>get-address result:address:buffer/deref, length:offset len:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> s:address:address:array:character<span class="Special"> <- </span>get-address result:address:buffer/deref, data:offset - capacity:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + capacity:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> s:address:address:array:character/deref<span class="Special"> <- </span>new character:type, capacity:number <span class="CommentedCode">#? $print s:address:address:array:character/deref, [</span> <span class="CommentedCode">#? ]</span> - <span class="Identifier">reply</span> result:address:buffer + <span class="muControl">reply</span> result:address:buffer ] <span class="muRecipe">recipe</span> grow-buffer [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - in:address:buffer<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> + in:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># double buffer size</span> x:address:address:array:character<span class="Special"> <- </span>get-address in:address:buffer/deref, data:offset oldlen:number<span class="Special"> <- </span>length x:address:address:array:character/deref/deref @@ -165,57 +165,57 @@ container buffer [ i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, oldlen:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean src:character<span class="Special"> <- </span>index olddata:address:array:character/deref, i:number dest:address:character<span class="Special"> <- </span>index-address x:address:address:array:character/deref/deref, i:number dest:address:character/deref<span class="Special"> <- </span>copy src:character i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> in:address:buffer + <span class="muControl">reply</span> in:address:buffer ] <span class="muRecipe">recipe</span> buffer-full? [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - in:address:buffer<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> + in:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> len:number<span class="Special"> <- </span>get in:address:buffer/deref, length:offset s:address:array:character<span class="Special"> <- </span>get in:address:buffer/deref, data:offset capacity:number<span class="Special"> <- </span>length s:address:array:character/deref result:boolean<span class="Special"> <- </span>greater-or-equal len:number, capacity:number - <span class="Identifier">reply</span> result:boolean + <span class="muControl">reply</span> result:boolean ] <span class="Comment"># in:address:buffer <- buffer-append in:address:buffer, c:character</span> <span class="muRecipe">recipe</span> buffer-append [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - in:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - c:character<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> + in:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + c:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> len:address:number<span class="Special"> <- </span>get-address in:address:buffer/deref, length:offset <span class="Delimiter">{</span> <span class="Comment"># backspace? just drop last character if it exists and return</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 empty?:boolean<span class="Special"> <- </span>lesser-or-equal len:address:number/deref, <span class="Constant">0:literal</span> - <span class="Identifier">reply-if</span> empty?:boolean, in:address:buffer/same-as-ingredient:0 + <span class="muControl">reply-if</span> empty?:boolean, in:address:buffer/same-as-ingredient:0 len:address:number/deref<span class="Special"> <- </span>subtract len:address:number/deref, <span class="Constant">1:literal</span> - <span class="Identifier">reply</span> in:address:buffer/same-as-ingredient:0 + <span class="muControl">reply</span> in:address:buffer/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># grow buffer if necessary</span> full?:boolean<span class="Special"> <- </span>buffer-full? in:address:buffer - <span class="Identifier">break-unless</span> full?:boolean + <span class="muControl">break-unless</span> full?:boolean in:address:buffer<span class="Special"> <- </span>grow-buffer in:address:buffer <span class="Delimiter">}</span> s:address:array:character<span class="Special"> <- </span>get in:address:buffer/deref, data:offset dest:address:character<span class="Special"> <- </span>index-address s:address:array:character/deref, len:address:number/deref dest:address:character/deref<span class="Special"> <- </span>copy c:character len:address:number/deref<span class="Special"> <- </span>add len:address:number/deref, <span class="Constant">1:literal</span> - <span class="Identifier">reply</span> in:address:buffer/same-as-ingredient:0 + <span class="muControl">reply</span> in:address:buffer/same-as-ingredient:0 ] <span class="muScenario">scenario</span> buffer-append-works [ run [ - <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> x:address:buffer<span class="Special"> <- </span>init-buffer <span class="Constant">3:literal</span> s1:address:array:character<span class="Special"> <- </span>get x:address:buffer/deref, data:offset x:address:buffer<span class="Special"> <- </span>buffer-append x:address:buffer, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> @@ -238,7 +238,7 @@ container buffer [ <span class="CommentedCode">#? $print 1065:number/raw, [</span> <span class="CommentedCode">#? ]</span> 2:array:character/<span class="Special">raw <- </span>copy s2:address:array:character/deref - <span class="Identifier"> +buffer-filled</span> +<span class="Constant"> +buffer-filled</span> x:address:buffer<span class="Special"> <- </span>buffer-append x:address:buffer, <span class="Constant">100:literal</span> <span class="Comment"># 'd'</span> s3:address:array:character<span class="Special"> <- </span>get x:address:buffer/deref, data:offset 10:boolean/<span class="Special">raw <- </span>equal s1:address:array:character, s3:address:array:character @@ -267,7 +267,7 @@ container buffer [ <span class="muScenario">scenario</span> buffer-append-handles-backspace [ run [ - <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> x:address:buffer<span class="Special"> <- </span>init-buffer <span class="Constant">3:literal</span> x:address:buffer<span class="Special"> <- </span>buffer-append x:address:buffer, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> x:address:buffer<span class="Special"> <- </span>buffer-append x:address:buffer, <span class="Constant">98:literal</span> <span class="Comment"># 'b'</span> @@ -284,36 +284,36 @@ container buffer [ <span class="Comment"># result:address:array:character <- integer-to-decimal-string n:number</span> <span class="muRecipe">recipe</span> integer-to-decimal-string [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - n:number<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> + n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># is it zero?</span> <span class="Delimiter">{</span> - <span class="Identifier">break-if</span> n:number + <span class="muControl">break-if</span> n:number result:address:array:character<span class="Special"> <- </span>new <span class="Constant">[0]</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character <span class="Delimiter">}</span> <span class="Comment"># save sign</span> negate-result:boolean<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> negative?:boolean<span class="Special"> <- </span>lesser-than n:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-unless</span> negative?:boolean + <span class="muControl">break-unless</span> negative?:boolean negate-result:boolean<span class="Special"> <- </span>copy <span class="Constant">1:literal</span> - n:number<span class="Special"> <- </span>multiply n:number,<span class="Identifier"> -1</span>:literal + n:number<span class="Special"> <- </span>multiply n:number, <span class="Constant">-1:literal</span> <span class="Delimiter">}</span> <span class="Comment"># add digits from right to left into intermediate buffer</span> tmp:address:buffer<span class="Special"> <- </span>init-buffer <span class="Constant">30:literal</span> digit-base:number<span class="Special"> <- </span>copy <span class="Constant">48:literal</span> <span class="Comment"># '0'</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal n:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean n:number, digit:number<span class="Special"> <- </span>divide-with-remainder n:number, <span class="Constant">10:literal</span> c:character<span class="Special"> <- </span>add digit-base:number, digit:number tmp:address:buffer<span class="Special"> <- </span>buffer-append tmp:address:buffer, c:character - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># add sign</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> negate-result:boolean + <span class="muControl">break-unless</span> negate-result:boolean tmp:address:buffer<span class="Special"> <- </span>buffer-append tmp:address:buffer, <span class="Constant">45:literal</span> <span class="Comment"># '-'</span> <span class="Delimiter">}</span> <span class="Comment"># reverse buffer into string result</span> @@ -325,7 +325,7 @@ container buffer [ <span class="Delimiter">{</span> <span class="Comment"># while i >= 0</span> done?:boolean<span class="Special"> <- </span>lesser-than i:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean <span class="Comment"># result[j] = tmp[i]</span> src:character<span class="Special"> <- </span>index buf:address:array:character/deref, i:number dest:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, j:number @@ -334,18 +334,18 @@ container buffer [ i:number<span class="Special"> <- </span>subtract i:number, <span class="Constant">1:literal</span> <span class="Comment"># --j</span> j:number<span class="Special"> <- </span>add j:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character ] <span class="muRecipe">recipe</span> buffer-to-array [ - <span class="Identifier">default-space</span>:address:array:character<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - in:address:buffer<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:array:character<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + in:address:buffer<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># propagate null buffer</span> - <span class="Identifier">break-if</span> in:address:buffer - <span class="Identifier">reply</span> <span class="Constant">0:literal</span> + <span class="muControl">break-if</span> in:address:buffer + <span class="muControl">reply</span> <span class="Constant">0:literal</span> <span class="Delimiter">}</span> len:number<span class="Special"> <- </span>get in:address:buffer/deref, length:offset <span class="CommentedCode">#? $print [size ], len:number, [ </span> @@ -357,14 +357,14 @@ container buffer [ <span class="Delimiter">{</span> <span class="CommentedCode">#? $print i:number #? 1</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, len:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean src:character<span class="Special"> <- </span>index s:address:array:character/deref, i:number dest:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, i:number dest:address:character/deref<span class="Special"> <- </span>copy src:character i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character ] <span class="muScenario">scenario</span> integer-to-decimal-digit-zero [ @@ -389,7 +389,7 @@ container buffer [ <span class="muScenario">scenario</span> integer-to-decimal-digit-negative [ run [ - 1:address:array:character/<span class="Special">raw <- </span>integer-to-decimal-string<span class="Identifier"> -1</span>:literal + 1:address:array:character/<span class="Special">raw <- </span>integer-to-decimal-string <span class="Constant">-1:literal</span> 2:array:character/<span class="Special">raw <- </span>copy 1:address:array:character/deref/<span class="Special">raw</span> ] memory-should-contain [ @@ -401,11 +401,11 @@ container buffer [ <span class="Comment"># result:address:array:character <- string-append a:address:array:character, b:address:array:character</span> <span class="muRecipe">recipe</span> string-append [ - <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> <span class="Comment"># result = new character[a.length + b.length]</span> - a:address:array:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + a:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> a-len:number<span class="Special"> <- </span>length a:address:array:character/deref - b:address:array:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + b:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> b-len:number<span class="Special"> <- </span>length b:address:array:character/deref result-len:number<span class="Special"> <- </span>add a-len:number, b-len:number result:address:array:character<span class="Special"> <- </span>new character:type, result-len:number @@ -415,7 +415,7 @@ container buffer [ <span class="Delimiter">{</span> <span class="Comment"># while i < a.length</span> a-done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, a-len:number - <span class="Identifier">break-if</span> a-done?:boolean + <span class="muControl">break-if</span> a-done?:boolean <span class="Comment"># result[result-idx] = a[i]</span> out:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, result-idx:number in:character<span class="Special"> <- </span>index a:address:array:character/deref, i:number @@ -424,14 +424,14 @@ container buffer [ i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> <span class="Comment"># ++result-idx</span> result-idx:number<span class="Special"> <- </span>add result-idx:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># copy b into result</span> i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> <span class="Comment"># while i < b.length</span> b-done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, b-len:number - <span class="Identifier">break-if</span> b-done?:boolean + <span class="muControl">break-if</span> b-done?:boolean <span class="Comment"># result[result-idx] = a[i]</span> out:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, result-idx:number in:character<span class="Special"> <- </span>index b:address:array:character/deref, i:number @@ -440,9 +440,9 @@ container buffer [ i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> <span class="Comment"># ++result-idx</span> result-idx:number<span class="Special"> <- </span>add result-idx:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character ] <span class="muScenario">scenario</span> string-append-1 [ @@ -460,25 +460,25 @@ container buffer [ <span class="Comment"># replace underscores in first with remaining args</span> <span class="Comment"># result:address:array:character <- interpolate template:address:array:character, ...</span> <span class="muRecipe">recipe</span> interpolate [ - <span class="Identifier">default-space</span>:array:address:location<span class="Special"> <- </span>new location:type, <span class="Constant">60:literal</span> - template:address:array:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:array:address:location<span class="Special"> <- </span>new location:type, <span class="Constant">60:literal</span> + template:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># compute result-len, space to allocate for result</span> tem-len:number<span class="Special"> <- </span>length template:address:array:character/deref result-len:number<span class="Special"> <- </span>copy tem-len:number <span class="Delimiter">{</span> <span class="Comment"># while arg received</span> - a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - <span class="Identifier">break-unless</span> arg-received?:boolean + a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="muControl">break-unless</span> arg-received?:boolean <span class="Comment"># result-len = result-len + arg.length - 1 for the 'underscore' being replaced</span> a-len:number<span class="Special"> <- </span>length a:address:array:character/deref result-len:number<span class="Special"> <- </span>add result-len:number, a-len:number result-len:number<span class="Special"> <- </span>subtract result-len:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="CommentedCode">#? $print tem-len:number, [ ], $result-len:number, [ </span> <span class="CommentedCode">#? ] #? 1</span> rewind-ingredients - _<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> <span class="Comment"># skip template</span> + _<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># skip template</span> <span class="Comment"># result = new array:character[result-len]</span> result:address:array:character<span class="Special"> <- </span>new character:type, result-len:number <span class="Comment"># repeatedly copy sections of template and 'holes' into result</span> @@ -486,17 +486,17 @@ container buffer [ i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> <span class="Comment"># while arg received</span> - a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - <span class="Identifier">break-unless</span> arg-received?:boolean + a:address:array:character, arg-received?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="muControl">break-unless</span> arg-received?:boolean <span class="Comment"># copy template into result until '_'</span> <span class="Delimiter">{</span> <span class="Comment"># while i < template.length</span> tem-done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, tem-len:number - <span class="Identifier">break-if</span> tem-done?:boolean,<span class="Identifier"> +done</span>:label + <span class="muControl">break-if</span> tem-done?:boolean, <span class="Constant">+done:label</span> <span class="Comment"># while template[i] != '_'</span> in:character<span class="Special"> <- </span>index template:address:array:character/deref, i:number underscore?:boolean<span class="Special"> <- </span>equal in:character, <span class="Constant">95:literal</span> <span class="Comment"># '_'</span> - <span class="Identifier">break-if</span> underscore?:boolean + <span class="muControl">break-if</span> underscore?:boolean <span class="Comment"># result[result-idx] = template[i]</span> out:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, result-idx:number out:address:character/deref<span class="Special"> <- </span>copy in:character @@ -504,14 +504,14 @@ container buffer [ i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> <span class="Comment"># ++result-idx</span> result-idx:number<span class="Special"> <- </span>add result-idx:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># copy 'a' into result</span> j:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> <span class="Comment"># while j < a.length</span> arg-done?:boolean<span class="Special"> <- </span>greater-or-equal j:number, a-len:number - <span class="Identifier">break-if</span> arg-done?:boolean + <span class="muControl">break-if</span> arg-done?:boolean <span class="Comment"># result[result-idx] = a[j]</span> in:character<span class="Special"> <- </span>index a:address:array:character/deref, j:number out:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, result-idx:number @@ -520,18 +520,18 @@ container buffer [ j:number<span class="Special"> <- </span>add j:number, <span class="Constant">1:literal</span> <span class="Comment"># ++result-idx</span> result-idx:number<span class="Special"> <- </span>add result-idx:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># skip '_' in template</span> i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> <span class="Comment"># interpolate next arg</span> + <span class="muControl">loop</span> <span class="Comment"># interpolate next arg</span> <span class="Delimiter">}</span> - <span class="Identifier"> +done</span> +<span class="Constant"> +done</span> <span class="Comment"># done with holes; copy rest of template directly into result</span> <span class="Delimiter">{</span> <span class="Comment"># while i < template.length</span> tem-done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, tem-len:number - <span class="Identifier">break-if</span> tem-done?:boolean + <span class="muControl">break-if</span> tem-done?:boolean <span class="Comment"># result[result-idx] = template[i]</span> in:character<span class="Special"> <- </span>index template:address:array:character/deref, i:number out:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, result-idx:number @@ -540,9 +540,9 @@ container buffer [ i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> <span class="Comment"># ++result-idx</span> result-idx:number<span class="Special"> <- </span>add result-idx:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character ] <span class="muScenario">scenario</span> interpolate-works [ @@ -585,88 +585,88 @@ container buffer [ <span class="Comment"># result:boolean <- space? c:character</span> <span class="muRecipe">recipe</span> space? [ - <span class="Identifier">default-space</span>:array:address:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - c:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:array:address:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + c:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># most common case first</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">32:literal/space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal/newline</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">9:literal/tab</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">13:literal/carriage-return</span> <span class="Comment"># remaining uncommon cases in sorted order</span> <span class="Comment"># <a href="http://unicode.org">http://unicode.org</a> code-points in unicode-set Z and Pattern_White_Space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">11:literal/ctrl-k</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">12:literal/ctrl-l</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">133:literal/ctrl-0085</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">160:literal/no-break-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">5760:literal/ogham-space-mark</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8192:literal/en-quad</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8193:literal/em-quad</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8194:literal/en-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8195:literal/em-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8196:literal/three-per-em-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8197:literal/four-per-em-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8198:literal/six-per-em-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8199:literal/figure-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8200:literal/punctuation-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8201:literal/thin-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8202:literal/hair-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8206:literal/left-to-right</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8207:literal/right-to-left</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8232:literal/line-separator</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8233:literal/paragraph-separator</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8239:literal/narrow-no-break-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8287:literal/medium-mathematical-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> result:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">12288:literal/ideographic-space</span> - <span class="Identifier">jump-if</span> result:boolean,<span class="Identifier"> +reply</span>:label - <span class="Identifier"> +reply</span> - <span class="Identifier">reply</span> result:boolean + <span class="muControl">jump-if</span> result:boolean, <span class="Constant">+reply:label</span> +<span class="Constant"> +reply</span> + <span class="muControl">reply</span> result:boolean ] <span class="Comment"># result:address:array:character <- trim s:address:array:character</span> <span class="muRecipe">recipe</span> trim [ - <span class="Identifier">default-space</span>:array:address:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - s:address:array:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:array:address:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + s:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> len:number<span class="Special"> <- </span>length s:address:array:character/deref <span class="Comment"># left trim: compute start</span> start:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> <span class="Delimiter">{</span> at-end?:boolean<span class="Special"> <- </span>greater-or-equal start:number, len:number - <span class="Identifier">break-unless</span> at-end?:boolean + <span class="muControl">break-unless</span> at-end?:boolean result:address:array:character<span class="Special"> <- </span>new character:type, <span class="Constant">0:literal</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character <span class="Delimiter">}</span> curr:character<span class="Special"> <- </span>index s:address:array:character/deref, start:number whitespace?:boolean<span class="Special"> <- </span>space? curr:character - <span class="Identifier">break-unless</span> whitespace?:boolean + <span class="muControl">break-unless</span> whitespace?:boolean start:number<span class="Special"> <- </span>add start:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># right trim: compute end</span> end:number<span class="Special"> <- </span>subtract len:number, <span class="Constant">1:literal</span> @@ -675,12 +675,12 @@ container buffer [ assert not-at-start?:boolean <span class="Constant">[end ran up against start]</span> curr:character<span class="Special"> <- </span>index s:address:array:character/deref, end:number whitespace?:boolean<span class="Special"> <- </span>space? curr:character - <span class="Identifier">break-unless</span> whitespace?:boolean + <span class="muControl">break-unless</span> whitespace?:boolean end:number<span class="Special"> <- </span>subtract end:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># result = new character[end+1 - start]</span> - new-len:number<span class="Special"> <- </span>subtract end:number, start:number,<span class="Identifier"> -1</span>:literal + new-len:number<span class="Special"> <- </span>subtract end:number, start:number, <span class="Constant">-1:literal</span> result:address:array:character<span class="Special"> <- </span>new character:type, new-len:number <span class="Comment"># i = start, j = 0</span> i:number<span class="Special"> <- </span>copy start:number @@ -688,7 +688,7 @@ container buffer [ <span class="Delimiter">{</span> <span class="Comment"># while i <= end</span> done?:boolean<span class="Special"> <- </span>greater-than i:number, end:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean <span class="Comment"># result[j] = s[i]</span> src:character<span class="Special"> <- </span>index s:address:array:character/deref, i:number dest:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, j:number @@ -696,9 +696,9 @@ container buffer [ <span class="Comment"># ++i, ++j</span> i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> j:number<span class="Special"> <- </span>add j:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character ] <span class="muScenario">scenario</span> trim-unmodified [ diff --git a/html/061channel.mu.html b/html/061channel.mu.html index e9d5a8f9..4122d241 100644 --- a/html/061channel.mu.html +++ b/html/061channel.mu.html @@ -13,15 +13,15 @@ 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; } -.CommentedCode { color: #6c6c6c; } +.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } --> </style> @@ -68,7 +68,7 @@ container channel [ <span class="Comment"># result:address:channel <- init-channel capacity:number</span> <span class="muRecipe">recipe</span> init-channel [ - <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> <span class="Comment"># result = new channel</span> result:address:channel<span class="Special"> <- </span>new channel:type <span class="Comment"># result.first-full = 0</span> @@ -78,22 +78,22 @@ container channel [ free:address:number<span class="Special"> <- </span>get-address result:address:channel/deref, first-free:offset free:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Comment"># result.data = new location[ingredient+1]</span> - capacity:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + capacity:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> capacity:number<span class="Special"> <- </span>add capacity:number, <span class="Constant">1:literal</span> <span class="Comment"># unused slot for 'full?' below</span> dest:address:address:array:location<span class="Special"> <- </span>get-address result:address:channel/deref, data:offset dest:address:address:array:location/deref<span class="Special"> <- </span>new location:type, capacity:number - <span class="Identifier">reply</span> result:address:channel + <span class="muControl">reply</span> result:address:channel ] <span class="Comment"># chan:address:channel <- write chan:address:channel, val:location</span> <span class="muRecipe">recipe</span> write [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - val:location<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> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + val:location<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># block if chan is full</span> full:boolean<span class="Special"> <- </span>channel-full? chan:address:channel - <span class="Identifier">break-unless</span> full:boolean + <span class="muControl">break-unless</span> full:boolean full-address:address:number<span class="Special"> <- </span>get-address chan:address:channel/deref, first-full:offset wait-for-location full-address:address:number/deref <span class="Delimiter">}</span> @@ -108,20 +108,20 @@ container channel [ <span class="Comment"># wrap free around to 0 if necessary</span> len:number<span class="Special"> <- </span>length circular-buffer:address:array:location/deref at-end?:boolean<span class="Special"> <- </span>greater-or-equal free:address:number/deref, len:number - <span class="Identifier">break-unless</span> at-end?:boolean + <span class="muControl">break-unless</span> at-end?:boolean free:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> chan:address:channel/same-as-ingredient:0 + <span class="muControl">reply</span> chan:address:channel/same-as-ingredient:0 ] <span class="Comment"># result:location, chan:address:channel <- read chan:address:channel</span> <span class="muRecipe">recipe</span> read [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<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> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># block if chan is empty</span> empty:boolean<span class="Special"> <- </span>channel-empty? chan:address:channel - <span class="Identifier">break-unless</span> empty:boolean + <span class="muControl">break-unless</span> empty:boolean free-address:address:number<span class="Special"> <- </span>get-address chan:address:channel/deref, first-free:offset wait-for-location free-address:address:number/deref <span class="Delimiter">}</span> @@ -135,21 +135,21 @@ container channel [ <span class="Comment"># wrap full around to 0 if necessary</span> len:number<span class="Special"> <- </span>length circular-buffer:address:array:location/deref at-end?:boolean<span class="Special"> <- </span>greater-or-equal full:address:number/deref, len:number - <span class="Identifier">break-unless</span> at-end?:boolean + <span class="muControl">break-unless</span> at-end?:boolean full:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:location, chan:address:channel/same-as-ingredient:0 + <span class="muControl">reply</span> result:location, chan:address:channel/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> clear-channel [ - <span class="Identifier">default-space</span>:address:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="Constant">default-space</span>:address:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> empty?:boolean<span class="Special"> <- </span>channel-empty? chan:address:channel - <span class="Identifier">break-if</span> empty?:boolean + <span class="muControl">break-if</span> empty?:boolean _, chan:address:channel<span class="Special"> <- </span>read chan:address:channel <span class="Delimiter">}</span> - <span class="Identifier">reply</span> chan:address:channel/same-as-ingredient:0 + <span class="muControl">reply</span> chan:address:channel/same-as-ingredient:0 ] <span class="muScenario">scenario</span> channel-initialization [ @@ -220,20 +220,20 @@ container channel [ <span class="Comment"># An empty channel has first-empty and first-full both at the same value.</span> <span class="muRecipe">recipe</span> channel-empty? [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<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> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># return chan.first-full == chan.first-free</span> full:number<span class="Special"> <- </span>get chan:address:channel/deref, first-full:offset free:number<span class="Special"> <- </span>get chan:address:channel/deref, first-free:offset result:boolean<span class="Special"> <- </span>equal full:number, free:number - <span class="Identifier">reply</span> result:boolean + <span class="muControl">reply</span> result:boolean ] <span class="Comment"># A full channel has first-empty just before first-full, wasting one slot.</span> <span class="Comment"># (Other alternatives: <a href="https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)">https://en.wikipedia.org/wiki/Circular_buffer#Full_.2F_Empty_Buffer_Distinction)</a></span> <span class="muRecipe">recipe</span> channel-full? [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<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> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># tmp = chan.first-free + 1</span> tmp:number<span class="Special"> <- </span>get chan:address:channel/deref, first-free:offset tmp:number<span class="Special"> <- </span>add tmp:number, <span class="Constant">1:literal</span> @@ -241,22 +241,22 @@ container channel [ <span class="Comment"># if tmp == chan.capacity, tmp = 0</span> len:number<span class="Special"> <- </span>channel-capacity chan:address:channel at-end?:boolean<span class="Special"> <- </span>greater-or-equal tmp:number, len:number - <span class="Identifier">break-unless</span> at-end?:boolean + <span class="muControl">break-unless</span> at-end?:boolean tmp:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">}</span> <span class="Comment"># return chan.first-full == tmp</span> full:number<span class="Special"> <- </span>get chan:address:channel/deref, first-full:offset result:boolean<span class="Special"> <- </span>equal full:number, tmp:number - <span class="Identifier">reply</span> result:boolean + <span class="muControl">reply</span> result:boolean ] <span class="Comment"># result:number <- channel-capacity chan:address:channel</span> <span class="muRecipe">recipe</span> channel-capacity [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<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> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> q:address:array:location<span class="Special"> <- </span>get chan:address:channel/deref, data:offset result:number<span class="Special"> <- </span>length q:address:array:location/deref - <span class="Identifier">reply</span> result:number + <span class="muControl">reply</span> result:number ] <span class="muScenario">scenario</span> channel-new-empty-not-full [ @@ -314,23 +314,23 @@ container channel [ <span class="Comment"># helper for channels of characters in particular</span> <span class="Comment"># out:address:channel <- buffer-lines in:address:channel, out:address:channel</span> <span class="muRecipe">recipe</span> buffer-lines [ - <span class="Identifier">default-space</span>:address:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + <span class="Constant">default-space</span>:address:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> <span class="CommentedCode">#? $print [buffer-lines: aaa</span> <span class="CommentedCode">#? ]</span> - in:address:channel<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - out:address:channel<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + in:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + out:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># repeat forever</span> <span class="Delimiter">{</span> line:address:buffer<span class="Special"> <- </span>init-buffer, <span class="Constant">30:literal</span> <span class="Comment"># read characters from 'in' until newline, copy into line</span> <span class="Delimiter">{</span> - <span class="Identifier"> +next-character</span> +<span class="Constant"> +next-character</span> c:character, in:address:channel<span class="Special"> <- </span>read in:address:channel <span class="Comment"># drop a character on backspace</span> <span class="Delimiter">{</span> <span class="Comment"># special-case: if it's a backspace</span> backspace?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8:literal</span> - <span class="Identifier">break-unless</span> backspace?:boolean + <span class="muControl">break-unless</span> backspace?:boolean <span class="Comment"># drop previous character</span> <span class="CommentedCode">#? return-to-console #? 2</span> <span class="CommentedCode">#? $print [backspace! #? 1</span> @@ -338,7 +338,7 @@ container channel [ <span class="Delimiter">{</span> buffer-length:address:number<span class="Special"> <- </span>get-address line:address:buffer/deref, length:offset buffer-empty?:boolean<span class="Special"> <- </span>equal buffer-length:address:number/deref, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> buffer-empty?:boolean + <span class="muControl">break-if</span> buffer-empty?:boolean <span class="CommentedCode">#? $print [before: ], buffer-length:address:number/deref, [ </span> <span class="CommentedCode">#? ] #? 1</span> buffer-length:address:number/deref<span class="Special"> <- </span>subtract buffer-length:address:number/deref, <span class="Constant">1:literal</span> @@ -347,18 +347,18 @@ container channel [ <span class="Delimiter">}</span> <span class="CommentedCode">#? $exit #? 2</span> <span class="Comment"># and don't append this one</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"># append anything else</span> <span class="CommentedCode">#? $print [buffer-lines: appending ], c:character, [ </span> <span class="CommentedCode">#? ]</span> line:address:buffer<span class="Special"> <- </span>buffer-append line:address:buffer, c:character line-done?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal/newline</span> - <span class="Identifier">break-if</span> line-done?:boolean + <span class="muControl">break-if</span> line-done?:boolean <span class="Comment"># stop buffering on eof (currently only generated by fake keyboard)</span> empty-fake-keyboard?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">0:literal/eof</span> - <span class="Identifier">break-if</span> empty-fake-keyboard?:boolean - <span class="Identifier">loop</span> + <span class="muControl">break-if</span> empty-fake-keyboard?:boolean + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="CommentedCode">#? return-to-console #? 1</span> <span class="Comment"># copy line into 'out'</span> @@ -369,19 +369,19 @@ container channel [ max:number<span class="Special"> <- </span>get line:address:buffer/deref, length:offset <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, max:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean c:character<span class="Special"> <- </span>index line-contents:address:array:character/deref, i:number out:address:channel<span class="Special"> <- </span>write out:address:channel, c:character <span class="CommentedCode">#? $print [writing ], i:number, [: ], c:character, [ </span> <span class="CommentedCode">#? ] #? 1</span> i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="CommentedCode">#? $dump-trace #? 1</span> <span class="CommentedCode">#? $exit #? 1</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> out:address:channel/same-as-ingredient:1 + <span class="muControl">reply</span> out:address:channel/same-as-ingredient:1 ] <span class="muScenario">scenario</span> buffer-lines-blocks-until-newline [ @@ -403,14 +403,14 @@ F buffer-lines-blocks-until-newline: channel should be empty <span class="muReci wait-for-routine 4:number/buffer-routine 6:boolean<span class="Special"> <- </span>channel-empty? 2:address:channel/buffered-stdin assert 6:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing<span class="Identifier"> 'a</span>'] +F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing 'a'] <span class="Comment"># write 'b'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">98:literal/b</span> restart 4:number/buffer-routine wait-for-routine 4:number/buffer-routine 7:boolean<span class="Special"> <- </span>channel-empty? 2:address:channel/buffered-stdin assert 7:boolean, [ -F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing<span class="Identifier"> 'b</span>'] +F buffer-lines-blocks-until-newline: channel should be empty <span class="muRecipe">after</span> writing 'b'] <span class="Comment"># write newline</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">10:literal/newline</span> restart 4:number/buffer-routine diff --git a/html/062array.mu.html b/html/062array.mu.html index 435d8fbd..e7b4cb3a 100644 --- a/html/062array.mu.html +++ b/html/062array.mu.html @@ -13,13 +13,13 @@ 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; } +.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } --> </style> @@ -46,14 +46,14 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># create an array out of a list of scalar args</span> <span class="muRecipe">recipe</span> init-array [ - <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> capacity:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> <span class="Comment"># while read curr-value</span> - curr-value:location, exists?:boolean<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - <span class="Identifier">break-unless</span> exists?:boolean + curr-value:location, exists?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="muControl">break-unless</span> exists?:boolean capacity:number<span class="Special"> <- </span>add capacity:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> result:address:array:location<span class="Special"> <- </span>new location:type, capacity:number rewind-ingredients @@ -61,15 +61,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Delimiter">{</span> <span class="Comment"># while read curr-value</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, capacity:number - <span class="Identifier">break-if</span> done?:boolean - curr-value:location, exists?:boolean<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + <span class="muControl">break-if</span> done?:boolean + curr-value:location, exists?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> assert exists?:boolean, <span class="Constant">[error in rewinding ingredients to init-array]</span> tmp:address:location<span class="Special"> <- </span>index-address result:address:array:location/deref, i:number tmp:address:location/deref<span class="Special"> <- </span>copy curr-value:location i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:address:array:location + <span class="muControl">reply</span> result:address:array:location ] </pre> </body> diff --git a/html/063list.mu.html b/html/063list.mu.html index 62b4dfcb..cd1a7b40 100644 --- a/html/063list.mu.html +++ b/html/063list.mu.html @@ -13,13 +13,13 @@ 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; } -.CommentedCode { color: #6c6c6c; } +.muScenario { color: #00af00; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } --> </style> @@ -43,31 +43,31 @@ container list [ <span class="Comment"># result:address:list <- push x:location, in:address:list</span> <span class="muRecipe">recipe</span> push [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - x:location<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - in:address:list<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> + x:location<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + in:address:list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> result:address:list<span class="Special"> <- </span>new list:type val:address:location<span class="Special"> <- </span>get-address result:address:list/deref, value:offset val:address:location/deref<span class="Special"> <- </span>copy x:location next:address:address:list<span class="Special"> <- </span>get-address result:address:list/deref, next:offset next:address:address:list/deref<span class="Special"> <- </span>copy in:address:list - <span class="Identifier">reply</span> result:address:list + <span class="muControl">reply</span> result:address:list ] <span class="Comment"># result:location <- first in:address:list</span> <span class="muRecipe">recipe</span> first [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - in:address:list<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> + in:address:list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> result:location<span class="Special"> <- </span>get in:address:list/deref, value:offset - <span class="Identifier">reply</span> result:location + <span class="muControl">reply</span> result:location ] <span class="Comment"># result:address:list <- rest in:address:list</span> <span class="muRecipe">recipe</span> rest [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - in:address:list<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> + in:address:list<span class="Special"> <- </span><span class="Constant">next-ingredient</span> result:address:list<span class="Special"> <- </span>get in:address:list/deref, next:offset - <span class="Identifier">reply</span> result:address:list + <span class="muControl">reply</span> result:address:list ] <span class="muScenario">scenario</span> list-handling [ diff --git a/html/064random.cc.html b/html/064random.cc.html index 8ef6c773..27c847a2 100644 --- a/html/064random.cc.html +++ b/html/064random.cc.html @@ -19,7 +19,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/070display.cc.html b/html/070display.cc.html index 6ab69439..9b31520f 100644 --- a/html/070display.cc.html +++ b/html/070display.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/071print.mu.html b/html/071print.mu.html index d4af4de3..56ea1f74 100644 --- a/html/071print.mu.html +++ b/html/071print.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> @@ -49,12 +49,12 @@ container screen-cell [ ] <span class="muRecipe">recipe</span> init-fake-screen [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal/capacity</span> + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal/capacity</span> result:address:screen<span class="Special"> <- </span>new screen:type width:address:number<span class="Special"> <- </span>get-address result:address:screen/deref, num-columns:offset - width:address:number/deref<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + width:address:number/deref<span class="Special"> <- </span><span class="Constant">next-ingredient</span> height:address:number<span class="Special"> <- </span>get-address result:address:screen/deref, num-rows:offset - height:address:number/deref<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + height:address:number/deref<span class="Special"> <- </span><span class="Constant">next-ingredient</span> row:address:number<span class="Special"> <- </span>get-address result:address:screen/deref, cursor-row:offset row:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> column:address:number<span class="Special"> <- </span>get-address result:address:screen/deref, cursor-column:offset @@ -63,58 +63,58 @@ container screen-cell [ buf:address:address:array:screen-cell<span class="Special"> <- </span>get-address result:address:screen/deref, data:offset buf:address:address:array:screen-cell/deref<span class="Special"> <- </span>new screen-cell:type, bufsize:number clear-screen result:address:screen - <span class="Identifier">reply</span> result:address:screen + <span class="muControl">reply</span> result:address:screen ] <span class="muRecipe">recipe</span> clear-screen [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="CommentedCode">#? $print [clearing screen</span> <span class="CommentedCode">#? ] #? 1</span> <span class="Comment"># if x exists</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen <span class="Comment"># clear fake screen</span> buf:address:array:screen-cell<span class="Special"> <- </span>get x:address:screen/deref, data:offset max:number<span class="Special"> <- </span>length buf:address:array:screen-cell/deref i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, max:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean curr:address:screen-cell<span class="Special"> <- </span>index-address buf:address:array:screen-cell/deref, i:number curr-content:address:character<span class="Special"> <- </span>get-address curr:address:screen-cell/deref, contents:offset curr-content:address:character/deref<span class="Special"> <- </span>copy <span class="Constant">[ ]</span> curr-color:address:character<span class="Special"> <- </span>get-address curr:address:screen-cell/deref, color:offset curr-color:address:character/deref<span class="Special"> <- </span>copy <span class="Constant">7:literal/white</span> i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># reset cursor</span> cur:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-row:offset cur:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> cur:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-column:offset cur:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> clear-display - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> print-character [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - c:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - color:number, color-found?: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> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + c:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> - <span class="Identifier">break-if</span> color-found?:boolean + <span class="muControl">break-if</span> color-found?:boolean color:number<span class="Special"> <- </span>copy <span class="Constant">7:literal/white</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># if x exists</span> <span class="Comment"># (handle special cases exactly like in the real screen)</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen row:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-row:offset column:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-column:offset width:number<span class="Special"> <- </span>get x:address:screen/deref, num-columns:offset @@ -125,16 +125,16 @@ container screen-cell [ newline?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal/newline</span> <span class="CommentedCode">#? $print c:character, [ ], newline?:boolean, [ </span> <span class="CommentedCode">#? ] #? 1</span> - <span class="Identifier">break-unless</span> newline?:boolean + <span class="muControl">break-unless</span> newline?:boolean <span class="Delimiter">{</span> <span class="Comment"># unless cursor is already at bottom</span> at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row:address:number/deref, max-row:number - <span class="Identifier">break-if</span> at-bottom?:boolean + <span class="muControl">break-if</span> at-bottom?:boolean <span class="Comment"># move it to the next row</span> column:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> row:address:number/deref<span class="Special"> <- </span>add row:address:number/deref, <span class="Constant">1:literal</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># save character in fake screen</span> index:number<span class="Special"> <- </span>multiply row:address:number/deref, width:number @@ -143,11 +143,11 @@ container screen-cell [ <span class="Comment"># special-case: backspace</span> <span class="Delimiter">{</span> backspace?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">8:literal</span> - <span class="Identifier">break-unless</span> backspace?:boolean + <span class="muControl">break-unless</span> backspace?:boolean <span class="Delimiter">{</span> <span class="Comment"># unless cursor is already at left margin</span> at-left?:boolean<span class="Special"> <- </span>lesser-or-equal column:address:number/deref, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> at-left?:boolean + <span class="muControl">break-if</span> at-left?:boolean <span class="Comment"># clear previous location</span> column:address:number/deref<span class="Special"> <- </span>subtract column:address:number/deref, <span class="Constant">1:literal</span> index:number<span class="Special"> <- </span>subtract index:number, <span class="Constant">1:literal</span> @@ -157,7 +157,7 @@ container screen-cell [ cursor-contents:address:character/deref<span class="Special"> <- </span>copy <span class="Constant">32:literal/space</span> cursor-color:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">7:literal/white</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="CommentedCode">#? $print [saving character ], c:character, [ to fake screen ], cursor:address/screen, [ </span> <span class="CommentedCode">#? ] #? 1</span> @@ -169,14 +169,14 @@ container screen-cell [ <span class="Comment"># increment column unless it's already all the way to the right</span> <span class="Delimiter">{</span> at-right?:boolean<span class="Special"> <- </span>equal column:address:number/deref, width:number - <span class="Identifier">break-if</span> at-right?:boolean + <span class="muControl">break-if</span> at-right?:boolean column:address:number/deref<span class="Special"> <- </span>add column:address:number/deref, <span class="Constant">1:literal</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> print-character-to-display c:character, color:number - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muScenario">scenario</span> print-character-at-top-left [ @@ -251,11 +251,11 @@ container screen-cell [ ] <span class="muRecipe">recipe</span> clear-line [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, clear line in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen n:number<span class="Special"> <- </span>get x:address:screen/deref, num-columns:offset column:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-column:offset original-column:number<span class="Special"> <- </span>copy column:address:number/deref @@ -265,50 +265,50 @@ container screen-cell [ <span class="CommentedCode">#? $print column:address:number/deref, [ </span> <span class="CommentedCode">#? ] #? 1</span> done?:boolean<span class="Special"> <- </span>greater-or-equal column:address:number/deref, n:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean print-character x:address:screen, <span class="Constant">[ ]</span> <span class="Comment"># implicitly updates 'column'</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># now back to where the cursor was</span> column:address:number/deref<span class="Special"> <- </span>copy original-column:number - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> clear-line-on-display - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> cursor-position [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, lookup cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen row:number<span class="Special"> <- </span>get x:address:screen/deref, cursor-row:offset column:number<span class="Special"> <- </span>get x:address:screen/deref, cursor-column:offset - <span class="Identifier">reply</span> row:number, column:number, x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> row:number, column:number, x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> row:number, column:number<span class="Special"> <- </span>cursor-position-on-display - <span class="Identifier">reply</span> row:number, column:number, x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> row:number, column:number, x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> move-cursor [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - new-row:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - new-column:number<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> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + new-row:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + new-column:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen row:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-row:offset row:address:number/deref<span class="Special"> <- </span>copy new-row:number column:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-column:offset column:address:number/deref<span class="Special"> <- </span>copy new-column:number - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> move-cursor-on-display new-row:number, new-column:number - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muScenario">scenario</span> clear-line-erases-printed-characters [ @@ -343,17 +343,17 @@ container screen-cell [ ] <span class="muRecipe">recipe</span> cursor-down [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen <span class="Delimiter">{</span> <span class="Comment"># if row < height</span> height:number<span class="Special"> <- </span>get x:address:screen/deref, num-rows:offset row:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-row:offset at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal row:address:number/deref, height:number - <span class="Identifier">break-if</span> at-bottom?:boolean + <span class="muControl">break-if</span> at-bottom?:boolean <span class="Comment"># row = row+1</span> <span class="CommentedCode">#? $print [AAA: ], row:address:number, [ -> ], row:address:number/deref, [ </span> <span class="CommentedCode">#? ] #? 1</span> @@ -362,159 +362,159 @@ container screen-cell [ <span class="CommentedCode">#? ] #? 1</span> <span class="CommentedCode">#? $start-tracing #? 1</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> move-cursor-down-on-display - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> cursor-up [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen <span class="Delimiter">{</span> <span class="Comment"># if row >= 0</span> row:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-row:offset at-top?:boolean<span class="Special"> <- </span>lesser-than row:address:number/deref, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> at-top?:boolean + <span class="muControl">break-if</span> at-top?:boolean <span class="Comment"># row = row-1</span> row:address:number/deref<span class="Special"> <- </span>subtract row:address:number/deref, <span class="Constant">1:literal</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> move-cursor-up-on-display - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> cursor-right [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen <span class="Delimiter">{</span> <span class="Comment"># if column < width</span> width:number<span class="Special"> <- </span>get x:address:screen/deref, num-columns:offset column:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-column:offset at-bottom?:boolean<span class="Special"> <- </span>greater-or-equal column:address:number/deref, width:number - <span class="Identifier">break-if</span> at-bottom?:boolean + <span class="muControl">break-if</span> at-bottom?:boolean <span class="Comment"># column = column+1</span> column:address:number/deref<span class="Special"> <- </span>add column:address:number/deref, <span class="Constant">1:literal</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> move-cursor-right-on-display - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> cursor-left [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen <span class="Delimiter">{</span> <span class="Comment"># if column >= 0</span> column:address:number<span class="Special"> <- </span>get-address x:address:screen/deref, cursor-column:offset at-top?:boolean<span class="Special"> <- </span>lesser-than column:address:number/deref, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> at-top?:boolean + <span class="muControl">break-if</span> at-top?:boolean <span class="Comment"># column = column-1</span> column:address:number/deref<span class="Special"> <- </span>subtract column:address:number/deref, <span class="Constant">1:literal</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> move-cursor-left-on-display - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> cursor-to-start-of-line [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> row:number, _, x:address:screen<span class="Special"> <- </span>cursor-position x:address:screen column:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> x:address:screen<span class="Special"> <- </span>move-cursor x:address:screen, row:number, column:number - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> cursor-to-next-line [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> x:address:screen<span class="Special"> <- </span>cursor-down x:address:screen x:address:screen<span class="Special"> <- </span>cursor-to-start-of-line x:address:screen - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> screen-width [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen width:number<span class="Special"> <- </span>get x:address:screen/deref, num-columns:offset - <span class="Identifier">reply</span> width:number + <span class="muControl">reply</span> width:number <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> width:number<span class="Special"> <- </span>display-width - <span class="Identifier">reply</span> width:number + <span class="muControl">reply</span> width:number ] <span class="muRecipe">recipe</span> screen-height [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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">30:literal</span> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:screen + <span class="muControl">break-unless</span> x:address:screen height:number<span class="Special"> <- </span>get x:address:screen/deref, num-rows:offset - <span class="Identifier">reply</span> height:number + <span class="muControl">reply</span> height:number <span class="Delimiter">}</span> <span class="Comment"># otherwise, real screen</span> height:number<span class="Special"> <- </span>display-height - <span class="Identifier">reply</span> height:number + <span class="muControl">reply</span> height:number ] <span class="muRecipe">recipe</span> print-string [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - s:address:array:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - color:number, color-found?: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> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + s:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> - <span class="Identifier">break-if</span> color-found?:boolean + <span class="muControl">break-if</span> color-found?:boolean color:number<span class="Special"> <- </span>copy <span class="Constant">7:literal/white</span> <span class="Delimiter">}</span> len:number<span class="Special"> <- </span>length s:address:array:character/deref i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal i:number, len:number - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean c:character<span class="Special"> <- </span>index s:address:array:character/deref, i:number print-character x:address:screen, c:character, color:number i:number<span class="Special"> <- </span>add i:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> print-integer [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - x:address:screen<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - n:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - color:number, color-found?: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> + x:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:number, color-found?:boolean<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> - <span class="Identifier">break-if</span> color-found?:boolean + <span class="muControl">break-if</span> color-found?:boolean color:number<span class="Special"> <- </span>copy <span class="Constant">7:literal/white</span> <span class="Delimiter">}</span> <span class="Comment"># todo: other bases besides decimal</span> s:address:array:character<span class="Special"> <- </span>integer-to-decimal-string n:number print-string x:address:screen, s:address:array:character, color:number - <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 + <span class="muControl">reply</span> x:address:screen/same-as-ingredient:0 ] </pre> </body> diff --git a/html/072scenario_screen.cc.html b/html/072scenario_screen.cc.html index c6de8564..87ef1158 100644 --- a/html/072scenario_screen.cc.html +++ b/html/072scenario_screen.cc.html @@ -20,7 +20,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } --> </style> diff --git a/html/073scenario_screen_test.mu.html b/html/073scenario_screen_test.mu.html index 3b15278e..cf432dc2 100644 --- a/html/073scenario_screen_test.mu.html +++ b/html/073scenario_screen_test.mu.html @@ -13,10 +13,10 @@ 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; } +.muScenario { color: #00af00; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } --> </style> diff --git a/html/074keyboard.mu.html b/html/074keyboard.mu.html index e29f2485..75e9a0e5 100644 --- a/html/074keyboard.mu.html +++ b/html/074keyboard.mu.html @@ -17,9 +17,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .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> @@ -34,72 +34,73 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># Wrappers around keyboard primitives that take a 'keyboard' object and are thus</span> <span class="Comment"># easier to test.</span> -container keyboard <span class="Constant">[ # can't think of another word like screen/display, so real and fake keyboards use the same name</span> -<span class="Constant"> index:number</span> -<span class="Constant"> data:address:array:character</span> -<span class="Constant">]</span> +<span class="Comment"># display:screen as keyboard:__? Can't think of another word.</span> +container keyboard [ + index:number + data:address:array:character +] <span class="muRecipe">recipe</span> init-fake-keyboard [ - <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> result:address:keyboard<span class="Special"> <- </span>new keyboard:type buf:address:address:array:character<span class="Special"> <- </span>get-address result:address:keyboard/deref, data:offset <span class="CommentedCode">#? $start-tracing #? 1</span> - buf:address:address:array:character/deref<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + buf:address:address:array:character/deref<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="CommentedCode">#? $stop-tracing #? 1</span> idx:address:number<span class="Special"> <- </span>get-address result:address:keyboard/deref, index:offset idx:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> - <span class="Identifier">reply</span> result:address:keyboard + <span class="muControl">reply</span> result:address:keyboard ] <span class="muRecipe">recipe</span> read-key [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - x:address:keyboard<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> + x:address:keyboard<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:keyboard + <span class="muControl">break-unless</span> x:address:keyboard idx:address:number<span class="Special"> <- </span>get-address x:address:keyboard/deref, index:offset buf:address:array:character<span class="Special"> <- </span>get x:address:keyboard/deref, data:offset max:number<span class="Special"> <- </span>length buf:address:array:character/deref <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>greater-or-equal idx:address:number/deref, max:number - <span class="Identifier">break-unless</span> done?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal/eof</span>, <span class="Constant">1:literal/found</span>, x:address:keyboard/same-as-ingredient:0 + <span class="muControl">break-unless</span> done?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal/eof</span>, <span class="Constant">1:literal/found</span>, x:address:keyboard/same-as-ingredient:0 <span class="Delimiter">}</span> c:character<span class="Special"> <- </span>index buf:address:array:character/deref, idx:address:number/deref idx:address:number/deref<span class="Special"> <- </span>add idx:address:number/deref, <span class="Constant">1:literal</span> - <span class="Identifier">reply</span> c:character, <span class="Constant">1:literal/found</span>, x:address:keyboard/same-as-ingredient:0 + <span class="muControl">reply</span> c:character, <span class="Constant">1:literal/found</span>, x:address:keyboard/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># real keyboard input is infrequent; avoid polling it too much</span> switch c:character, found?:boolean<span class="Special"> <- </span>read-key-from-keyboard - <span class="Identifier">reply</span> c:character, found?:boolean, x:address:keyboard/same-as-ingredient:0 + <span class="muControl">reply</span> c:character, found?:boolean, x:address:keyboard/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> wait-for-key [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - x:address:keyboard<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> + x:address:keyboard<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> - <span class="Identifier">break-unless</span> x:address:keyboard + <span class="muControl">break-unless</span> x:address:keyboard <span class="Comment"># on fake keyboards 'wait-for-key' behaves just like 'read-key'</span> c:character, found?:boolean, x:address:keyboard<span class="Special"> <- </span>read-key x:address:keyboard - <span class="Identifier">reply</span> c:character, x:address:keyboard/same-as-ingredient:0 + <span class="muControl">reply</span> c:character, x:address:keyboard/same-as-ingredient:0 <span class="Delimiter">}</span> c:character<span class="Special"> <- </span>wait-for-key-from-keyboard - <span class="Identifier">reply</span> c:character, x:address:keyboard/same-as-ingredient:0 + <span class="muControl">reply</span> c:character, x:address:keyboard/same-as-ingredient:0 ] <span class="muRecipe">recipe</span> send-keys-to-channel [ - <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> - chan:address:channel<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> + chan:address:channel<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> c:character, found?:boolean, keyboard:address<span class="Special"> <- </span>read-key keyboard:address - <span class="Identifier">loop-unless</span> found?:boolean + <span class="muControl">loop-unless</span> found?:boolean <span class="CommentedCode">#? print-integer screen:address, c:character #? 1</span> print-character screen:address, c:character chan:address:channel<span class="Special"> <- </span>write chan:address:channel, c:character <span class="Comment"># todo: eof</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> ] </pre> diff --git a/html/075scenario_keyboard.cc.html b/html/075scenario_keyboard.cc.html index 25c378b4..b58ca988 100644 --- a/html/075scenario_keyboard.cc.html +++ b/html/075scenario_keyboard.cc.html @@ -17,7 +17,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.Identifier { color: #804000; } .CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/076scenario_keyboard_test.mu.html b/html/076scenario_keyboard_test.mu.html index 804eecaf..9cc3b21a 100644 --- a/html/076scenario_keyboard_test.mu.html +++ b/html/076scenario_keyboard_test.mu.html @@ -13,10 +13,10 @@ 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; } +.muScenario { color: #00af00; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.muScenario { color: #00af00; } --> </style> diff --git a/html/077mouse.cc.html b/html/077mouse.cc.html new file mode 100644 index 00000000..0c3f775e --- /dev/null +++ b/html/077mouse.cc.html @@ -0,0 +1,68 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 077mouse.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +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; } +.Constant { color: #008080; } +.Comment { color: #8080ff; } +.Delimiter { color: #c000c0; } +.Identifier { color: #804000; } +.CommentedCode { color: #6c6c6c; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +READ_KEYBOARD_OR_MOUSE_EVENT<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +Recipe_number[<span class="Constant">"read-keyboard-or-mouse-event"</span>] = READ_KEYBOARD_OR_MOUSE_EVENT<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case READ_KEYBOARD_OR_MOUSE_EVENT: <span class="Delimiter">{</span> + products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span> <span class="Comment">// result and status</span> + tb_event event<span class="Delimiter">;</span> + int event_type = tb_peek_event<span class="Delimiter">(</span>&event<span class="Delimiter">,</span> <span class="Constant">5</span><span class="Comment">/*</span><span class="Comment">ms</span><span class="Comment">*/</span><span class="Delimiter">);</span> + if <span class="Delimiter">(</span>event_type == TB_EVENT_KEY<span class="Delimiter">)</span> <span class="Delimiter">{</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">keyboard event</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span> + long long key = event<span class="Delimiter">.</span>key ? event<span class="Delimiter">.</span>key : event<span class="Delimiter">.</span>ch<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>key == TB_KEY_CTRL_C<span class="Delimiter">)</span> tb_shutdown<span class="Delimiter">(),</span> exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> + if <span class="Delimiter">(</span>key == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> key = TB_KEY_BACKSPACE<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>key == TB_KEY_CARRIAGE_RETURN<span class="Delimiter">)</span> key = TB_KEY_NEWLINE<span class="Delimiter">;</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>key<span class="Delimiter">);</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>event_type == TB_EVENT_MOUSE<span class="Delimiter">)</span> <span class="Delimiter">{</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">mouse event</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span> +<span class="CommentedCode">//? tb_shutdown(); //? 1</span> +<span class="CommentedCode">//? cerr << event_type << ' ' << event.key << ' ' << event.y << ' ' << event.x << '\n'; //? 1</span> +<span class="CommentedCode">//? exit(0); //? 1</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>key<span class="Delimiter">);</span> <span class="Comment">// which button, etc.</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>y<span class="Delimiter">);</span> <span class="Comment">// row</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>x<span class="Delimiter">);</span> <span class="Comment">// column</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">false</span><span class="Delimiter">);</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/080trace_browser.cc.html b/html/080trace_browser.cc.html new file mode 100644 index 00000000..62ad443a --- /dev/null +++ b/html/080trace_browser.cc.html @@ -0,0 +1,236 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 080trace_browser.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +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; } +.cSpecial { color: #008000; } +.Constant { color: #008080; } +.Comment { color: #8080ff; } +.Delimiter { color: #c000c0; } +.Identifier { color: #804000; } +.CommentedCode { color: #6c6c6c; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +_BROWSE_TRACE<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +Recipe_number[<span class="Constant">"$browse-trace"</span>] = _BROWSE_TRACE<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case _BROWSE_TRACE: <span class="Delimiter">{</span> + start_trace_browser<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Globals")</span> +set<long long int> Visible<span class="Delimiter">;</span> +long long int Top_of_screen = <span class="Constant">0</span><span class="Delimiter">;</span> +long long int Last_printed_row = <span class="Constant">0</span><span class="Delimiter">;</span> +map<int<span class="Delimiter">,</span> long long int> Trace_index<span class="Delimiter">;</span> <span class="Comment">// screen row -> trace index</span> + +<span class="Delimiter">:(code)</span> +void start_trace_browser<span class="Delimiter">()</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!Trace_stream<span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + cerr << <span class="Constant">"computing depth to display</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> + long long int min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + cerr << <span class="Constant">"depth is "</span> << min_depth << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> + cerr << <span class="Constant">"computing lines to display</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>depth == min_depth<span class="Delimiter">)</span> + Visible<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + tb_init<span class="Delimiter">();</span> + Display_row = Display_column = <span class="Constant">0</span><span class="Delimiter">;</span> + tb_event event<span class="Delimiter">;</span> + Top_of_screen = <span class="Constant">0</span><span class="Delimiter">;</span> + refresh_screen_rows<span class="Delimiter">();</span> + while <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + render<span class="Delimiter">();</span> + do <span class="Delimiter">{</span> + tb_poll_event<span class="Delimiter">(</span>&event<span class="Delimiter">);</span> + <span class="Delimiter">}</span> while <span class="Delimiter">(</span>event<span class="Delimiter">.</span>type != TB_EVENT_KEY<span class="Delimiter">);</span> + long long int key = event<span class="Delimiter">.</span>key ? event<span class="Delimiter">.</span>key : event<span class="Delimiter">.</span>ch<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'q'</span> || key == <span class="Constant">'Q'</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'j'</span> || key == TB_KEY_ARROW_DOWN<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// move cursor one line down</span> + if <span class="Delimiter">(</span>Display_row < Last_printed_row<span class="Delimiter">)</span> ++Display_row<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'k'</span> || key == TB_KEY_ARROW_UP<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// move cursor one line up</span> + if <span class="Delimiter">(</span>Display_row > <span class="Constant">0</span><span class="Delimiter">)</span> --Display_row<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'H'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// move cursor to top of screen</span> + Display_row = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'M'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// move cursor to center of screen</span> + Display_row = tb_height<span class="Delimiter">()</span>/<span class="Constant">2</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'L'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// move cursor to bottom of screen</span> + Display_row = tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'J'</span> || key == TB_KEY_PGDN<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// page-down</span> + if <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> + Top_of_screen = Trace_index[tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span>]+<span class="Constant">1</span><span class="Delimiter">;</span> + refresh_screen_rows<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'K'</span> || key == TB_KEY_PGUP<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// page-up is more convoluted</span> +<span class="CommentedCode">//? tb_shutdown(); //? 1</span> +<span class="CommentedCode">//? cerr << "page-up: Top_of_screen is currently " << Top_of_screen << '\n'; //? 1</span> + for <span class="Delimiter">(</span>int screen_row = tb_height<span class="Delimiter">();</span> screen_row > <span class="Constant">0</span> && Top_of_screen > <span class="Constant">0</span><span class="Delimiter">;</span> --screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + --Top_of_screen<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>Top_of_screen <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + while <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span> && Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Top_of_screen<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> + --Top_of_screen<span class="Delimiter">;</span> +<span class="CommentedCode">//? cerr << "now " << Top_of_screen << '\n'; //? 1</span> + <span class="Delimiter">}</span> +<span class="CommentedCode">//? exit(0); //? 1</span> + if <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span><span class="Delimiter">)</span> + refresh_screen_rows<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == <span class="Constant">'G'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// go to bottom of screen; largely like page-up, interestingly</span> + Top_of_screen = SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">)</span>-<span class="Constant">1</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>int screen_row = tb_height<span class="Delimiter">();</span> screen_row > <span class="Constant">0</span> && Top_of_screen > <span class="Constant">0</span><span class="Delimiter">;</span> --screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + --Top_of_screen<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>Top_of_screen <= <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + while <span class="Delimiter">(</span>Top_of_screen > <span class="Constant">0</span> && Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Top_of_screen<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> + --Top_of_screen<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + refresh_screen_rows<span class="Delimiter">();</span> + <span class="Comment">// move cursor to bottom</span> + Display_row = Last_printed_row<span class="Delimiter">;</span> + refresh_screen_rows<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == TB_KEY_CARRIAGE_RETURN<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// expand lines under current by one level</span> +<span class="CommentedCode">//? tb_shutdown();</span> + assert<span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Display_row<span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">());</span> + long long int start_index = Trace_index[Display_row]<span class="Delimiter">;</span> +<span class="CommentedCode">//? cerr << "start_index is " << start_index << '\n';</span> + long long int index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Comment">// simultaneously compute end_index and min_depth</span> + int min_depth = <span class="Constant">9999</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> != Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + assert<span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth > Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>start_index<span class="Delimiter">).</span>depth<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth < min_depth<span class="Delimiter">)</span> min_depth = curr_line<span class="Delimiter">.</span>depth<span class="Delimiter">;</span> + <span class="Delimiter">}</span> +<span class="CommentedCode">//? cerr << "min_depth is " << min_depth << '\n';</span> + long long int end_index = index<span class="Delimiter">;</span> +<span class="CommentedCode">//? cerr << "end_index is " << end_index << '\n';</span> + <span class="Comment">// mark as visible all intervening indices at min_depth</span> + for <span class="Delimiter">(</span>index = start_index<span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == min_depth<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << "adding " << index << '\n';</span> + Visible<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>index<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> +<span class="CommentedCode">//? exit(0);</span> + refresh_screen_rows<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>key == TB_KEY_BACKSPACE || key == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// collapse all lines under current</span> + assert<span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>Display_row<span class="Delimiter">)</span> != Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">());</span> + long long int start_index = Trace_index[Display_row]<span class="Delimiter">;</span> + long long int index = <span class="Constant">0</span><span class="Delimiter">;</span> + <span class="Comment">// end_index is the next line at a depth same as or lower than start_index</span> + int initial_depth = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>start_index<span class="Delimiter">).</span>depth<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>index<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>curr_line<span class="Delimiter">.</span>depth <= initial_depth<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + long long int end_index = index<span class="Delimiter">;</span> + <span class="Comment">// mark as visible all intervening indices at min_depth</span> + for <span class="Delimiter">(</span>index = start_index+<span class="Constant">1</span><span class="Delimiter">;</span> index < end_index<span class="Delimiter">;</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + Visible<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>index<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + refresh_screen_rows<span class="Delimiter">();</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + tb_shutdown<span class="Delimiter">();</span> +<span class="Delimiter">}</span> + +<span class="Comment">// update Trace_indices for each screen_row on the basis of Top_of_screen and Visible</span> +void refresh_screen_rows<span class="Delimiter">()</span> <span class="Delimiter">{</span> + long long int screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = <span class="Constant">0</span><span class="Delimiter">;</span> + Trace_index<span class="Delimiter">.</span>clear<span class="Delimiter">();</span> + for <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">,</span> index = Top_of_screen<span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">()</span> && index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">);</span> ++screen_row<span class="Delimiter">,</span> ++index<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// skip lines without depth for now</span> + while <span class="Delimiter">(</span>Visible<span class="Delimiter">.</span>find<span class="Delimiter">(</span>index<span class="Delimiter">)</span> == Visible<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> + ++index<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>index >= SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">))</span> <span class="Identifier">goto</span> done<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + assert<span class="Delimiter">(</span>index < SIZE<span class="Delimiter">(</span>Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">));</span> + Trace_index[screen_row] = index<span class="Delimiter">;</span> + <span class="Delimiter">}</span> +done:<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +void render<span class="Delimiter">()</span> <span class="Delimiter">{</span> + long long int screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>screen_row = <span class="Constant">0</span><span class="Delimiter">;</span> screen_row < tb_height<span class="Delimiter">();</span> ++screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Trace_index<span class="Delimiter">.</span>find<span class="Delimiter">(</span>screen_row<span class="Delimiter">)</span> == Trace_index<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + trace_line& curr_line = Trace_stream<span class="Delimiter">-></span>past_lines<span class="Delimiter">.</span>at<span class="Delimiter">(</span>Trace_index[screen_row]<span class="Delimiter">);</span> + ostringstream out<span class="Delimiter">;</span> + out << std::setw<span class="Delimiter">(</span><span class="Constant">4</span><span class="Delimiter">)</span> << curr_line<span class="Delimiter">.</span>depth << <span class="Constant">' '</span> << curr_line<span class="Delimiter">.</span>label << <span class="Constant">": "</span> << curr_line<span class="Delimiter">.</span>contents<span class="Delimiter">;</span> + render_line<span class="Delimiter">(</span>screen_row<span class="Delimiter">,</span> out<span class="Delimiter">.</span>str<span class="Delimiter">());</span> + <span class="Delimiter">}</span> + <span class="Comment">// clear rest of screen</span> + Last_printed_row = screen_row-<span class="Constant">1</span><span class="Delimiter">;</span> + for <span class="Delimiter">(;</span> screen_row < tb_height<span class="Delimiter">();</span> ++screen_row<span class="Delimiter">)</span> <span class="Delimiter">{</span> + render_line<span class="Delimiter">(</span>screen_row<span class="Delimiter">,</span> <span class="Constant">"~"</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Comment">// move cursor back to display row at the end</span> + tb_set_cursor<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> + tb_present<span class="Delimiter">();</span> +<span class="Delimiter">}</span> + +void render_line<span class="Delimiter">(</span>int screen_row<span class="Delimiter">,</span> const string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> + long long int col = <span class="Constant">0</span><span class="Delimiter">;</span> + for <span class="Delimiter">(</span>col = <span class="Constant">0</span><span class="Delimiter">;</span> col < tb_width<span class="Delimiter">()</span> && col < SIZE<span class="Delimiter">(</span>s<span class="Delimiter">);</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> + char c = s<span class="Delimiter">.</span>at<span class="Delimiter">(</span>col<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>c == <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> c = <span class="Constant">';'</span><span class="Delimiter">;</span> <span class="Comment">// replace newlines with semi-colons</span> + tb_change_cell<span class="Delimiter">(</span>col<span class="Delimiter">,</span> screen_row<span class="Delimiter">,</span> c<span class="Delimiter">,</span> TB_WHITE<span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + for <span class="Delimiter">(;</span> col < tb_width<span class="Delimiter">();</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> + tb_change_cell<span class="Delimiter">(</span>col<span class="Delimiter">,</span> screen_row<span class="Delimiter">,</span> <span class="Constant">' '</span><span class="Delimiter">,</span> TB_WHITE<span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span> + <span class="Delimiter">}</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/081run_interactive.cc.html b/html/081run_interactive.cc.html new file mode 100644 index 00000000..a271fe60 --- /dev/null +++ b/html/081run_interactive.cc.html @@ -0,0 +1,159 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - 081run_interactive.cc</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="cpp"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +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; } +.cSpecial { color: #008000; } +.Constant { color: #008080; } +.Comment { color: #8080ff; } +.Delimiter { color: #c000c0; } +.SalientComment { color: #00ffff; } +.CommentedCode { color: #6c6c6c; } +.Identifier { color: #804000; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment">//: Helper for the repl.</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +RUN_INTERACTIVE<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +Recipe_number[<span class="Constant">"run-interactive"</span>] = RUN_INTERACTIVE<span class="Delimiter">;</span> +<span class="CommentedCode">//? cerr << "run-interactive: " << RUN_INTERACTIVE << '\n'; //? 1</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case RUN_INTERACTIVE: <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)));</span> +<span class="CommentedCode">//? cerr << "AAA 0\n"; //? 1</span> + run_interactive<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> +<span class="CommentedCode">//? cerr << "ZZZ\n"; //? 1</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> <span class="Comment">// not done with caller; don't increment current_step_index()</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(code)</span> +<span class="Comment">// manual tests:</span> +<span class="Comment">// empty string (excluding whitespace and comments) does nothing</span> +<span class="Comment">// ctrl-d</span> +<span class="Comment">// just an integer (excluding whitespace and comments) prints value of that location in memory</span> +<span class="Comment">// instruction executes</span> +<span class="Comment">// backspace at start begins new attempt</span> +void run_interactive<span class="Delimiter">(</span>long long int address<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? tb_shutdown(); //? 1</span> + long long int size = Memory[address]<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>size == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + ++current_step_index<span class="Delimiter">();</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + ostringstream tmp<span class="Delimiter">;</span> + for <span class="Delimiter">(</span>long long int curr = address+<span class="Constant">1</span><span class="Delimiter">;</span> curr < address+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// todo: unicode</span> + tmp << <span class="Delimiter">(</span>char<span class="Delimiter">)(</span>int<span class="Delimiter">)</span>Memory[curr]<span class="Delimiter">;</span> + <span class="Delimiter">}</span> +<span class="CommentedCode">//? cerr << size << ' ' << Memory[address+size] << '\n'; //? 1</span> + assert<span class="Delimiter">(</span>Memory[address+size] == <span class="Constant">10</span><span class="Delimiter">);</span> <span class="Comment">// skip the newline</span> + if <span class="Delimiter">(</span>Recipe_number<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"interactive"</span><span class="Delimiter">)</span> == Recipe_number<span class="Delimiter">.</span>end<span class="Delimiter">())</span> + Recipe_number[<span class="Constant">"interactive"</span>] = Next_recipe_number++<span class="Delimiter">;</span> + string command = trim<span class="Delimiter">(</span>strip_comments<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>str<span class="Delimiter">()));</span> + if <span class="Delimiter">(</span>command<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> + ++current_step_index<span class="Delimiter">();</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>is_integer<span class="Delimiter">(</span>command<span class="Delimiter">))</span> <span class="Delimiter">{</span> + print_value_of_location_as_response<span class="Delimiter">(</span>to_integer<span class="Delimiter">(</span>command<span class="Delimiter">));</span> + ++current_step_index<span class="Delimiter">();</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> +<span class="CommentedCode">//? exit(0); //? 1</span> + if <span class="Delimiter">(</span>Name[Recipe_number[<span class="Constant">"interactive"</span>]]<span class="Delimiter">.</span>find<span class="Delimiter">(</span>command<span class="Delimiter">)</span> != Name[Recipe_number[<span class="Constant">"interactive"</span>]]<span class="Delimiter">.</span>end<span class="Delimiter">())</span> <span class="Delimiter">{</span> + print_value_of_location_as_response<span class="Delimiter">(</span>Name[Recipe_number[<span class="Constant">"interactive"</span>]][command]<span class="Delimiter">);</span> + ++current_step_index<span class="Delimiter">();</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> +<span class="CommentedCode">//? tb_shutdown(); //? 1</span> +<span class="CommentedCode">//? cerr << command; //? 1</span> +<span class="CommentedCode">//? exit(0); //? 1</span> +<span class="CommentedCode">//? cerr << "AAA 1\n"; //? 1</span> + Recipe<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>Recipe_number[<span class="Constant">"interactive"</span>]<span class="Delimiter">);</span> + <span class="Comment">// call run(string) but without the scheduling</span> +<span class="CommentedCode">//? cerr << ("recipe interactive [\n"+command+"\n]\n"); //? 1</span> + load<span class="Delimiter">(</span><span class="Constant">"recipe interactive [</span><span class="cSpecial">\n</span><span class="Constant">"</span>+command+<span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">]</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">);</span> + transform_all<span class="Delimiter">();</span> +<span class="CommentedCode">//? cerr << "names: " << Name[Recipe_number["interactive"]].size() << "; "; //? 1</span> +<span class="CommentedCode">//? cerr << "steps: " << Recipe[Recipe_number["interactive"]].steps.size() << "; "; //? 1</span> +<span class="CommentedCode">//? cerr << "interactive transformed_until: " << Recipe[Recipe_number["interactive"]].transformed_until << '\n'; //? 1</span> + Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>push_front<span class="Delimiter">(</span>call<span class="Delimiter">(</span>Recipe_number[<span class="Constant">"interactive"</span>]<span class="Delimiter">));</span> +<span class="Delimiter">}</span> + +string strip_comments<span class="Delimiter">(</span>string in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + ostringstream result<span class="Delimiter">;</span> +<span class="CommentedCode">//? cerr << in; //? 1</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>in<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + result << in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + else <span class="Delimiter">{</span> + while <span class="Delimiter">(</span>i < SIZE<span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> != <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> + ++i<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>i < SIZE<span class="Delimiter">(</span>in<span class="Delimiter">)</span> && in<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> == <span class="cSpecial">'\n'</span><span class="Delimiter">)</span> ++i<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> +<span class="CommentedCode">//? cerr << "ZZZ"; //? 1</span> + <span class="Identifier">return</span> result<span class="Delimiter">.</span>str<span class="Delimiter">();</span> +<span class="Delimiter">}</span> + +void print_value_of_location_as_response<span class="Delimiter">(</span>long long int address<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// convert to string</span> + ostringstream out<span class="Delimiter">;</span> + out << <span class="Constant">"=> "</span> << Memory[address]<span class="Delimiter">;</span> + string result = out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> + <span class="Comment">// handle regular I/O</span> + if <span class="Delimiter">(</span>!tb_is_active<span class="Delimiter">())</span> <span class="Delimiter">{</span> + cerr << result << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Comment">// raw I/O; use termbox to print</span> + long long int bound = SIZE<span class="Delimiter">(</span>result<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>bound > tb_width<span class="Delimiter">())</span> bound = tb_width<span class="Delimiter">();</span> + for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < bound<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> + tb_change_cell<span class="Delimiter">(</span>i<span class="Delimiter">,</span> Display_row<span class="Delimiter">,</span> result<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Comment">/*</span><span class="Comment">computer's color</span><span class="Comment">*/</span><span class="Constant">245</span><span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Comment">// newline</span> + if <span class="Delimiter">(</span>Display_row < tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> + ++Display_row<span class="Delimiter">;</span> + Display_column = <span class="Constant">0</span><span class="Delimiter">;</span> + tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span> + tb_present<span class="Delimiter">();</span> +<span class="Delimiter">}</span> + +<span class="SalientComment">//:: debugging tool</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +_RUN_DEPTH<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +Recipe_number[<span class="Constant">"$run-depth"</span>] = _RUN_DEPTH<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case _RUN_DEPTH: <span class="Delimiter">{</span> + cerr << Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>size<span class="Delimiter">();</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/callcc.mu.html b/html/callcc.mu.html index b7dad852..42dda8e5 100644 --- a/html/callcc.mu.html +++ b/html/callcc.mu.html @@ -16,7 +16,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } --> </style> @@ -33,18 +33,18 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> main [ c:continuation<span class="Special"> <- </span>f - <span class="Identifier">continue-from</span> c:continuation <span class="Comment"># <-- ..when you hit this</span> + <span class="muControl">continue-from</span> c:continuation <span class="Comment"># <-- ..when you hit this</span> ] <span class="muRecipe">recipe</span> f [ c:continuation<span class="Special"> <- </span>g - <span class="Identifier">reply</span> c:continuation + <span class="muControl">reply</span> c:continuation ] <span class="muRecipe">recipe</span> g [ - c:continuation<span class="Special"> <- </span><span class="Identifier">current-continuation</span> <span class="Comment"># <-- loop back to here</span> - <span class="Identifier"> $print</span> <span class="Constant">1:literal</span> - <span class="Identifier">reply</span> c:continuation <span class="Comment"># threaded through unmodified after first iteration</span> + c:continuation<span class="Special"> <- </span><span class="muControl">current-continuation</span> <span class="Comment"># <-- loop back to here</span> + $print <span class="Constant">1:literal</span> + <span class="muControl">reply</span> c:continuation <span class="Comment"># threaded through unmodified after first iteration</span> ] </pre> </body> diff --git a/html/channel.mu.html b/html/channel.mu.html index e6f7df34..82a17f6f 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -17,7 +17,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } --> </style> @@ -34,38 +34,38 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> producer [ <span class="Comment"># produce numbers 1 to 5 on a channel</span> - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<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> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># n = 0</span> n:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>lesser-than n:number, <span class="Constant">5:literal</span> - <span class="Identifier">break-unless</span> done?:boolean + <span class="muControl">break-unless</span> done?:boolean <span class="Comment"># other threads might get between these prints</span> - <span class="Identifier"> $print</span> <span class="Constant">[produce: ]</span>, n:number, <span class="Constant">[ </span> + $print <span class="Constant">[produce: ]</span>, n:number, <span class="Constant">[ </span> <span class="Constant">]</span> chan:address:channel<span class="Special"> <- </span>write chan:address:channel, n:number n:number<span class="Special"> <- </span>add n:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> ] <span class="muRecipe">recipe</span> consumer [ <span class="Comment"># consume and print integers from a channel</span> - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - chan:address:channel<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> + chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># read an integer from the channel</span> n:number, chan:address:channel<span class="Special"> <- </span>read chan:address:channel <span class="Comment"># other threads might get between these prints</span> - <span class="Identifier"> $print</span> <span class="Constant">[consume: ]</span>, n:number, <span class="Constant">[ </span> + $print <span class="Constant">[consume: ]</span>, n:number, <span class="Constant">[ </span> <span class="Constant">]</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</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> chan:address:channel<span class="Special"> <- </span>init-channel <span class="Constant">3:literal</span> <span class="Comment"># create two background 'routines' that communicate by a channel</span> routine1:number<span class="Special"> <- </span>start-running producer:<span class="muRecipe">recipe</span>, chan:address:channel diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 4ece3331..046395e3 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -13,15 +13,15 @@ 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; } -.CommentedCode { color: #6c6c6c; } +.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } --> </style> @@ -41,15 +41,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } switch-to-display <span class="Comment"># take control of screen and keyboard</span> <span class="Comment"># The chessboard recipe takes keyboard and screen objects as 'ingredients'.</span> - <span class="Comment">#</span> +<span class="Constant"> #</span> <span class="Comment"># In mu it is good form (though not required) to explicitly show the</span> <span class="Comment"># hardware you rely on.</span> - <span class="Comment">#</span> +<span class="Constant"> #</span> <span class="Comment"># The chessboard also returns the same keyboard and screen objects. In mu it</span> <span class="Comment"># is good form to not modify ingredients of a recipe unless they are also</span> <span class="Comment"># results. Here we clearly modify both keyboard and screen, so we return</span> <span class="Comment"># both.</span> - <span class="Comment">#</span> +<span class="Constant"> #</span> <span class="Comment"># Here the keyboard and screen are both 0, which usually indicates real</span> <span class="Comment"># hardware rather than a fake for testing as you'll see below.</span> <span class="Constant">0:literal/real-screen</span>, <span class="Constant">0:literal/real-keyboard</span><span class="Special"> <- </span>chessboard <span class="Constant">0:literal/real-screen</span>, <span class="Constant">0:literal/real-keyboard</span> @@ -60,7 +60,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="SalientComment">## But enough about mu. Here's what it looks like to run the chessboard program.</span> <span class="muScenario">scenario</span> print-board-and-read-move [ - <span class="Identifier"> $close-trace</span> <span class="Comment"># administrivia: most scenarios save and check traces, but this one gets too large/slow</span> + $close-trace <span class="Comment"># administrivia: most scenarios save and check traces, but this one gets too large/slow</span> <span class="Comment"># we'll make the screen really wide because the program currently prints out a long line</span> assume-screen <span class="Constant">120:literal/width</span>, <span class="Constant">20:literal/height</span> <span class="Comment"># initialize keyboard to type in a move</span> @@ -104,9 +104,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> chessboard [ <span class="CommentedCode">#? $start-tracing [schedule] #? 2</span> <span class="CommentedCode">#? $start-tracing #? 1</span> - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - screen:address<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - keyboard: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> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + keyboard:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="CommentedCode">#? $print [screen: ], screen:address, [, keyboard: ], keyboard:address, [ </span> <span class="CommentedCode">#? ] #? 1</span> board:address:array:address:array:character<span class="Special"> <- </span>initial-position @@ -145,23 +145,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } m:address:move, quit:boolean, error:boolean<span class="Special"> <- </span>read-move buffered-stdin:address:channel, screen:address <span class="CommentedCode">#? $print [eee</span> <span class="CommentedCode">#? ] #? 1</span> - <span class="Identifier">break-if</span> quit:boolean,<span class="Identifier"> +quit</span>:offset + <span class="muControl">break-if</span> quit:boolean, +quit:offset buffered-stdin:address:channel<span class="Special"> <- </span>clear-channel buffered-stdin:address:channel <span class="Comment"># cleanup after error. todo: test this?</span> - <span class="Identifier">loop-if</span> error:boolean + <span class="muControl">loop-if</span> error:boolean <span class="Delimiter">}</span> board:address:array:address:array:character<span class="Special"> <- </span>make-move board:address:array:address:array:character, m:address:move clear-screen screen:address - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier"> +quit</span> +<span class="Constant"> +quit</span> <span class="CommentedCode">#? $print [aaa] #? 1</span> ] <span class="SalientComment">## a board is an array of files, a file is an array of characters (squares)</span> <span class="muRecipe">recipe</span> init-board [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - initial-position:address:array:number<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> + initial-position:address:array:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># assert(length(initial-position) == 64)</span> len:number<span class="Special"> <- </span>length initial-position:address:array:number/deref correct-length?:boolean<span class="Special"> <- </span>equal len:number, <span class="Constant">64:literal</span> @@ -171,45 +171,45 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } col:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal col:number, <span class="Constant">8:literal</span> - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean file:address:address:array:character<span class="Special"> <- </span>index-address board:address:array:address:array:character/deref, col:number file:address:address:array:character/deref<span class="Special"> <- </span>init-file initial-position:address:array:number, col:number col:number<span class="Special"> <- </span>add col:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> board:address:array:address:array:character + <span class="muControl">reply</span> board:address:array:address:array:character ] <span class="muRecipe">recipe</span> init-file [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - position:address:array:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - index:number<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> + position:address:array:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + index:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> index:number<span class="Special"> <- </span>multiply index:number, <span class="Constant">8:literal</span> result:address:array:character<span class="Special"> <- </span>new character:type, <span class="Constant">8:literal</span> row:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal row:number, <span class="Constant">8:literal</span> - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean dest:address:character<span class="Special"> <- </span>index-address result:address:array:character/deref, row:number dest:address:character/deref<span class="Special"> <- </span>index position:address:array:number/deref, index:number row:number<span class="Special"> <- </span>add row:number, <span class="Constant">1:literal</span> index:number<span class="Special"> <- </span>add index:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> result:address:array:character + <span class="muControl">reply</span> result:address:array:character ] <span class="muRecipe">recipe</span> print-board [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - screen:address<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - board:address:array:address:array:character<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> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + board:address:array:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> row:number<span class="Special"> <- </span>copy <span class="Constant">7:literal</span> <span class="Comment"># start printing from the top of the board</span> <span class="Comment"># print each row</span> <span class="CommentedCode">#? $print [printing board to screen ], screen:address, [ </span> <span class="CommentedCode">#? ] #? 1</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>lesser-than row:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean <span class="CommentedCode">#? $print [printing rank ], row:number, [ </span> <span class="CommentedCode">#? ] #? 1</span> <span class="Comment"># print rank number as a legend</span> @@ -221,17 +221,17 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } col:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">{</span> done?:boolean<span class="Special"> <- </span>equal col:number, <span class="Constant">8:literal</span> - <span class="Identifier">break-if</span> done?:boolean + <span class="muControl">break-if</span> done?:boolean f:address:array:character<span class="Special"> <- </span>index board:address:array:address:array:character/deref, col:number c:character<span class="Special"> <- </span>index f:address:array:character/deref, row:number print-character screen:address, c:character print-character screen:address, <span class="Constant">32:literal</span> <span class="Comment"># ' '</span> col:number<span class="Special"> <- </span>add col:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> row:number<span class="Special"> <- </span>subtract row:number, <span class="Constant">1:literal</span> cursor-to-next-line screen:address - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># print file letters as legend</span> <span class="CommentedCode">#? $print [printing legend</span> @@ -249,7 +249,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># board:address:array:address:array:character <- initial-position</span> <span class="muRecipe">recipe</span> initial-position [ - <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> <span class="Comment"># layout in memory (in raster order):</span> <span class="Comment"># R P _ _ _ _ p r</span> <span class="Comment"># N P _ _ _ _ p n</span> @@ -269,7 +269,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="CommentedCode">#? 78:literal/N, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 110:literal/n,</span> <span class="CommentedCode">#? 82:literal/R, 80:literal/P, 32:literal/blank, 32:literal/blank, 32:literal/blank, 32:literal/blank, 112:literal/p, 114:literal/r</span> board:address:array:address:array:character<span class="Special"> <- </span>init-board initial-position:address:array:number - <span class="Identifier">reply</span> board:address:array:address:array:character + <span class="muControl">reply</span> board:address:array:address:array:character ] <span class="muScenario">scenario</span> printing-the-board [ @@ -309,13 +309,13 @@ container move [ <span class="Comment"># result:address:move, quit?:boolean, error?:boolean <- read-move stdin:address:channel, screen:address</span> <span class="Comment"># prints only error messages to screen</span> <span class="muRecipe">recipe</span> read-move [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - stdin:address:channel<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> + stdin:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="CommentedCode">#? $print screen:address #? 1</span> from-file:number, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-file stdin:address:channel, screen:address - <span class="Identifier">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean - <span class="Identifier">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean <span class="CommentedCode">#? return-to-console #? 1</span> <span class="Comment"># construct the move object</span> result:address:move<span class="Special"> <- </span>new move:type @@ -323,52 +323,52 @@ container move [ x:address:number/deref<span class="Special"> <- </span>copy from-file:number x:address:number<span class="Special"> <- </span>get-address result:address:move/deref, from-rank:offset x:address:number/deref, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-rank stdin:address:channel, screen:address - <span class="Identifier">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean - <span class="Identifier">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean error?:boolean<span class="Special"> <- </span>expect-from-channel stdin:address:channel, <span class="Constant">45:literal/dash</span>, screen:address - <span class="Identifier">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, error?:boolean + <span class="muControl">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, error?:boolean x:address:number<span class="Special"> <- </span>get-address result:address:move/deref, to-file:offset x:address:number/deref, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-file stdin:address:channel, screen:address - <span class="Identifier">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean - <span class="Identifier">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean x:address:number<span class="Special"> <- </span>get-address result:address:move/deref, to-rank:offset x:address:number/deref, quit?:boolean, error?:boolean<span class="Special"> <- </span>read-rank stdin:address:channel, screen:address - <span class="Identifier">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean - <span class="Identifier">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> quit?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, quit?:boolean, error?:boolean <span class="CommentedCode">#? $exit #? 1</span> error?:boolean<span class="Special"> <- </span>expect-from-channel stdin:address:channel, <span class="Constant">10:literal/newline</span>, screen:address - <span class="Identifier">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, error?:boolean - <span class="Identifier">reply</span> result:address:move, quit?:boolean, error?:boolean + <span class="muControl">reply-if</span> error?:boolean, <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, error?:boolean + <span class="muControl">reply</span> result:address:move, quit?:boolean, error?:boolean ] <span class="Comment"># file:number, quit:boolean, error:boolean <- read-file stdin:address:channel, screen:address</span> <span class="Comment"># valid values for file: 0-7</span> <span class="muRecipe">recipe</span> read-file [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - stdin:address:channel<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> + stdin:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> c:character, stdin:address:channel<span class="Special"> <- </span>read stdin:address:channel <span class="Delimiter">{</span> q-pressed?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">81:literal</span> <span class="Comment"># 'Q'</span> - <span class="Identifier">break-unless</span> q-pressed?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> + <span class="muControl">break-unless</span> q-pressed?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> q-pressed?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">113:literal</span> <span class="Comment"># 'q'</span> - <span class="Identifier">break-unless</span> q-pressed?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> + <span class="muControl">break-unless</span> q-pressed?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> empty-fake-keyboard?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">0:literal/eof</span> - <span class="Identifier">break-unless</span> empty-fake-keyboard?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> + <span class="muControl">break-unless</span> empty-fake-keyboard?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> newline?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal/newline</span> - <span class="Identifier">break-unless</span> newline?:boolean + <span class="muControl">break-unless</span> newline?:boolean error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> print-string screen:address, error-message:address:array:character - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> <span class="Delimiter">}</span> file:number<span class="Special"> <- </span>subtract c:character, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> <span class="CommentedCode">#? $print file:number, [ </span> @@ -376,47 +376,47 @@ container move [ <span class="Comment"># 'a' <= file <= 'h'</span> <span class="Delimiter">{</span> above-min:boolean<span class="Special"> <- </span>greater-or-equal file:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> above-min:boolean + <span class="muControl">break-if</span> above-min:boolean error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[file too low: ]</span> print-string screen:address, error-message:address:array:character print-character screen:address, c:character cursor-to-next-line screen:address - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> below-max:boolean<span class="Special"> <- </span>lesser-than file:number, <span class="Constant">8:literal</span> - <span class="Identifier">break-if</span> below-max:boolean + <span class="muControl">break-if</span> below-max:boolean error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[file too high: ]</span> print-string screen:address, error-message:address:array:character print-character screen:address, c:character - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> file:number, <span class="Constant">0:literal/quit</span>, <span class="Constant">0:literal/error</span> + <span class="muControl">reply</span> file:number, <span class="Constant">0:literal/quit</span>, <span class="Constant">0:literal/error</span> ] <span class="Comment"># rank:number <- read-rank stdin:address:channel, screen:address</span> <span class="Comment"># valid values: 0-7, -1 (quit), -2 (error)</span> <span class="muRecipe">recipe</span> read-rank [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - stdin:address:channel<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> + stdin:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> c:character, stdin:address:channel<span class="Special"> <- </span>read stdin:address:channel <span class="Delimiter">{</span> q-pressed?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">81:literal</span> <span class="Comment"># 'Q'</span> - <span class="Identifier">break-unless</span> q-pressed?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> + <span class="muControl">break-unless</span> q-pressed?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> q-pressed?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">113:literal</span> <span class="Comment"># 'q'</span> - <span class="Identifier">break-unless</span> q-pressed?:boolean - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> + <span class="muControl">break-unless</span> q-pressed?:boolean + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">1:literal/quit</span>, <span class="Constant">0:literal/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> newline?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal</span> <span class="Comment"># newline</span> - <span class="Identifier">break-unless</span> newline?:boolean + <span class="muControl">break-unless</span> newline?:boolean error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[that's not enough]</span> print-string screen:address, error-message:address:array:character - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> <span class="Delimiter">}</span> rank:number<span class="Special"> <- </span>subtract c:character, <span class="Constant">49:literal</span> <span class="Comment"># '1'</span> <span class="CommentedCode">#? $print rank:number, [ </span> @@ -424,39 +424,39 @@ container move [ <span class="Comment"># assert'1' <= rank <= '8'</span> <span class="Delimiter">{</span> above-min:boolean<span class="Special"> <- </span>greater-or-equal rank:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-if</span> above-min:boolean + <span class="muControl">break-if</span> above-min:boolean error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[rank too low: ]</span> print-string screen:address, error-message:address:array:character print-character screen:address, c:character - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> below-max:boolean<span class="Special"> <- </span>lesser-or-equal rank:number, <span class="Constant">7:literal</span> - <span class="Identifier">break-if</span> below-max:boolean + <span class="muControl">break-if</span> below-max:boolean error-message:address:array:character<span class="Special"> <- </span>new <span class="Constant">[rank too high: ]</span> print-string screen:address, error-message:address:array:character print-character screen:address, c:character - <span class="Identifier">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> + <span class="muControl">reply</span> <span class="Constant">0:literal/dummy</span>, <span class="Constant">0:literal/quit</span>, <span class="Constant">1:literal/error</span> <span class="Delimiter">}</span> - <span class="Identifier">reply</span> rank:number, <span class="Constant">0:literal/quit</span>, <span class="Constant">0:literal/error</span> + <span class="muControl">reply</span> rank:number, <span class="Constant">0:literal/quit</span>, <span class="Constant">0:literal/error</span> ] <span class="Comment"># read a character from the given channel and check that it's what we expect</span> <span class="Comment"># return true on error</span> <span class="muRecipe">recipe</span> expect-from-channel [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - stdin:address:channel<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - expected:character<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> + stdin:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + expected:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> c:character, stdin:address:channel<span class="Special"> <- </span>read stdin:address:channel match?:boolean<span class="Special"> <- </span>equal c:character, expected:character <span class="Delimiter">{</span> - <span class="Identifier">break-if</span> match?:boolean + <span class="muControl">break-if</span> match?:boolean s:address:array:character<span class="Special"> <- </span>new <span class="Constant">[expected character not found]</span> print-string screen:address, s:address:array:character <span class="Delimiter">}</span> result:boolean<span class="Special"> <- </span>not match?:boolean - <span class="Identifier">reply</span> result:boolean + <span class="muControl">reply</span> result:boolean ] <span class="muScenario">scenario</span> read-move-blocking [ @@ -476,7 +476,7 @@ container move [ <span class="CommentedCode">#? ] #? 1</span> 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> coming up<span class="Identifier"> (before</span> any keys were pressed)] +F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] <span class="Comment"># press 'a'</span> <span class="CommentedCode">#? $print [ccc channel address: ], 1:address:channel, [ </span> <span class="CommentedCode">#? ] #? 1</span> @@ -490,7 +490,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span <span class="CommentedCode">#? ] #? 1</span> 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank<span class="Identifier"> 'a</span>'] +F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank 'a'] <span class="Comment"># press '2'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">50:literal</span> <span class="Comment"># '2'</span> restart 2:number/routine @@ -501,7 +501,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span <span class="CommentedCode">#? ] #? 1</span> 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file<span class="Identifier"> 'a2</span>'] +F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file 'a2'] <span class="Comment"># press '-'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">45:literal</span> <span class="Comment"># '-'</span> restart 2:number/routine @@ -512,7 +512,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span <span class="CommentedCode">#? ] #? 1</span> 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?/routine-state, [ -F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> hyphen<span class="Identifier"> 'a2-</span>'] +F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> hyphen 'a2-'] <span class="Comment"># press 'a'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> restart 2:number/routine @@ -523,7 +523,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span <span class="CommentedCode">#? ] #? 1</span> 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?/routine-state, [ -F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank<span class="Identifier"> 'a2-a</span>'] +F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> rank 'a2-a'] <span class="Comment"># press '4'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">52:literal</span> <span class="Comment"># '4'</span> restart 2:number/routine @@ -534,7 +534,7 @@ F read-move-blocking: routine failed to pause <span class="muRecipe">after</span <span class="CommentedCode">#? ] #? 1</span> 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file<span class="Identifier"> 'a2-a4</span>'] +F read-move-blocking: routine failed to pause <span class="muRecipe">after</span> file 'a2-a4'] <span class="Comment"># press 'newline'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">10:literal</span> <span class="Comment"># newline</span> restart 2:number/routine @@ -563,7 +563,7 @@ F read-move-blocking: routine failed to terminate on newline] 3:number<span class="Special"> <- </span>routine-state 2:number/id 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-quit: routine failed to pause <span class="muRecipe">after</span> coming up<span class="Identifier"> (before</span> any keys were pressed)] +F read-move-quit: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] <span class="Comment"># press 'q'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">113:literal</span> <span class="Comment"># 'q'</span> restart 2:number/routine @@ -572,7 +572,7 @@ F read-move-quit: routine failed to pause <span class="muRecipe">after</span> co 3:number<span class="Special"> <- </span>routine-state 2:number/id 4:boolean/completed?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">1:literal/completed</span> assert 4:boolean/completed?, [ -F read-move-quit: routine failed to terminate on<span class="Identifier"> 'q</span>'] +F read-move-quit: routine failed to terminate on 'q'] trace <span class="Constant">[test]</span>, <span class="Constant">[reached end]</span> ] trace-should-contain [ @@ -590,7 +590,7 @@ F read-move-quit: routine failed to terminate on<span class="Identifier"> 'q</sp 3:number<span class="Special"> <- </span>routine-state 2:number/id 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up<span class="Identifier"> (before</span> any keys were pressed)] +F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">50:literal</span> <span class="Comment"># '2'</span> restart 2:number/routine wait-for-routine 2:number @@ -611,7 +611,7 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co 3:number<span class="Special"> <- </span>routine-state 2:number/id 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up<span class="Identifier"> (before</span> any keys were pressed)] +F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> restart 2:number/routine @@ -633,7 +633,7 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co 3:number<span class="Special"> <- </span>routine-state 2:number/id 4:boolean/waiting?<span class="Special"> <- </span>equal 3:number/routine-state, <span class="Constant">2:literal/waiting</span> assert 4:boolean/waiting?, [ -F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up<span class="Identifier"> (before</span> any keys were pressed)] +F read-move-file: routine failed to pause <span class="muRecipe">after</span> coming up (<span class="muRecipe">before</span> any keys were pressed)] 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">10:literal/newline</span> 1:address:channel<span class="Special"> <- </span>write 1:address:channel, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> restart 2:number/routine @@ -646,9 +646,9 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co ] <span class="muRecipe">recipe</span> make-move [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - b:address:array:address:array:character<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - m:address:move<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> + b:address:array:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + m:address:move<span class="Special"> <- </span><span class="Constant">next-ingredient</span> from-file:number<span class="Special"> <- </span>get m:address:move/deref, from-file:offset <span class="CommentedCode">#? $print from-file:number, [ </span> <span class="CommentedCode">#? ] #? 1</span> @@ -669,7 +669,7 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co <span class="CommentedCode">#? ] #? 1</span> dest:address:character/deref/square<span class="Special"> <- </span>copy src:address:character/deref/square src:address:character/deref/square<span class="Special"> <- </span>copy <span class="Constant">32:literal</span> <span class="Comment"># ' '</span> - <span class="Identifier">reply</span> b:address:array:address:array:character/same-as-ingredient:0 + <span class="muControl">reply</span> b:address:array:address:array:character/same-as-ingredient:0 ] <span class="muScenario">scenario</span> making-a-move [ diff --git a/html/counters.mu.html b/html/counters.mu.html index ee41a5f8..1846c64e 100644 --- a/html/counters.mu.html +++ b/html/counters.mu.html @@ -16,7 +16,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } --> </style> @@ -33,21 +33,21 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># (spaces)</span> <span class="muRecipe">recipe</span> init-counter [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - n:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> - <span class="Identifier">reply</span> <span class="Identifier">default-space</span>:address:array:location + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="muControl">reply</span> <span class="Constant">default-space</span>:address:array:location ] <span class="muRecipe">recipe</span> increment-counter [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - 0:address:array:location/names:init-counter<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> <span class="Comment"># setup outer space; it *must* come from 'init-counter'</span> - x:number<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> + 0:address:array:location/names:init-counter<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># setup outer space; it *must* come from 'init-counter'</span> + x:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> n:number/space:1<span class="Special"> <- </span>add n:number/space:1, x:number - <span class="Identifier">reply</span> n:number/space:1 + <span class="muControl">reply</span> n:number/space:1 ] <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> <span class="Comment"># counter A</span> a:address:array:location<span class="Special"> <- </span>init-counter <span class="Constant">34:literal</span> <span class="Comment"># counter B</span> @@ -57,10 +57,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } b-value:number<span class="Special"> <- </span>increment-counter b:address:array:location, <span class="Constant">2:literal</span> a-value:number<span class="Special"> <- </span>increment-counter a:address:array:location, <span class="Constant">1:literal</span> <span class="Comment"># check results</span> - <span class="Identifier"> $print</span> <span class="Constant">[Contents of counters</span> + $print <span class="Constant">[Contents of counters</span> <span class="Constant">]</span> <span class="Comment"># trailing space in next line is to help with syntax highlighting</span> - <span class="Identifier"> $print</span> <span class="Constant">[a: ]</span>, a-value:number, <span class="Constant">[ b: ]</span>, b-value:number, <span class="Constant">[ </span> + $print <span class="Constant">[a: ]</span>, a-value:number, <span class="Constant">[ b: ]</span>, b-value:number, <span class="Constant">[ </span> <span class="Constant">]</span> ] </pre> diff --git a/html/edit.mu.html b/html/edit.mu.html index 8251e997..16ba4cac 100644 --- a/html/edit.mu.html +++ b/html/edit.mu.html @@ -17,9 +17,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .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> @@ -32,41 +32,93 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <body> <pre id='vimCodeElement'> <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 - draw-bounding-box <span class="Constant">0:literal/screen</span>, <span class="Constant">5:literal</span>, <span class="Constant">5:literal</span>, <span class="Constant">30:literal</span>, <span class="Constant">45:literal</span> + width:number<span class="Special"> <- </span>display-width + <span class="Delimiter">{</span> + wide-enough?:boolean<span class="Special"> <- </span>greater-than width:number, <span class="Constant">100:literal</span> + <span class="muControl">break-if</span> wide-enough?:boolean + return-to-console + assert wide-enough?:boolean, <span class="Constant">[screen too narrow; we don't support less than 100 characters yet]</span> + <span class="Delimiter">}</span> + divider:number, _<span class="Special"> <- </span>divide-with-remainder width:number, <span class="Constant">2:literal</span> + draw-column <span class="Constant">0:literal/screen</span>, divider:number + x:address:array:character<span class="Special"> <- </span>new <span class="Constant">[1:integer <- add 2:literal, 2:literal]</span> + y:address:array:character<span class="Special"> <- </span>edit x:address:array:character, <span class="Constant">0:literal/screen</span>, <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span>, <span class="Constant">5:literal</span>, divider:number +<span class="CommentedCode">#? draw-bounding-box 0:literal/screen, 0:literal, 0:literal, 5:literal, divider:number</span> + left:number<span class="Special"> <- </span>add divider:number, <span class="Constant">1:literal</span> + y:address:array:character<span class="Special"> <- </span>edit <span class="Constant">0:literal</span>, <span class="Constant">0:literal/screen</span>, <span class="Constant">0:literal</span>, left:number, <span class="Constant">2:literal</span>, width:number + move-cursor <span class="Constant">0:literal/screen</span>, <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span> wait-for-key-from-keyboard return-to-console ] +<span class="muRecipe">recipe</span> draw-column [ + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + col:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + curr:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> + max:number<span class="Special"> <- </span>screen-height screen:address + <span class="Delimiter">{</span> + continue?:boolean<span class="Special"> <- </span>lesser-than curr:number, max:number + <span class="muControl">break-unless</span> continue?:boolean + move-cursor screen:address, curr:number, col:number + print-character screen:address, <span class="Constant">9474:literal/vertical</span>, <span class="Constant">245:literal/grey</span> + curr:number<span class="Special"> <- </span>add curr:number, <span class="Constant">1:literal</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + move-cursor screen:address, <span class="Constant">0:literal</span>, <span class="Constant">0:literal</span> +] + +<span class="muRecipe">recipe</span> edit [ + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + in:address:array:character<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + top:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + bottom:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Comment"># draw bottom boundary</span> + curr:number<span class="Special"> <- </span>copy left:number + <span class="Delimiter">{</span> + continue?:boolean<span class="Special"> <- </span>lesser-than curr:number, right:number + <span class="muControl">break-unless</span> continue?:boolean + move-cursor screen:address, bottom:number, curr:number + print-character screen:address, <span class="Constant">9472:literal/vertical</span>, <span class="Constant">245:literal/grey</span> + curr:number<span class="Special"> <- </span>add curr:number, <span class="Constant">1:literal</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + move-cursor screen:address, top:number, left:number +] + <span class="muRecipe">recipe</span> draw-bounding-box [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</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> + screen:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># sanity-check the box bounds</span> - top:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + top:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> out?:boolean<span class="Special"> <- </span>lesser-than top:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-unless</span> out?:boolean + <span class="muControl">break-unless</span> out?:boolean top:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">}</span> - left:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + left:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> out?:boolean<span class="Special"> <- </span>lesser-than left:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-unless</span> out?:boolean + <span class="muControl">break-unless</span> out?:boolean left:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Delimiter">}</span> - bottom:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + bottom:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> height:number<span class="Special"> <- </span>screen-height screen:address out?:boolean<span class="Special"> <- </span>greater-or-equal bottom:number, height:number - <span class="Identifier">break-unless</span> out?:boolean + <span class="muControl">break-unless</span> out?:boolean bottom:number<span class="Special"> <- </span>subtract height:number, <span class="Constant">1:literal</span> <span class="Delimiter">}</span> - right:number<span class="Special"> <- </span><span class="Identifier">next-ingredient</span> + right:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> width:number<span class="Special"> <- </span>screen-width screen:address out?:boolean<span class="Special"> <- </span>greater-or-equal right:number, width:number - <span class="Identifier">break-unless</span> out?:boolean + <span class="muControl">break-unless</span> out?:boolean right:number<span class="Special"> <- </span>subtract width:number, <span class="Constant">1:literal</span> <span class="Delimiter">}</span> <span class="CommentedCode">#? print-integer screen:address, bottom:number</span> @@ -78,10 +130,10 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } x:number<span class="Special"> <- </span>add left:number, <span class="Constant">1:literal</span> <span class="Comment"># exclude corner</span> <span class="Delimiter">{</span> continue?:boolean<span class="Special"> <- </span>lesser-than x:number, right:number - <span class="Identifier">break-unless</span> continue?:boolean + <span class="muControl">break-unless</span> continue?:boolean print-character screen:address, <span class="Constant">9472:literal/horizontal</span>, <span class="Constant">245:literal/grey</span> x:number<span class="Special"> <- </span>add x:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> print-character screen:address, <span class="Constant">9488:literal/down-left</span>, <span class="Constant">245:literal/grey</span> <span class="Comment"># bottom border</span> @@ -90,23 +142,23 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } x:number<span class="Special"> <- </span>add left:number, <span class="Constant">1:literal</span> <span class="Comment"># exclude corner</span> <span class="Delimiter">{</span> continue?:boolean<span class="Special"> <- </span>lesser-than x:number, right:number - <span class="Identifier">break-unless</span> continue?:boolean + <span class="muControl">break-unless</span> continue?:boolean print-character screen:address, <span class="Constant">9472:literal/horizontal</span>, <span class="Constant">245:literal/grey</span> x:number<span class="Special"> <- </span>add x:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> print-character screen:address, <span class="Constant">9496:literal/up-left</span>, <span class="Constant">245:literal/grey</span> <span class="Comment"># left and right borders</span> x:number<span class="Special"> <- </span>add top:number, <span class="Constant">1:literal</span> <span class="Comment"># exclude corner</span> <span class="Delimiter">{</span> continue?:boolean<span class="Special"> <- </span>lesser-than x:number, bottom:number - <span class="Identifier">break-unless</span> continue?:boolean + <span class="muControl">break-unless</span> continue?:boolean move-cursor screen:address, x:number, left:number print-character screen:address, <span class="Constant">9474:literal/vertical</span>, <span class="Constant">245:literal/grey</span> move-cursor screen:address, x:number, right:number print-character screen:address, <span class="Constant">9474:literal/vertical</span>, <span class="Constant">245:literal/grey</span> x:number<span class="Special"> <- </span>add x:number, <span class="Constant">1:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># position cursor inside box</span> move-cursor screen:address, top:number, left:number diff --git a/html/factorial.mu.html b/html/factorial.mu.html index c57d4b62..22438340 100644 --- a/html/factorial.mu.html +++ b/html/factorial.mu.html @@ -13,13 +13,13 @@ 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; } +.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } --> </style> @@ -34,26 +34,26 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># example program: compute the factorial of 5</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> x:number<span class="Special"> <- </span>factorial <span class="Constant">5:literal</span> - <span class="Identifier"> $print</span> <span class="Constant">[result: ]</span>, x:number, <span class="Constant">[ </span> + $print <span class="Constant">[result: ]</span>, x:number, <span class="Constant">[ </span> <span class="Constant">]</span> ] <span class="muRecipe">recipe</span> factorial [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - n:number<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> + n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># if n=0 return 1</span> zero?:boolean<span class="Special"> <- </span>equal n:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-unless</span> zero?:boolean - <span class="Identifier">reply</span> <span class="Constant">1:literal</span> + <span class="muControl">break-unless</span> zero?:boolean + <span class="muControl">reply</span> <span class="Constant">1:literal</span> <span class="Delimiter">}</span> <span class="Comment"># return n * factorial(n - 1)</span> x:number<span class="Special"> <- </span>subtract n:number, <span class="Constant">1:literal</span> subresult:number<span class="Special"> <- </span>factorial x:number result:number<span class="Special"> <- </span>multiply subresult:number, n:number - <span class="Identifier">reply</span> result:number + <span class="muControl">reply</span> result:number ] <span class="Comment"># unit test</span> diff --git a/html/fork.mu.html b/html/fork.mu.html index 39c7207a..40e645b5 100644 --- a/html/fork.mu.html +++ b/html/fork.mu.html @@ -16,7 +16,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } --> </style> @@ -34,15 +34,15 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muRecipe">recipe</span> main [ start-running thread2:<span class="muRecipe">recipe</span> <span class="Delimiter">{</span> - <span class="Identifier"> $print</span> <span class="Constant">34:literal</span> - <span class="Identifier">loop</span> + $print <span class="Constant">34:literal</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> ] <span class="muRecipe">recipe</span> thread2 [ <span class="Delimiter">{</span> - <span class="Identifier"> $print</span> <span class="Constant">35:literal</span> - <span class="Identifier">loop</span> + $print <span class="Constant">35:literal</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> ] </pre> diff --git a/html/keyboard.mu.html b/html/keyboard.mu.html index 29d73f4e..9b0e29b3 100644 --- a/html/keyboard.mu.html +++ b/html/keyboard.mu.html @@ -17,7 +17,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } --> </style> @@ -39,9 +39,9 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } switch-to-display <span class="Delimiter">{</span> c:character, found?:boolean<span class="Special"> <- </span>read-key-from-keyboard - <span class="Identifier">break-if</span> found?:boolean + <span class="muControl">break-if</span> found?:boolean print-character-to-display <span class="Constant">97:literal</span> - <span class="Identifier">loop</span> + <span class="muControl">loop</span> <span class="Delimiter">}</span> return-to-console ] diff --git a/html/mouse.mu.html b/html/mouse.mu.html new file mode 100644 index 00000000..c4926f24 --- /dev/null +++ b/html/mouse.mu.html @@ -0,0 +1,46 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<title>Mu - mouse.mu</title> +<meta name="Generator" content="Vim/7.4"> +<meta name="plugin-version" content="vim7.4_v1"> +<meta name="syntax" content="none"> +<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy="> +<meta name="colorscheme" content="minimal"> +<style type="text/css"> +<!-- +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; } +.Comment { color: #8080ff; } +.Delimiter { color: #c000c0; } +.Special { color: #ff6060; } +.muControl { color: #804000; } +.muRecipe { color: #ff8700; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<span class="Comment"># example program: managing the display</span> + +<span class="muRecipe">recipe</span> main [ + switch-to-display + <span class="Delimiter">{</span> + _, found?:boolean<span class="Special"> <- </span>read-keyboard-or-mouse-event + <span class="muControl">break-if</span> found?:boolean + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + return-to-console +] +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> 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 [ diff --git a/html/tangle.mu.html b/html/tangle.mu.html index 4edc9c2d..4337e012 100644 --- a/html/tangle.mu.html +++ b/html/tangle.mu.html @@ -17,7 +17,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } +.muControl { color: #804000; } .muRecipe { color: #ff8700; } --> </style> @@ -39,32 +39,32 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># possibilities.</span> <span class="muRecipe">recipe</span> factorial [ - <span class="Identifier">default-space</span>:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> - n:number<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> + n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> - <span class="Identifier"> +base-case</span> +<span class="Constant"> +base-case</span> <span class="Delimiter">}</span> - <span class="Identifier"> +recursive-case</span> +<span class="Constant"> +recursive-case</span> ] -<span class="muRecipe">after</span><span class="Identifier"> +base-case</span> [ +<span class="muRecipe">after</span> +base-case [ <span class="Comment"># if n=0 return 1</span> zero?:boolean<span class="Special"> <- </span>equal n:number, <span class="Constant">0:literal</span> - <span class="Identifier">break-unless</span> zero?:boolean - <span class="Identifier">reply</span> <span class="Constant">1:literal</span> + <span class="muControl">break-unless</span> zero?:boolean + <span class="muControl">reply</span> <span class="Constant">1:literal</span> ] -<span class="muRecipe">after</span><span class="Identifier"> +recursive-case</span> [ +<span class="muRecipe">after</span> +recursive-case [ <span class="Comment"># return n * factorial(n - 1)</span> x:number<span class="Special"> <- </span>subtract n:number, <span class="Constant">1:literal</span> subresult:number<span class="Special"> <- </span>factorial x:number result:number<span class="Special"> <- </span>multiply subresult:number, n:number - <span class="Identifier">reply</span> result:number + <span class="muControl">reply</span> result:number ] <span class="muRecipe">recipe</span> main [ 1:number<span class="Special"> <- </span>factorial <span class="Constant">5:literal</span> - <span class="Identifier"> $print</span> <span class="Constant">[result: ]</span>, 1:number, [ + $print <span class="Constant">[result: ]</span>, 1:number, [ ] ] </pre> diff --git a/html/x.mu.html b/html/x.mu.html index 96eb4be8..8bde79bf 100644 --- a/html/x.mu.html +++ b/html/x.mu.html @@ -16,7 +16,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } -.Identifier { color: #008080; } .muRecipe { color: #ff8700; } --> </style> @@ -35,7 +34,7 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } 11:number<span class="Special"> <- </span>copy <span class="Constant">1:literal</span> 12:number<span class="Special"> <- </span>copy <span class="Constant">3:literal</span> 13:number<span class="Special"> <- </span>add 11:number, 12:number - <span class="Identifier"> $dump-memory</span> +<span class="Constant"> $dump-memory</span> ] </pre> </body> |