diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-30 19:30:33 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-30 19:37:02 -0700 |
commit | 4bbd3ded0b767ae0919551776e4c17189140e735 (patch) | |
tree | 29300d13dc2b869378fbde7f5456b1cfb519482d /html | |
parent | 06f3cebe3eb627e18910b6394bfde88c806c8f91 (diff) | |
download | mu-4bbd3ded0b767ae0919551776e4c17189140e735.tar.gz |
1517
Diffstat (limited to 'html')
65 files changed, 1320 insertions, 360 deletions
diff --git a/html/000organization.cc.html b/html/000organization.cc.html index 3767d420..6ec61434 100644 --- a/html/000organization.cc.html +++ b/html/000organization.cc.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.Delimiter { color: #c000c0; } +.Identifier { color: #008080; } .Comment { color: #8080ff; } .Constant { color: #008080; } -.Identifier { color: #008080; } .PreProc { color: #c000c0; } +.Delimiter { color: #c000c0; } --> </style> diff --git a/html/001help.cc.html b/html/001help.cc.html index 9fd816a7..d131b7a4 100644 --- a/html/001help.cc.html +++ b/html/001help.cc.html @@ -10,8 +10,8 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .cSpecial { color: #008000; } .Constant { color: #008080; } diff --git a/html/002test.cc.html b/html/002test.cc.html index 895022da..a8285065 100644 --- a/html/002test.cc.html +++ b/html/002test.cc.html @@ -10,15 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .cSpecial { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } -.Identifier { color: #008080; } .PreProc { color: #c000c0; } +.CommentedCode { color: #6c6c6c; } +.Identifier { color: #008080; } --> </style> @@ -86,6 +87,7 @@ if <span class="Delimiter">(</span>Run_tests<span class="Delimiter">)</span> <sp time_t t<span class="Delimiter">;</span> time<span class="Delimiter">(</span>&t<span class="Delimiter">);</span> cerr << <span class="Constant">"C tests: "</span> << ctime<span class="Delimiter">(</span>&t<span class="Delimiter">);</span> for <span class="Delimiter">(</span>size_t i=<span class="Constant">0</span><span class="Delimiter">;</span> i < sizeof<span class="Delimiter">(</span>Tests<span class="Delimiter">)</span>/sizeof<span class="Delimiter">(</span>Tests[<span class="Constant">0</span>]<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << i << '\n'; //? 1</span> run_test<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span class="Delimiter">}</span> <span class="Comment">// End Tests</span> diff --git a/html/003trace.cc.html b/html/003trace.cc.html index 2fe22df3..2c04a850 100644 --- a/html/003trace.cc.html +++ b/html/003trace.cc.html @@ -10,17 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .cSpecial { color: #008000; } .Constant { color: #008080; } -.Identifier { color: #008080; } +.PreProc { color: #c000c0; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } -.SalientComment { color: #00ffff; } .CommentedCode { color: #6c6c6c; } -.PreProc { color: #c000c0; } +.Identifier { color: #008080; } --> </style> @@ -213,9 +212,12 @@ ostream& operator<<<span class="Delimiter">(</span>ostream& os<spa <span class="PreProc">#define DUMP(layer) </span>if<span class="PreProc"> (Trace_stream) cerr << Trace_stream</span><span class="Delimiter">-></span><span class="PreProc">readable_contents(layer)</span><span class="Delimiter">;</span> -<span class="Comment">// Trace_stream is a resource, lease_tracer uses RAII to manage it.</span> -string Trace_file<span class="Delimiter">;</span> +<span class="Comment">// All scenarios save their traces in the repo, just like code. This gives</span> +<span class="Comment">// future readers more meat when they try to make sense of a new project.</span> static string Trace_dir = <span class="Constant">".traces/"</span><span class="Delimiter">;</span> +string Trace_file<span class="Delimiter">;</span> + +<span class="Comment">// Trace_stream is a resource, lease_tracer uses RAII to manage it.</span> struct lease_tracer <span class="Delimiter">{</span> lease_tracer<span class="Delimiter">()</span> <span class="Delimiter">{</span> Trace_stream = new trace_stream<span class="Delimiter">;</span> <span class="Delimiter">}</span> ~lease_tracer<span class="Delimiter">()</span> <span class="Delimiter">{</span> @@ -230,9 +232,6 @@ struct lease_tracer <span class="Delimiter">{</span> <span class="Delimiter">}</span> <span class="Delimiter">};</span> -<span class="Comment">// To transparently save traces, start tests with the TEST() macro.</span> -<span class="PreProc">#define TEST(name) </span>void<span class="PreProc"> test_</span><span class="SalientComment">##name() { Trace_file = #name;</span> - <span class="PreProc">#define START_TRACING_UNTIL_END_OF_SCOPE lease_tracer leased_tracer</span><span class="Delimiter">;</span> <span class="Delimiter">:(before "End Test Setup")</span> START_TRACING_UNTIL_END_OF_SCOPE diff --git a/html/003trace.test.cc.html b/html/003trace.test.cc.html index d32bdc77..704fd64e 100644 --- a/html/003trace.test.cc.html +++ b/html/003trace.test.cc.html @@ -10,12 +10,12 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .cSpecial { color: #008000; } -.Constant { color: #008080; } .Delimiter { color: #c000c0; } +.Constant { color: #008080; } .Comment { color: #8080ff; } --> </style> diff --git a/html/010vm.cc.html b/html/010vm.cc.html index 5545f2ae..5a971a6d 100644 --- a/html/010vm.cc.html +++ b/html/010vm.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .cSpecial { color: #008000; } .Constant { color: #008080; } -.Identifier { color: #008080; } +.PreProc { color: #c000c0; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } .CommentedCode { color: #6c6c6c; } -.PreProc { color: #c000c0; } +.Identifier { color: #008080; } --> </style> diff --git a/html/011load.cc.html b/html/011load.cc.html index ed5f8bb3..7b1807c5 100644 --- a/html/011load.cc.html +++ b/html/011load.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -34,7 +34,7 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } <pre id='vimCodeElement'> <span class="Comment">//: Phase 1 of running mu code: load it from a textual representation.</span> -<span class="Delimiter">:(scenarios load)</span> +<span class="Delimiter">:(scenarios load)</span> <span class="Comment">// use 'load' instead of 'run' in all scenarios in this layer</span> <span class="Delimiter">:(scenario first_recipe)</span> recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">23</span>:literal diff --git a/html/012transform.cc.html b/html/012transform.cc.html index 0ebf0874..aca6b62b 100644 --- a/html/012transform.cc.html +++ b/html/012transform.cc.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .Constant { color: #008080; } -.Identifier { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .CommentedCode { color: #6c6c6c; } +.Identifier { color: #008080; } --> </style> diff --git a/html/013literal_string.cc.html b/html/013literal_string.cc.html index 51b60ee4..19683498 100644 --- a/html/013literal_string.cc.html +++ b/html/013literal_string.cc.html @@ -10,16 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } +.cSpecial { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -67,15 +68,23 @@ string slurp_quoted<span class="Delimiter">(</span>istream& in<span class="D assert<span class="Delimiter">(</span>!in<span class="Delimiter">.</span>eof<span class="Delimiter">());</span> assert<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'['</span><span class="Delimiter">);</span> ostringstream out<span class="Delimiter">;</span> - int size = <span class="Constant">0</span><span class="Delimiter">;</span> + int brace_depth = <span class="Constant">0</span><span class="Delimiter">;</span> while <span class="Delimiter">(</span>!in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span> char c = in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> -<span class="CommentedCode">//? cout << c << '\n'; //? 1</span> +<span class="CommentedCode">//? cout << (int)c << ": " << brace_depth << '\n'; //? 2</span> + if <span class="Delimiter">(</span>c == <span class="cSpecial">'\\'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + out << <span class="Delimiter">(</span>char<span class="Delimiter">)</span>in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> out << c<span class="Delimiter">;</span> <span class="CommentedCode">//? cout << out.str() << "$\n"; //? 1</span> - if <span class="Delimiter">(</span>c == <span class="Constant">'['</span><span class="Delimiter">)</span> ++size<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>c == <span class="Constant">']'</span><span class="Delimiter">)</span> --size<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>size == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>c == <span class="Constant">'['</span><span class="Delimiter">)</span> ++brace_depth<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>c == <span class="Constant">']'</span><span class="Delimiter">)</span> --brace_depth<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>brace_depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>eof<span class="Delimiter">()</span> && brace_depth > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << <span class="Constant">"unbalanced '['</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> + <span class="Identifier">return</span> <span class="Constant">""</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> @@ -100,6 +109,12 @@ recipe main [ ] <span class="traceContains">+parse: ingredient: {name: "abc [def]", properties: ["abc [def]": "literal-string"]}</span> +<span class="Delimiter">:(scenario string_literal_escaped)</span> +recipe main [ + <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy [abc \[def] +] +<span class="traceContains">+parse: ingredient: {name: "abc [def", properties: ["abc [def": "literal-string"]}</span> + <span class="Delimiter">:(scenario string_literal_and_comment)</span> recipe main [ <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>copy [abc] <span class="Comment"># comment</span> diff --git a/html/014literal_noninteger.cc.html b/html/014literal_noninteger.cc.html index 20d580cb..9c9b9286 100644 --- a/html/014literal_noninteger.cc.html +++ b/html/014literal_noninteger.cc.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> diff --git a/html/020run.cc.html b/html/020run.cc.html index 5a02657c..2c39d12c 100644 --- a/html/020run.cc.html +++ b/html/020run.cc.html @@ -10,19 +10,19 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } -.traceAbsent { color: #c00000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/021arithmetic.cc.html b/html/021arithmetic.cc.html index 5f041ea7..321d66f0 100644 --- a/html/021arithmetic.cc.html +++ b/html/021arithmetic.cc.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> diff --git a/html/022boolean.cc.html b/html/022boolean.cc.html index 66e35c16..72539bf2 100644 --- a/html/022boolean.cc.html +++ b/html/022boolean.cc.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> diff --git a/html/023jump.cc.html b/html/023jump.cc.html index 0cf48bbf..842651db 100644 --- a/html/023jump.cc.html +++ b/html/023jump.cc.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .Constant { color: #008080; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> diff --git a/html/024compare.cc.html b/html/024compare.cc.html index 9bb84e86..1a145d00 100644 --- a/html/024compare.cc.html +++ b/html/024compare.cc.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> diff --git a/html/025trace.cc.html b/html/025trace.cc.html index 5ee0e70b..7951bfb5 100644 --- a/html/025trace.cc.html +++ b/html/025trace.cc.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> @@ -47,7 +47,7 @@ case TRACE: <span class="Delimiter">{</span> string label = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>isa_literal<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)));</span> string message = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> - trace<span class="Delimiter">(</span>label<span class="Delimiter">)</span> << message<span class="Delimiter">;</span> + trace<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">,</span> label<span class="Delimiter">)</span> << message<span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/026assert.cc.html b/html/026assert.cc.html index 66ff0180..2cfeff0d 100644 --- a/html/026assert.cc.html +++ b/html/026assert.cc.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .Constant { color: #008080; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> @@ -31,7 +31,7 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } <body> <pre id='vimCodeElement'> <span class="Delimiter">:(scenario assert)</span> -<span class="Special">% Hide_warnings = true;</span> +<span class="Special">% Hide_warnings = true; // '%' lines insert arbitrary C code into tests before calling 'run' with the lines below. Must be immediately after :(scenario) line.</span> recipe main [ assert <span class="Constant">0</span>:literal<span class="Delimiter">,</span> [this is an assert in mu] ] diff --git a/html/027debug.cc.html b/html/027debug.cc.html index 61a5577b..1cfa4300 100644 --- a/html/027debug.cc.html +++ b/html/027debug.cc.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/030container.cc.html b/html/030container.cc.html index 4da2e138..5e7b1ff1 100644 --- a/html/030container.cc.html +++ b/html/030container.cc.html @@ -10,19 +10,19 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.traceAbsent { color: #c00000; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } +.cSpecial { color: #008000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.cSpecial { color: #008000; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -50,11 +50,14 @@ Type[point]<span class="Delimiter">.</span>elements<span class="Delimiter">.</sp <span class="Comment">//: Containers can be copied around with a single instruction just like</span> <span class="Comment">//: numbers, no matter how large they are.</span> +<span class="Comment">//: Tests in this layer often explicitly setup memory before reading it as a</span> +<span class="Comment">//: container. Don't do this in general. I'm tagging exceptions with /raw to</span> +<span class="Comment">//: avoid warnings.</span> <span class="Delimiter">:(scenario copy_multiple_locations)</span> recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal - <span class="Constant">3</span>:point<span class="Special"> <- </span>copy <span class="Constant">1</span>:point + <span class="Constant">3</span>:point<span class="Special"> <- </span>copy <span class="Constant">1</span>:point/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 34 in location 3</span> <span class="traceContains">+mem: storing 35 in location 4</span> @@ -78,7 +81,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span>:literal - <span class="Constant">15</span>:point-number<span class="Special"> <- </span>copy <span class="Constant">12</span>:point-number + <span class="Constant">15</span>:point-number<span class="Special"> <- </span>copy <span class="Constant">12</span>:point-number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 36 in location 17</span> @@ -93,7 +96,7 @@ recipe main [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Comment"># second</span> <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal <span class="Constant">6</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span>:literal - <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number<span class="Delimiter">,</span> <span class="Constant">4</span>:point-number + <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">4</span>:point-number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 1 in location 7</span> @@ -105,7 +108,7 @@ recipe main [ <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Comment"># second</span> <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal <span class="Constant">6</span>:number<span class="Special"> <- </span>copy <span class="Constant">37</span>:literal <span class="Comment"># different</span> - <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number<span class="Delimiter">,</span> <span class="Constant">4</span>:point-number + <span class="Constant">7</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">1</span>:point-number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">4</span>:point-number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 0 in location 7</span> @@ -127,7 +130,7 @@ if <span class="Delimiter">(</span>t<span class="Delimiter">.</span>kind == cont recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal - <span class="Constant">15</span>:number<span class="Special"> <- </span>get <span class="Constant">12</span>:point<span class="Delimiter">,</span> <span class="Constant">1</span>:offset + <span class="Constant">15</span>:number<span class="Special"> <- </span>get <span class="Constant">12</span>:point/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 35 in location 15</span> @@ -165,7 +168,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span>:literal - <span class="Constant">15</span>:number<span class="Special"> <- </span>get <span class="Constant">12</span>:point-number<span class="Delimiter">,</span> <span class="Constant">1</span>:offset + <span class="Constant">15</span>:number<span class="Special"> <- </span>get <span class="Constant">12</span>:point-number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 36 in location 15</span> @@ -175,7 +178,7 @@ recipe main [ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal - <span class="Constant">15</span>:address:number<span class="Special"> <- </span>get-address <span class="Constant">12</span>:point<span class="Delimiter">,</span> <span class="Constant">1</span>:offset + <span class="Constant">15</span>:address:number<span class="Special"> <- </span>get-address <span class="Constant">12</span>:point/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:offset <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 13 in location 15</span> @@ -372,6 +375,18 @@ container foo [ ] <span class="traceContains">+warn: unknown type for field y in foo</span> +<span class="Delimiter">:(scenario read_container_with_bracket_in_comment)</span> +container foo [ + x:number + <span class="Comment"># ']' in comment</span> + y:number +] +<span class="traceContains">+parse: reading container foo</span> +<span class="traceContains">+parse: element name: x</span> +<span class="traceContains">+parse: type: 1</span> +<span class="traceContains">+parse: element name: y</span> +<span class="traceContains">+parse: type: 1</span> + <span class="Delimiter">:(before "End Load Sanity Checks")</span> check_container_field_types<span class="Delimiter">();</span> diff --git a/html/031address.cc.html b/html/031address.cc.html index 35bc04e3..de366c9a 100644 --- a/html/031address.cc.html +++ b/html/031address.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/032array.cc.html b/html/032array.cc.html index cac483a1..ac8d1636 100644 --- a/html/032array.cc.html +++ b/html/032array.cc.html @@ -13,15 +13,15 @@ pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -40,6 +40,9 @@ body { font-family: monospace; color: #d0d0d0; background-color: #080808; } <span class="Comment">//: elements of a fixed size, so you can't create containers containing arrays.</span> <span class="Comment">//: Create containers containing addresses to arrays instead.</span> +<span class="Comment">//: Tests in this layer often explicitly setup memory before reading it as an</span> +<span class="Comment">//: array. Don't do this in general. I'm tagging exceptions with /raw to</span> +<span class="Comment">//: avoid warnings.</span> <span class="Delimiter">:(scenario copy_array)</span> <span class="Comment"># Arrays can be copied around with a single instruction just like numbers,</span> <span class="Comment"># no matter how large they are.</span> @@ -48,7 +51,7 @@ recipe main [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">14</span>:literal <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span>:literal <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal - <span class="Constant">5</span>:array:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:array:number + <span class="Constant">5</span>:array:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:array:number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 3 in location 5</span> <span class="traceContains">+mem: storing 14 in location 6</span> @@ -87,7 +90,7 @@ recipe main [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">14</span>:literal <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span>:literal <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal - <span class="Constant">5</span>:number<span class="Special"> <- </span>index <span class="Constant">1</span>:array:number<span class="Delimiter">,</span> <span class="Constant">0</span>:literal + <span class="Constant">5</span>:number<span class="Special"> <- </span>index <span class="Constant">1</span>:array:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">0</span>:literal <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 14 in location 5</span> @@ -98,7 +101,7 @@ recipe main [ <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span>:literal <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal <span class="Constant">5</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal - <span class="Constant">6</span>:number<span class="Special"> <- </span>index <span class="Constant">1</span>:array:number<span class="Delimiter">,</span> <span class="Constant">5</span>:number + <span class="Constant">6</span>:number<span class="Special"> <- </span>index <span class="Constant">1</span>:array:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">5</span>:number <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 14 in location 6</span> @@ -140,7 +143,7 @@ recipe main [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">14</span>:literal <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span>:literal <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal - <span class="Constant">5</span>:number<span class="Special"> <- </span>index-address <span class="Constant">1</span>:array:number<span class="Delimiter">,</span> <span class="Constant">0</span>:literal + <span class="Constant">5</span>:number<span class="Special"> <- </span>index-address <span class="Constant">1</span>:array:number/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">0</span>:literal <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 2 in location 5</span> @@ -183,7 +186,7 @@ recipe main [ <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">14</span>:literal <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">15</span>:literal <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">16</span>:literal - <span class="Constant">5</span>:number<span class="Special"> <- </span>length <span class="Constant">1</span>:array:number + <span class="Constant">5</span>:number<span class="Special"> <- </span>length <span class="Constant">1</span>:array:number/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 3 in location 5</span> diff --git a/html/034exclusive_container.cc.html b/html/034exclusive_container.cc.html index 3da49c53..842c2789 100644 --- a/html/034exclusive_container.cc.html +++ b/html/034exclusive_container.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.Identifier { color: #008080; } +.traceContains { color: #008000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> @@ -59,13 +59,16 @@ Type[tmp]<span class="Delimiter">.</span>element_names<span class="Delimiter">.< Type[tmp]<span class="Delimiter">.</span>element_names<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">"p"</span><span class="Delimiter">);</span> <span class="Delimiter">}</span> +<span class="Comment">//: Tests in this layer often explicitly setup memory before reading it as an</span> +<span class="Comment">//: array. Don't do this in general. I'm tagging exceptions with /raw to</span> +<span class="Comment">//: avoid warnings.</span> <span class="Delimiter">:(scenario copy_exclusive_container)</span> <span class="Comment"># Copying exclusive containers copies all their contents and an extra location for the tag.</span> recipe main [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal <span class="Comment"># 'point' variant</span> <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span>:literal <span class="Constant">3</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal - <span class="Constant">4</span>:number-or-point<span class="Special"> <- </span>copy <span class="Constant">1</span>:number-or-point + <span class="Constant">4</span>:number-or-point<span class="Special"> <- </span>copy <span class="Constant">1</span>:number-or-point/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 1 in location 4</span> <span class="traceContains">+mem: storing 34 in location 5</span> @@ -103,7 +106,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span>:literal - <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point<span class="Delimiter">,</span> <span class="Constant">1</span>:variant + <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">1</span>:variant <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 13 in location 20</span> @@ -112,7 +115,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span>:literal - <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point<span class="Delimiter">,</span> <span class="Constant">0</span>:variant + <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/<span class="Special">raw</span><span class="Delimiter">,</span> <span class="Constant">0</span>:variant <span class="Comment"># unsafe</span> ] <span class="traceContains">+mem: storing 0 in location 20</span> diff --git a/html/035call.cc.html b/html/035call.cc.html index 5ba49098..73ba8d07 100644 --- a/html/035call.cc.html +++ b/html/035call.cc.html @@ -10,18 +10,18 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } .PreProc { color: #c000c0; } -.traceContains { color: #008000; } --> </style> diff --git a/html/036call_ingredient.cc.html b/html/036call_ingredient.cc.html index 15645498..45c81074 100644 --- a/html/036call_ingredient.cc.html +++ b/html/036call_ingredient.cc.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> diff --git a/html/037call_reply.cc.html b/html/037call_reply.cc.html index 22509da6..60363350 100644 --- a/html/037call_reply.cc.html +++ b/html/037call_reply.cc.html @@ -10,16 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } +.CommentedCode { color: #6c6c6c; } .Identifier { color: #008080; } -.traceContains { color: #008000; } --> </style> @@ -53,6 +54,10 @@ Recipe_number[<span class="Constant">"reply"</span>] = REPLY<span clas case REPLY: <span class="Delimiter">{</span> const instruction& reply_inst = current_instruction<span class="Delimiter">();</span> <span class="Comment">// save pointer into recipe before pop</span> --Callstack_depth<span class="Delimiter">;</span> +<span class="CommentedCode">//? if (tb_is_active()) { //? 1</span> +<span class="CommentedCode">//? tb_clear(); //? 1</span> +<span class="CommentedCode">//? cerr << Recipe[Current_routine->calls.front().running_recipe].name << ' ' << current_step_index() << '\n'; //? 1</span> +<span class="CommentedCode">//? } //? 1</span> Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>pop_front<span class="Delimiter">();</span> <span class="Comment">// just in case 'main' returns a value, drop it for now</span> if <span class="Delimiter">(</span>Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Identifier">goto</span> stop_running_current_routine<span class="Delimiter">;</span> @@ -62,6 +67,7 @@ case REPLY: <span class="Delimiter">{</span> <span class="Comment">// check that any reply ingredients with /same-as-ingredient connect up</span> <span class="Comment">// the corresponding ingredient and product in the caller.</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>caller_instruction<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << Recipe[Current_routine->calls.front().running_recipe].name << '\n'; //? 1</span> trace<span class="Delimiter">(</span>Primitive_recipe_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"result "</span> << i << <span class="Constant">" is "</span> << to_string<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> if <span class="Delimiter">(</span>has_property<span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"same-as-ingredient"</span><span class="Delimiter">))</span> <span class="Delimiter">{</span> vector<string> tmp = property<span class="Delimiter">(</span>reply_inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> <span class="Constant">"same-as-ingredient"</span><span class="Delimiter">);</span> @@ -84,7 +90,7 @@ recipe main [ recipe f [ <span class="Constant">12</span>:number<span class="Special"> <- </span>next-ingredient <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal - reply <span class="Constant">12</span>:point + reply <span class="Constant">12</span>:point/<span class="Special">raw</span> <span class="Comment"># unsafe</span> ] <span class="traceContains">+run: result 0 is [2, 35]</span> <span class="traceContains">+mem: storing 2 in location 3</span> diff --git a/html/038scheduler.cc.html b/html/038scheduler.cc.html index 8bdb1488..abf7f469 100644 --- a/html/038scheduler.cc.html +++ b/html/038scheduler.cc.html @@ -10,19 +10,19 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.traceAbsent { color: #c00000; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.Identifier { color: #008080; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> @@ -246,9 +246,9 @@ recipe f2 [ ] <span class="traceContains">+mem: storing 2 in location 1</span> +<span class="Comment">//: this scenario will require some careful setup in escaped C++</span> +<span class="Comment">//: (straining our tangle capabilities to near-breaking point)</span> <span class="Delimiter">:(scenario scheduler_skips_completed_routines)</span> -<span class="Comment"># this scenario will require some careful setup in escaped C++</span> -<span class="Comment"># (straining our tangle capabilities to near-breaking point)</span> <span class="Special">% recipe_number f1 = load("recipe f1 [\n1:number <- copy 0:literal\n]").front();</span> <span class="Special">% recipe_number f2 = load("recipe f2 [\n2:number <- copy 0:literal\n]").front();</span> <span class="Special">% Routines.push_back(new routine(f1)); // f1 meant to run</span> diff --git a/html/039wait.cc.html b/html/039wait.cc.html index b5325799..fb60ffc8 100644 --- a/html/039wait.cc.html +++ b/html/039wait.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.Identifier { color: #008080; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> diff --git a/html/040brace.cc.html b/html/040brace.cc.html index d864ce4f..c6c12f8c 100644 --- a/html/040brace.cc.html +++ b/html/040brace.cc.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/041name.cc.html b/html/041name.cc.html index 35e2067e..ee937835 100644 --- a/html/041name.cc.html +++ b/html/041name.cc.html @@ -10,19 +10,19 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } -.traceAbsent { color: #c00000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -67,6 +67,7 @@ void transform_names<span class="Delimiter">(</span>const recipe_number r<span c bool names_used = <span class="Constant">false</span><span class="Delimiter">;</span> bool numeric_locations_used = <span class="Constant">false</span><span class="Delimiter">;</span> map<string<span class="Delimiter">,</span> long long int>& names = Name[r]<span class="Delimiter">;</span> + map<string<span class="Delimiter">,</span> vector<type_number> > metadata<span class="Delimiter">;</span> <span class="Comment">// store the indices 'used' so far in the map</span> long long int& curr_idx = names[<span class="Constant">""</span>]<span class="Delimiter">;</span> ++curr_idx<span class="Delimiter">;</span> <span class="Comment">// avoid using index 0, benign skip in some other cases</span> @@ -75,6 +76,7 @@ void transform_names<span class="Delimiter">(</span>const recipe_number r<span c <span class="Comment">// Per-recipe Transforms</span> <span class="Comment">// map names to addresses</span> for <span class="Delimiter">(</span>long long int in = <span class="Constant">0</span><span class="Delimiter">;</span> in < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">);</span> ++in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + check_metadata<span class="Delimiter">(</span>metadata<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> r<span class="Delimiter">);</span> if <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> numeric_locations_used = <span class="Constant">true</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> names_used = <span class="Constant">true</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -84,6 +86,7 @@ void transform_names<span class="Delimiter">(</span>const recipe_number r<span c inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>lookup_name<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>in<span class="Delimiter">),</span> r<span class="Delimiter">));</span> <span class="Delimiter">}</span> for <span class="Delimiter">(</span>long long int out = <span class="Constant">0</span><span class="Delimiter">;</span> out < SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">);</span> ++out<span class="Delimiter">)</span> <span class="Delimiter">{</span> + check_metadata<span class="Delimiter">(</span>metadata<span class="Delimiter">,</span> inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">),</span> r<span class="Delimiter">);</span> if <span class="Delimiter">(</span>is_numeric_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> numeric_locations_used = <span class="Constant">true</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>is_named_location<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> names_used = <span class="Constant">true</span><span class="Delimiter">;</span> if <span class="Delimiter">(</span>disqualified<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span>out<span class="Delimiter">)))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> @@ -99,6 +102,15 @@ void transform_names<span class="Delimiter">(</span>const recipe_number r<span c raise << <span class="Constant">"mixing variable names and numeric addresses in "</span> << Recipe[r]<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> +void check_metadata<span class="Delimiter">(</span>map<string<span class="Delimiter">,</span> vector<type_number> >& metadata<span class="Delimiter">,</span> const reagent& x<span class="Delimiter">,</span> const recipe_number r<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>isa_literal<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span> + if <span class="Delimiter">(</span>metadata<span class="Delimiter">.</span>find<span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">)</span> == metadata<span class="Delimiter">.</span>end<span class="Delimiter">())</span> + metadata[x<span class="Delimiter">.</span>name] = x<span class="Delimiter">.</span>types<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>metadata[x<span class="Delimiter">.</span>name] != x<span class="Delimiter">.</span>types<span class="Delimiter">)</span> + raise << x<span class="Delimiter">.</span>name << <span class="Constant">" used with multiple types in "</span> << Recipe[r]<span class="Delimiter">.</span>name << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + bool disqualified<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">mutable</span><span class="Comment">*/</span> reagent& x<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>types<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> raise << <span class="Constant">"missing type in "</span> << x<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> @@ -216,6 +228,14 @@ recipe main [ ] <span class="traceAbsent">-warn: mixing variable names and numeric addresses in main</span> +<span class="Delimiter">:(scenario convert_names_warns_on_reusing_name_with_different_type)</span> +<span class="Special">% Hide_warnings = true;</span> +recipe main [ + x:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal + x:boolean<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal +] +<span class="traceContains">+warn: x used with multiple types in main</span> + <span class="SalientComment">//:: Support element names for containers in 'get' and 'get-address'.</span> <span class="Comment">//: update our running example container for the next test</span> @@ -264,7 +284,7 @@ recipe main [ <span class="Constant">12</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:literal <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span>:literal <span class="Constant">14</span>:number<span class="Special"> <- </span>copy <span class="Constant">36</span>:literal - <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point<span class="Delimiter">,</span> p:variant + <span class="Constant">20</span>:address:point<span class="Special"> <- </span>maybe-convert <span class="Constant">12</span>:number-or-point/<span class="Special">raw</span><span class="Delimiter">,</span> p:variant <span class="Comment"># unsafe</span> ] <span class="traceContains">+name: variant p of type number-or-point has tag 1</span> <span class="traceContains">+mem: storing 13 in location 20</span> diff --git a/html/042new.cc.html b/html/042new.cc.html index ad722ef0..b19775ab 100644 --- a/html/042new.cc.html +++ b/html/042new.cc.html @@ -10,18 +10,19 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.Identifier { color: #008080; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.PreProc { color: #c000c0; } +.Identifier { color: #008080; } --> </style> @@ -194,7 +195,7 @@ recipe main [ <span class="traceContains">+new: routine allocated memory from 1000 to 1002</span> <span class="traceContains">+new: routine allocated memory from 1002 to 1004</span> -<span class="SalientComment">//:: Next, extend 'new' to handle a string literal argument.</span> +<span class="SalientComment">//:: Next, extend 'new' to handle a unicode string literal argument.</span> <span class="Delimiter">:(scenario new_string)</span> recipe main [ @@ -204,6 +205,16 @@ recipe main [ <span class="Comment"># number code for 'e'</span> <span class="traceContains">+mem: storing 101 in location 2</span> +<span class="Delimiter">:(scenario new_string_handles_unicode)</span> +recipe main [ + <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [a«c] + <span class="Constant">2</span>:number<span class="Special"> <- </span>length <span class="Constant">1</span>:address:array:character/deref + <span class="Constant">3</span>:character<span class="Special"> <- </span>index <span class="Constant">1</span>:address:array:character/deref<span class="Delimiter">,</span> <span class="Constant">1</span>:literal +] +<span class="traceContains">+mem: storing 3 in location 2</span> +<span class="Comment"># unicode for '«'</span> +<span class="traceContains">+mem: storing 171 in location 3</span> + <span class="Delimiter">:(before "End NEW Transform Special-cases")</span> if <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">"literal-string"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// skip transform</span> @@ -215,7 +226,7 @@ recipe main [ if <span class="Delimiter">(</span>isa_literal<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">))</span> && current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span> == <span class="Constant">"literal-string"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// allocate an array just large enough for it</span> - long long int string_length = SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> + long long int string_length = unicode_length<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span class="CommentedCode">//? cout << "string_length is " << string_length << '\n'; //? 1</span> ensure_space<span class="Delimiter">(</span>string_length+<span class="Constant">1</span><span class="Delimiter">);</span> <span class="Comment">// don't forget the extra location for array size</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span> @@ -223,8 +234,16 @@ if <span class="Delimiter">(</span>isa_literal<span class="Delimiter">(</span>cu <span class="Comment">// initialize string</span> <span class="CommentedCode">//? cout << "new string literal: " << current_instruction().ingredients.at(0).name << '\n'; //? 1</span> Memory[Current_routine<span class="Delimiter">-></span>alloc++] = string_length<span class="Delimiter">;</span> + long long int curr = <span class="Constant">0</span><span class="Delimiter">;</span> + const string& contents = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">;</span> + const char* raw_contents = contents<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < string_length<span class="Delimiter">;</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - Memory[Current_routine<span class="Delimiter">-></span>alloc++] = current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> + uint32_t curr_character<span class="Delimiter">;</span> + assert<span class="Delimiter">(</span>curr < SIZE<span class="Delimiter">(</span>contents<span class="Delimiter">));</span> + tb_utf8_char_to_unicode<span class="Delimiter">(</span>&curr_character<span class="Delimiter">,</span> &raw_contents[curr]<span class="Delimiter">);</span> + Memory[Current_routine<span class="Delimiter">-></span>alloc] = curr_character<span class="Delimiter">;</span> + curr += tb_utf8_char_length<span class="Delimiter">(</span>raw_contents[curr]<span class="Delimiter">);</span> + ++Current_routine<span class="Delimiter">-></span>alloc<span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Comment">// mu strings are not null-terminated in memory</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -239,6 +258,23 @@ recipe main [ ] <span class="traceContains">+new: routine allocated memory from 1000 to 1002</span> <span class="traceContains">+new: routine allocated memory from 1002 to 1004</span> + +<span class="Comment">//: helpers</span> +<span class="Delimiter">:(code)</span> +long long int unicode_length<span class="Delimiter">(</span>const string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> + const char* in = s<span class="Delimiter">.</span>c_str<span class="Delimiter">();</span> + long long int result = <span class="Constant">0</span><span class="Delimiter">;</span> + long long int curr = <span class="Constant">0</span><span class="Delimiter">;</span> + while <span class="Delimiter">(</span>curr < SIZE<span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// carefully bounds-check on the string</span> + <span class="Comment">// before accessing its raw pointer</span> + ++result<span class="Delimiter">;</span> + curr += tb_utf8_char_length<span class="Delimiter">(</span>in[curr]<span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span> result<span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Includes")</span> +<span class="PreProc">#include</span><span class="Constant">"termbox/termbox.h"</span> <span class="Comment">// for unicode primitives</span> </pre> </body> </html> diff --git a/html/043space.cc.html b/html/043space.cc.html index 6de55942..05e1c8d3 100644 --- a/html/043space.cc.html +++ b/html/043space.cc.html @@ -10,19 +10,19 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.traceAbsent { color: #c00000; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } +.cSpecial { color: #008000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.cSpecial { color: #008000; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -153,7 +153,7 @@ long long int address<span class="Delimiter">(</span>long long int offset<span c <span class="CommentedCode">//? cout << base << '\n'; //? 2</span> if <span class="Delimiter">(</span>offset >= static_cast<long long int><span class="Delimiter">(</span>Memory[base]<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// todo: test</span> - raise << <span class="Constant">"location "</span> << offset << <span class="Constant">" is out of bounds "</span> << Memory[base] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> + raise << <span class="Constant">"location "</span> << offset << <span class="Constant">" is out of bounds "</span> << Memory[base] << <span class="Constant">" at "</span> << base << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Identifier">return</span> base+<span class="Constant">1</span> + offset<span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/044space_surround.cc.html b/html/044space_surround.cc.html index c2b69607..74620675 100644 --- a/html/044space_surround.cc.html +++ b/html/044space_surround.cc.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.Identifier { color: #008080; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> diff --git a/html/045closure_name.cc.html b/html/045closure_name.cc.html index d76f6297..1520e46b 100644 --- a/html/045closure_name.cc.html +++ b/html/045closure_name.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.Identifier { color: #008080; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> diff --git a/html/046tangle.cc.html b/html/046tangle.cc.html index fc8f475a..9604310f 100644 --- a/html/046tangle.cc.html +++ b/html/046tangle.cc.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/047jump_label.cc.html b/html/047jump_label.cc.html index 44a23965..4547dcb2 100644 --- a/html/047jump_label.cc.html +++ b/html/047jump_label.cc.html @@ -10,18 +10,18 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .traceAbsent { color: #c00000; } -.Identifier { color: #008080; } +.cSpecial { color: #008000; } .Constant { color: #008080; } +.traceContains { color: #008000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.cSpecial { color: #008000; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> diff --git a/html/048call_variable.cc.html b/html/048call_variable.cc.html index 286c83c1..6d7bf3b4 100644 --- a/html/048call_variable.cc.html +++ b/html/048call_variable.cc.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.Identifier { color: #008080; } +.traceContains { color: #008000; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> diff --git a/html/049continuation.cc.html b/html/049continuation.cc.html index 2cf647ca..341d6fa9 100644 --- a/html/049continuation.cc.html +++ b/html/049continuation.cc.html @@ -10,18 +10,18 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.traceAbsent { color: #c00000; } -.CommentedCode { color: #6c6c6c; } +.traceContains { color: #008000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } +.CommentedCode { color: #6c6c6c; } --> </style> diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index fa3c0d55..92d38825 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -10,19 +10,19 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } -.traceAbsent { color: #c00000; } .Constant { color: #008080; } +.SalientComment { color: #00ffff; } +.traceAbsent { color: #c00000; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } +.CommentedCode { color: #6c6c6c; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } -.traceContains { color: #008000; } --> </style> @@ -107,15 +107,30 @@ else if <span class="Delimiter">(</span>command == <span class="Constant">" <span class="Delimiter">:(code)</span> scenario parse_scenario<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << "parse scenario\n"; //? 1</span> scenario result<span class="Delimiter">;</span> result<span class="Delimiter">.</span>name = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> - skip_bracket<span class="Delimiter">(</span>in<span class="Delimiter">,</span> <span class="Constant">"'scenario' must begin with '['"</span><span class="Delimiter">);</span> - ostringstream buffer<span class="Delimiter">;</span> - slurp_until_matching_bracket<span class="Delimiter">(</span>in<span class="Delimiter">,</span> buffer<span class="Delimiter">);</span> - result<span class="Delimiter">.</span>to_run = buffer<span class="Delimiter">.</span>str<span class="Delimiter">();</span> + skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + assert<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'['</span><span class="Delimiter">);</span> + <span class="Comment">// scenarios are take special 'code' strings so we need to ignore brackets</span> + <span class="Comment">// inside comments</span> + result<span class="Delimiter">.</span>to_run = slurp_quoted_ignoring_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="Delimiter">:(scenario read_scenario_with_bracket_in_comment)</span> +scenario foo [ + <span class="Comment"># ']' in comment</span> + <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">0</span>:literal +] +<span class="traceContains">+run: 1:number <- copy 0:literal</span> + +<span class="Delimiter">:(scenario read_scenario_with_bracket_in_comment_in_nested_string)</span> +scenario foo [ + <span class="Constant">1</span>:address:array:character<span class="Special"> <- </span>new [<span class="Comment"># not a comment]</span> +] +<span class="traceContains">+run: 1:address:array:character <- new [# not a comment]</span> + <span class="SalientComment">//:: Run scenarios when we run 'mu test'.</span> <span class="Comment">//: Treat the text of the scenario as a regular series of instructions.</span> @@ -124,7 +139,7 @@ time_t mu_time<span class="Delimiter">;</span> time<span class="Delimiter">(</sp cerr << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">Mu tests: "</span> << ctime<span class="Delimiter">(</span>&mu_time<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>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="CommentedCode">//? cerr << Passed << '\n'; //? 1</span> -<span class="CommentedCode">//? cerr << i << ": " << Scenarios.at(i).name << '\n'; //? 3</span> +<span class="CommentedCode">//? cerr << i << ": " << Scenarios.at(i).name << '\n'; //? 5</span> run_mu_scenario<span class="Delimiter">(</span>Scenarios<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> if <span class="Delimiter">(</span>Passed<span class="Delimiter">)</span> cerr << <span class="Constant">"."</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -151,6 +166,7 @@ void run_mu_scenario<span class="Delimiter">(</span>const scenario& s<span c Trace_stream = new trace_stream<span class="Delimiter">;</span> setup<span class="Delimiter">();</span> <span class="Delimiter">}</span> +<span class="CommentedCode">//? cerr << '^' << s.to_run << "$\n"; //? 1</span> run<span class="Delimiter">(</span><span class="Constant">"recipe "</span>+s<span class="Delimiter">.</span>name+<span class="Constant">" [ "</span> + s<span class="Delimiter">.</span>to_run + <span class="Constant">" ]"</span><span class="Delimiter">);</span> if <span class="Delimiter">(</span>not_already_inside_test && Trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span> teardown<span class="Delimiter">();</span> @@ -229,6 +245,7 @@ MEMORY_SHOULD_CONTAIN<span class="Delimiter">,</span> Recipe_number[<span class="Constant">"memory-should-contain"</span>] = MEMORY_SHOULD_CONTAIN<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case MEMORY_SHOULD_CONTAIN: <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="CommentedCode">//? cout << current_instruction().ingredients.at(0).name << '\n'; //? 1</span> check_memory<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -256,11 +273,18 @@ void check_memory<span class="Delimiter">(</span>const string& s<span class= raise << <span class="Constant">"duplicate expectation for location "</span> << address << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> trace<span class="Delimiter">(</span>Primitive_recipe_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"checking location "</span> << address<span class="Delimiter">;</span> if <span class="Delimiter">(</span>Memory[address] != value<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>Current_scenario<span class="Delimiter">)</span> + if <span class="Delimiter">(</span>Current_scenario && !Hide_warnings<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// genuine test in a mu file</span> raise << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": expected location "</span> << address << <span class="Constant">" to contain "</span> << value << <span class="Constant">" but saw "</span> << Memory[address] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> - else + <span class="Delimiter">}</span> + else <span class="Delimiter">{</span> + <span class="Comment">// just testing scenario support</span> raise << <span class="Constant">"expected location "</span> << address << <span class="Constant">" to contain "</span> << value << <span class="Constant">" but saw "</span> << Memory[address] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> - Passed = <span class="Constant">false</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>!Hide_warnings<span class="Delimiter">)</span> <span class="Delimiter">{</span> + Passed = <span class="Constant">false</span><span class="Delimiter">;</span> + ++Num_failures<span class="Delimiter">;</span> + <span class="Delimiter">}</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> locations_checked<span class="Delimiter">.</span>insert<span class="Delimiter">(</span>address<span class="Delimiter">);</span> @@ -303,10 +327,14 @@ void check_string<span class="Delimiter">(</span>long long int address<span clas for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>literal<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span>Primitive_recipe_depth<span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"checking location "</span> << address+i<span class="Delimiter">;</span> if <span class="Delimiter">(</span>Memory[address+i] != literal<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">))</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>Current_scenario && !Hide_warnings<span class="Delimiter">)</span> + if <span class="Delimiter">(</span>Current_scenario && !Hide_warnings<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// genuine test in a mu file</span> raise << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": expected location "</span> << <span class="Delimiter">(</span>address+i<span class="Delimiter">)</span> << <span class="Constant">" to contain "</span> << literal<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> << <span class="Constant">" but saw "</span> << Memory[address+i] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> - else + <span class="Delimiter">}</span> + else <span class="Delimiter">{</span> + <span class="Comment">// just testing scenario support</span> raise << <span class="Constant">"expected location "</span> << <span class="Delimiter">(</span>address+i<span class="Delimiter">)</span> << <span class="Constant">" to contain "</span> << literal<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)</span> << <span class="Constant">" but saw "</span> << Memory[address+i] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!Hide_warnings<span class="Delimiter">)</span> <span class="Delimiter">{</span> Passed = <span class="Constant">false</span><span class="Delimiter">;</span> ++Num_failures<span class="Delimiter">;</span> @@ -380,6 +408,7 @@ TRACE_SHOULD_CONTAIN<span class="Delimiter">,</span> Recipe_number[<span class="Constant">"trace-should-contain"</span>] = TRACE_SHOULD_CONTAIN<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case TRACE_SHOULD_CONTAIN: <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> check_trace<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -470,6 +499,7 @@ TRACE_SHOULD_NOT_CONTAIN<span class="Delimiter">,</span> Recipe_number[<span class="Constant">"trace-should-not-contain"</span>] = TRACE_SHOULD_NOT_CONTAIN<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case TRACE_SHOULD_NOT_CONTAIN: <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> check_trace_missing<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -517,24 +547,45 @@ recipe main [ <span class="Delimiter">:(code)</span> <span class="Comment">// just for the scenarios running scenarios in C++ layers</span> void run_mu_scenario<span class="Delimiter">(</span>const string& form<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << form << '\n'; //? 1</span> istringstream in<span class="Delimiter">(</span>form<span class="Delimiter">);</span> in >> std::noskipws<span class="Delimiter">;</span> + skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> string _scenario = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> -<span class="CommentedCode">//? cout << _scenario << '\n'; //? 1</span> +<span class="CommentedCode">//? cout << _scenario << '\n'; //? 2</span> assert<span class="Delimiter">(</span>_scenario == <span class="Constant">"scenario"</span><span class="Delimiter">);</span> scenario s = parse_scenario<span class="Delimiter">(</span>in<span class="Delimiter">);</span> run_mu_scenario<span class="Delimiter">(</span>s<span class="Delimiter">);</span> <span class="Delimiter">}</span> -void slurp_until_matching_bracket<span class="Delimiter">(</span>istream& in<span class="Delimiter">,</span> ostream& out<span class="Delimiter">)</span> <span class="Delimiter">{</span> - int brace_depth = <span class="Constant">1</span><span class="Delimiter">;</span> <span class="Comment">// just scanned '['</span> +string slurp_quoted_ignoring_comments<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + assert<span class="Delimiter">(</span>in<span class="Delimiter">.</span>get<span class="Delimiter">()</span> == <span class="Constant">'['</span><span class="Delimiter">);</span> <span class="Comment">// drop initial '['</span> char c<span class="Delimiter">;</span> + ostringstream out<span class="Delimiter">;</span> while <span class="Delimiter">(</span>in >> c<span class="Delimiter">)</span> <span class="Delimiter">{</span> - if <span class="Delimiter">(</span>c == <span class="Constant">'['</span><span class="Delimiter">)</span> ++brace_depth<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>c == <span class="Constant">']'</span><span class="Delimiter">)</span> --brace_depth<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>brace_depth == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Comment">// drop final ']'</span> +<span class="CommentedCode">//? cerr << c << '\n'; //? 3</span> + if <span class="Delimiter">(</span>c == <span class="Constant">'#'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// skip comment</span> + in<span class="Delimiter">.</span>putback<span class="Delimiter">(</span>c<span class="Delimiter">);</span> + skip_comment<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>c == <span class="Constant">'['</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// nested strings won't detect comments</span> + <span class="Comment">// can't yet handle scenarios inside strings inside scenarios..</span> + in<span class="Delimiter">.</span>putback<span class="Delimiter">(</span>c<span class="Delimiter">);</span> + out << slurp_quoted<span class="Delimiter">(</span>in<span class="Delimiter">);</span> +<span class="CommentedCode">//? cerr << "snapshot: ^" << out.str() << "$\n"; //? 1</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>c == <span class="Constant">']'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// must be at the outermost level; drop final ']'</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> out << c<span class="Delimiter">;</span> <span class="Delimiter">}</span> +<span class="CommentedCode">//? cerr << "done\n"; //? 2</span> + <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> </pre> </body> diff --git a/html/051scenario_test.mu.html b/html/051scenario_test.mu.html index 46f28e16..4097cb74 100644 --- a/html/051scenario_test.mu.html +++ b/html/051scenario_test.mu.html @@ -10,13 +10,13 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; 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 90a06d40..ee17699c 100644 --- a/html/060string.mu.html +++ b/html/060string.mu.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .CommentedCode { color: #6c6c6c; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } --> </style> @@ -313,6 +313,34 @@ container buffer [ <span class="Identifier">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> + len:number<span class="Special"> <- </span>get in:address:buffer/deref, length:offset +<span class="CommentedCode">#? $print [size ], len:number, [ </span> +<span class="CommentedCode">#? ] #? 1</span> + s:address:array:character<span class="Special"> <- </span>get in:address:buffer/deref, data:offset + <span class="Delimiter">{</span> + <span class="Comment"># propagate null buffer</span> + <span class="Identifier">break-if</span> s:address:array:character + <span class="Identifier">reply</span> <span class="Constant">0:literal</span> + <span class="Delimiter">}</span> + <span class="Comment"># we can't just return s because it is usually the wrong length</span> + result:address:array:character<span class="Special"> <- </span>new character:type, len:number + i:number<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> + <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 + 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="Delimiter">}</span> + <span class="Identifier">reply</span> result:address:array:character +] + <span class="muScenario">scenario</span> integer-to-decimal-digit-zero [ run [ 1:address:array:character/<span class="Special">raw <- </span>integer-to-decimal-string <span class="Constant">0:literal</span> diff --git a/html/061channel.mu.html b/html/061channel.mu.html index 3c27efcb..8860c45b 100644 --- a/html/061channel.mu.html +++ b/html/061channel.mu.html @@ -10,18 +10,18 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .CommentedCode { color: #6c6c6c; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } +.SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } --> </style> diff --git a/html/062array.mu.html b/html/062array.mu.html index 8aa099b6..b1909132 100644 --- a/html/062array.mu.html +++ b/html/062array.mu.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } --> </style> diff --git a/html/063list.mu.html b/html/063list.mu.html index 9c53db7d..87b1b52b 100644 --- a/html/063list.mu.html +++ b/html/063list.mu.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .CommentedCode { color: #6c6c6c; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } --> </style> diff --git a/html/064random.cc.html b/html/064random.cc.html index 7056e553..d2157fda 100644 --- a/html/064random.cc.html +++ b/html/064random.cc.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .Constant { color: #008080; } +.PreProc { color: #c000c0; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.PreProc { color: #c000c0; } -.traceContains { color: #008000; } --> </style> diff --git a/html/070display.cc.html b/html/070display.cc.html index 590d1613..f18bcf20 100644 --- a/html/070display.cc.html +++ b/html/070display.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .cSpecial { color: #008000; } .Constant { color: #008080; } -.Identifier { color: #008080; } +.PreProc { color: #c000c0; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .SalientComment { color: #00ffff; } .CommentedCode { color: #6c6c6c; } -.PreProc { color: #c000c0; } +.Identifier { color: #008080; } --> </style> @@ -105,6 +105,9 @@ case PRINT_CHARACTER_TO_DISPLAY: <span class="Delimiter">{</span> long long int width = <span class="Delimiter">(</span>w >= <span class="Constant">0</span><span class="Delimiter">)</span> ? w : <span class="Constant">0</span><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> long long int c = 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">//? tb_shutdown(); //? 1</span> +<span class="CommentedCode">//? cerr << "AAA " << c << ' ' << (int)'\n' << ' ' << (int)'\r' << '\n'; //? 1</span> +<span class="CommentedCode">//? exit(1); //? 1</span> if <span class="Delimiter">(</span>c == <span class="cSpecial">'\n'</span> || c == <span class="cSpecial">'\r'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>Display_row < height-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> Display_column = <span class="Constant">0</span><span class="Delimiter">;</span> @@ -123,10 +126,13 @@ case PRINT_CHARACTER_TO_DISPLAY: <span class="Delimiter">{</span> <span class="Delimiter">}</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> - int color = TB_WHITE<span class="Delimiter">;</span> + int color = TB_DEFAULT<span class="Delimiter">;</span> if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> > <span class="Constant">1</span><span class="Delimiter">)</span> <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">1</span><span class="Delimiter">)));</span> - color = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + color = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)</span>+<span class="Constant">1</span><span class="Comment">/*</span><span class="Comment">skip default</span><span class="Comment">*/</span><span class="Delimiter">;</span> +<span class="CommentedCode">//? tb_shutdown(); //? 1</span> +<span class="CommentedCode">//? cerr << "AAA " << color << '\n'; //? 1</span> +<span class="CommentedCode">//? exit(1); //? 1</span> <span class="Delimiter">}</span> tb_change_cell<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">,</span> c<span class="Delimiter">,</span> color<span class="Delimiter">,</span> TB_DEFAULT<span class="Delimiter">);</span> if <span class="Delimiter">(</span>Display_column < width-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -236,8 +242,12 @@ case WAIT_FOR_KEY_FROM_KEYBOARD: <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 result = 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>result == 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>result == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> result = TB_KEY_BACKSPACE<span class="Delimiter">;</span> + if <span class="Delimiter">(</span>result == TB_KEY_CARRIAGE_RETURN<span class="Delimiter">)</span> result = TB_KEY_NEWLINE<span class="Delimiter">;</span> products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</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>event<span class="Delimiter">.</span>ch<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>result<span class="Delimiter">);</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/071print.mu.html b/html/071print.mu.html index 06e65a38..736cda4e 100644 --- a/html/071print.mu.html +++ b/html/071print.mu.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } +.muScenario { color: #00af00; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -40,7 +40,12 @@ container screen [ num-columns:number cursor-row:number cursor-column:number - data:address:array:character + data:address:array:screen-cell +] + +container screen-cell [ + contents:character + color:number ] <span class="muRecipe">recipe</span> init-fake-screen [ @@ -55,8 +60,8 @@ container screen [ column:address:number<span class="Special"> <- </span>get-address result:address:screen/deref, cursor-column:offset column:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> bufsize:number<span class="Special"> <- </span>multiply width:address:number/deref, height:address:number/deref - buf:address:address:array:character<span class="Special"> <- </span>get-address result:address:screen/deref, data:offset - buf:address:address:array:character/deref<span class="Special"> <- </span>new character:type, bufsize:number + 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 ] @@ -70,14 +75,17 @@ container screen [ <span class="Delimiter">{</span> <span class="Identifier">break-unless</span> x:address:screen <span class="Comment"># clear fake screen</span> - buf:address:array:character<span class="Special"> <- </span>get x:address:screen/deref, data:offset - max:number<span class="Special"> <- </span>length buf:address:array:character/deref + 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 - c:address:character<span class="Special"> <- </span>index-address buf:address:array:character/deref, i:number - c:address:character/deref<span class="Special"> <- </span>copy <span class="Constant">[ ]</span> + 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="Delimiter">}</span> @@ -97,6 +105,12 @@ container 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> 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="Delimiter">{</span> + <span class="Comment"># default color to white</span> + <span class="Identifier">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> @@ -108,7 +122,7 @@ container screen [ max-row:number<span class="Special"> <- </span>subtract height:number, <span class="Constant">1:literal</span> <span class="Comment"># special-case: newline</span> <span class="Delimiter">{</span> - newline?:boolean<span class="Special"> <- </span>equal c:character, <span class="Constant">10:literal/newlin</span> + 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 @@ -125,8 +139,7 @@ container screen [ <span class="Comment"># save character in fake screen</span> index:number<span class="Special"> <- </span>multiply row:address:number/deref, width:number index:number<span class="Special"> <- </span>add index:number, column:address:number/deref - buf:address:array:character<span class="Special"> <- </span>get x:address:screen/deref, data:offset - cursor:address:character<span class="Special"> <- </span>index-address buf:address:array:character/deref, index:number + buf:address:array:screen-cell<span class="Special"> <- </span>get x:address:screen/deref, data:offset <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> @@ -137,14 +150,22 @@ container screen [ <span class="Identifier">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> - cursor:address:character<span class="Special"> <- </span>subtract cursor:address:character, <span class="Constant">1:literal</span> - cursor:address:character/deref<span class="Special"> <- </span>copy <span class="Constant">32:literal/space</span> + index:number<span class="Special"> <- </span>subtract index:number, <span class="Constant">1:literal</span> + cursor:address:screen-cell<span class="Special"> <- </span>index-address buf:address:array:screen-cell/deref, index:number + cursor-contents:address:character<span class="Special"> <- </span>get-address cursor:address:screen-cell/deref, contents:offset + cursor-color:address:number<span class="Special"> <- </span>get-address cursor:address:screen-cell/deref, color:offset + 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="Delimiter">}</span> <span class="CommentedCode">#? $print [saving character ], c:character, [ to fake screen ], cursor:address/screen, [ </span> <span class="CommentedCode">#? ] #? 1</span> - cursor:address:character/deref<span class="Special"> <- </span>copy c:character + cursor:address:screen-cell<span class="Special"> <- </span>index-address buf:address:array:screen-cell/deref, index:number + cursor-contents:address:character<span class="Special"> <- </span>get-address cursor:address:screen-cell/deref, contents:offset + cursor-color:address:number<span class="Special"> <- </span>get-address cursor:address:screen-cell/deref, color:offset + cursor-contents:address:character/deref<span class="Special"> <- </span>copy c:character + cursor-color:address:number/deref<span class="Special"> <- </span>copy color:number <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 @@ -154,7 +175,7 @@ container screen [ <span class="Identifier">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 + print-character-to-display c:character, color:number <span class="Identifier">reply</span> x:address:screen/same-as-ingredient:0 ] @@ -163,13 +184,29 @@ container screen [ <span class="CommentedCode">#? $start-tracing #? 3</span> 1:address:screen<span class="Special"> <- </span>init-fake-screen <span class="Constant">3:literal/width</span>, <span class="Constant">2:literal/height</span> 1:address:screen<span class="Special"> <- </span>print-character 1:address:screen, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> - 2:address:array:character<span class="Special"> <- </span>get 1:address:screen/deref, data:offset - 3:array:character<span class="Special"> <- </span>copy 2:address:array:character/deref + 2:address:array:screen-cell<span class="Special"> <- </span>get 1:address:screen/deref, data:offset + 3:array:screen-cell<span class="Special"> <- </span>copy 2:address:array:screen-cell/deref + ] + memory-should-contain [ + 3<span class="Special"> <- </span>6 <span class="Comment"># width*height</span> + 4<span class="Special"> <- </span>97 <span class="Comment"># 'a'</span> + 5<span class="Special"> <- </span>7 <span class="Comment"># white</span> + 6<span class="Special"> <- </span>0 + ] +] + +<span class="muScenario">scenario</span> print-character-color [ + run [ + 1:address:screen<span class="Special"> <- </span>init-fake-screen <span class="Constant">3:literal/width</span>, <span class="Constant">2:literal/height</span> + 1:address:screen<span class="Special"> <- </span>print-character 1:address:screen, <span class="Constant">97:literal/a</span>, <span class="Constant">1:literal/red</span> + 2:address:array:screen-cell<span class="Special"> <- </span>get 1:address:screen/deref, data:offset + 3:array:screen-cell<span class="Special"> <- </span>copy 2:address:array:screen-cell/deref ] memory-should-contain [ 3<span class="Special"> <- </span>6 <span class="Comment"># width*height</span> 4<span class="Special"> <- </span>97 <span class="Comment"># 'a'</span> - 5<span class="Special"> <- </span>0 + 5<span class="Special"> <- </span>1 <span class="Comment"># red</span> + 6<span class="Special"> <- </span>0 ] ] @@ -180,14 +217,15 @@ container screen [ 1:address:screen<span class="Special"> <- </span>print-character 1:address:screen, <span class="Constant">97:literal</span> <span class="Comment"># 'a'</span> 1:address:screen<span class="Special"> <- </span>print-character 1:address:screen, <span class="Constant">8:literal</span> <span class="Comment"># backspace</span> 2:number<span class="Special"> <- </span>get 1:address:screen/deref, cursor-column:offset - 3:address:array:character<span class="Special"> <- </span>get 1:address:screen/deref, data:offset - 4:array:character<span class="Special"> <- </span>copy 3:address:array:character/deref + 3:address:array:screen-cell<span class="Special"> <- </span>get 1:address:screen/deref, data:offset + 4:array:screen-cell<span class="Special"> <- </span>copy 3:address:array:screen-cell/deref ] memory-should-contain [ 2<span class="Special"> <- </span>0 <span class="Comment"># cursor column</span> 4<span class="Special"> <- </span>6 <span class="Comment"># width*height</span> 5<span class="Special"> <- </span>32 <span class="Comment"># space, not 'a'</span> - 6<span class="Special"> <- </span>0 + 6<span class="Special"> <- </span>7 <span class="Comment"># white</span> + 7<span class="Special"> <- </span>0 ] ] @@ -199,15 +237,16 @@ container screen [ 1:address:screen<span class="Special"> <- </span>print-character 1:address:screen, <span class="Constant">10:literal/newline</span> 2:number<span class="Special"> <- </span>get 1:address:screen/deref, cursor-row:offset 3:number<span class="Special"> <- </span>get 1:address:screen/deref, cursor-column:offset - 4:address:array:character<span class="Special"> <- </span>get 1:address:screen/deref, data:offset - 5:array:character<span class="Special"> <- </span>copy 4:address:array:character/deref + 4:address:array:screen-cell<span class="Special"> <- </span>get 1:address:screen/deref, data:offset + 5:array:screen-cell<span class="Special"> <- </span>copy 4:address:array:screen-cell/deref ] memory-should-contain [ 2<span class="Special"> <- </span>1 <span class="Comment"># cursor row</span> 3<span class="Special"> <- </span>0 <span class="Comment"># cursor column</span> 5<span class="Special"> <- </span>6 <span class="Comment"># width*height</span> 6<span class="Special"> <- </span>97 <span class="Comment"># 'a'</span> - 7<span class="Special"> <- </span>0 + 7<span class="Special"> <- </span>7 <span class="Comment"># white</span> + 8<span class="Special"> <- </span>0 ] ] @@ -282,18 +321,24 @@ container screen [ 1:address:screen<span class="Special"> <- </span>move-cursor 1:address:screen, <span class="Constant">0:literal/row</span>, <span class="Constant">0:literal/column</span> <span class="Comment"># clear line</span> 1:address:screen<span class="Special"> <- </span>clear-line 1:address:screen - 2:address:array:character<span class="Special"> <- </span>get 1:address:screen/deref, data:offset - 3:array:character<span class="Special"> <- </span>copy 2:address:array:character/deref + 2:address:array:screen-cell<span class="Special"> <- </span>get 1:address:screen/deref, data:offset + 3:array:screen-cell<span class="Special"> <- </span>copy 2:address:array:screen-cell/deref ] <span class="Comment"># screen should be blank</span> memory-should-contain [ 3<span class="Special"> <- </span>6 <span class="Comment"># width*height</span> 4<span class="Special"> <- </span>0 - 5<span class="Special"> <- </span>0 + 5<span class="Special"> <- </span>7 6<span class="Special"> <- </span>0 - 7<span class="Special"> <- </span>0 + 7<span class="Special"> <- </span>7 8<span class="Special"> <- </span>0 - 9<span class="Special"> <- </span>0 + 9<span class="Special"> <- </span>7 + 10<span class="Special"> <- </span>0 + 11<span class="Special"> <- </span>7 + 12<span class="Special"> <- </span>0 + 13<span class="Special"> <- </span>7 + 14<span class="Special"> <- </span>0 + 15<span class="Special"> <- </span>7 ] ] diff --git a/html/072scenario_screen.cc.html b/html/072scenario_screen.cc.html index ecf37ed3..093a0173 100644 --- a/html/072scenario_screen.cc.html +++ b/html/072scenario_screen.cc.html @@ -10,17 +10,17 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } +.traceContains { color: #008000; } .cSpecial { color: #008000; } -.Identifier { color: #008080; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } -.traceContains { color: #008000; } +.Identifier { color: #008080; } --> </style> @@ -35,12 +35,13 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } <span class="Comment">//: Clean syntax to manipulate and check the screen in scenarios.</span> <span class="Comment">//: Instructions 'assume-screen' and 'screen-should-contain' implicitly create</span> <span class="Comment">//: a variable called 'screen' that is accessible inside other 'run'</span> -<span class="Comment">//: instructions in the scenario.</span> +<span class="Comment">//: instructions in the scenario. 'screen-should-contain' can check unicode</span> +<span class="Comment">//: characters in the fake screen</span> <span class="Delimiter">:(scenarios run_mu_scenario)</span> <span class="Delimiter">:(scenario screen_in_scenario)</span> scenario screen-in-scenario [ -<span class="CommentedCode">#? $start-tracing</span> +<span class="CommentedCode">#? $start-tracing #? 2</span> assume-screen <span class="Constant">5</span>:literal/width<span class="Delimiter">,</span> <span class="Constant">3</span>:literal/height run [ screen:address<span class="Special"> <- </span>print-character screen:address<span class="Delimiter">,</span> <span class="Constant">97</span>:literal <span class="Comment"># 'a'</span> @@ -51,18 +52,51 @@ scenario screen-in-scenario [ <span class="Delimiter">.</span> <span class="Delimiter">.</span> <span class="Delimiter">.</span> <span class="Delimiter">.</span> ] -<span class="CommentedCode">#? $exit</span> +<span class="CommentedCode">#? $exit #? 1</span> ] <span class="Delimiter">:(scenario screen_in_scenario_unicode)</span> +scenario screen-in-scenario-unicode-color [ + assume-screen <span class="Constant">5</span>:literal/width<span class="Delimiter">,</span> <span class="Constant">3</span>:literal/height + run [ + screen:address<span class="Special"> <- </span>print-character screen:address<span class="Delimiter">,</span> <span class="Constant">955</span>:literal/greek-small-lambda<span class="Delimiter">,</span> <span class="Constant">1</span>:literal/red + screen:address<span class="Special"> <- </span>print-character screen:address<span class="Delimiter">,</span> <span class="Constant">97</span>:literal/a + ] + screen-should-contain [ + <span class="Comment"># 01234</span> + <span class="Delimiter">.</span>λa <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + ] +<span class="CommentedCode">#? $exit</span> +] + +<span class="Delimiter">:(scenario screen_in_scenario_color)</span> <span class="Comment"># screen-should-contain can check unicode characters in the fake screen</span> -scenario screen-in-scenario [ +scenario screen-in-scenario-color [ assume-screen <span class="Constant">5</span>:literal/width<span class="Delimiter">,</span> <span class="Constant">3</span>:literal/height run [ - screen:address<span class="Special"> <- </span>print-character screen:address<span class="Delimiter">,</span> <span class="Constant">955</span>:literal <span class="Comment"># 'λ'</span> + screen:address<span class="Special"> <- </span>print-character screen:address<span class="Delimiter">,</span> <span class="Constant">955</span>:literal/greek-small-lambda<span class="Delimiter">,</span> <span class="Constant">1</span>:literal/red + screen:address<span class="Special"> <- </span>print-character screen:address<span class="Delimiter">,</span> <span class="Constant">97</span>:literal/a<span class="Delimiter">,</span> <span class="Constant">7</span>:literal/white ] + <span class="Comment"># screen-should-contain shows everything</span> screen-should-contain [ <span class="Comment"># 01234</span> + <span class="Delimiter">.</span>λa <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + ] + <span class="Comment"># screen-should-contain-in-color filters out everything except the given</span> + <span class="Comment"># color, all you see is the 'a' in white.</span> + screen-should-contain-in-color <span class="Constant">7</span>:literal/white<span class="Delimiter">,</span> [ + <span class="Comment"># 01234</span> + <span class="Delimiter">.</span> a <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + ] + <span class="Comment"># ..and the λ in red.</span> + screen-should-contain-in-color <span class="Constant">1</span>:literal/red<span class="Delimiter">,</span> [ + <span class="Comment"># 01234</span> <span class="Delimiter">.</span>λ <span class="Delimiter">.</span> <span class="Delimiter">.</span> <span class="Delimiter">.</span> <span class="Delimiter">.</span> <span class="Delimiter">.</span> @@ -71,7 +105,6 @@ scenario screen-in-scenario [ ] <span class="Delimiter">:(scenario screen_in_scenario_error)</span> -<span class="CommentedCode">#? % cerr << "AAA\n";</span> <span class="Special">% Hide_warnings = true;</span> scenario screen-in-scenario-error [ assume-screen <span class="Constant">5</span>:literal/width<span class="Delimiter">,</span> <span class="Constant">3</span>:literal/height @@ -87,6 +120,23 @@ scenario screen-in-scenario-error [ ] <span class="traceContains">+warn: expected screen location (0, 0) to contain 98 ('b') instead of 97 ('a')</span> +<span class="Delimiter">:(scenario screen_in_scenario_color_error)</span> +<span class="Special">% Hide_warnings = true;</span> +<span class="Comment"># screen-should-contain can check unicode characters in the fake screen</span> +scenario screen-in-scenario-color [ + assume-screen <span class="Constant">5</span>:literal/width<span class="Delimiter">,</span> <span class="Constant">3</span>:literal/height + run [ + screen:address<span class="Special"> <- </span>print-character screen:address<span class="Delimiter">,</span> <span class="Constant">97</span>:literal/a<span class="Delimiter">,</span> <span class="Constant">1</span>:literal/red + ] + screen-should-contain-in-color <span class="Constant">2</span>:literal/green<span class="Delimiter">,</span> [ + <span class="Comment"># 01234</span> + <span class="Delimiter">.</span>a <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + <span class="Delimiter">.</span> <span class="Delimiter">.</span> + ] +] +<span class="traceContains">+warn: expected screen location (0, 0) to be in color 2 instead of 1</span> + <span class="Comment">//: allow naming just for 'screen'</span> <span class="Delimiter">:(before "End is_special_name Cases")</span> if <span class="Delimiter">(</span>s == <span class="Constant">"screen"</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> @@ -132,8 +182,20 @@ SCREEN_SHOULD_CONTAIN<span class="Delimiter">,</span> Recipe_number[<span class="Constant">"screen-should-contain"</span>] = SCREEN_SHOULD_CONTAIN<span class="Delimiter">;</span> <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> case SCREEN_SHOULD_CONTAIN: <span class="Delimiter">{</span> -<span class="CommentedCode">//? cout << "AAA\n"; //? 1</span> - check_screen<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + check_screen<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>name<span class="Delimiter">,</span> -<span class="Constant">1</span><span class="Delimiter">);</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +SCREEN_SHOULD_CONTAIN_IN_COLOR<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +Recipe_number[<span class="Constant">"screen-should-contain-in-color"</span>] = SCREEN_SHOULD_CONTAIN_IN_COLOR<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case SCREEN_SHOULD_CONTAIN_IN_COLOR: <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>!Passed<span class="Delimiter">)</span> <span class="Identifier">break</span><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> + check_screen<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>name<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="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> @@ -152,8 +214,8 @@ struct raw_string_stream <span class="Delimiter">{</span> <span class="Delimiter">};</span> <span class="Delimiter">:(code)</span> -void check_screen<span class="Delimiter">(</span>const string& expected_contents<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span class="CommentedCode">//? cerr << "Checking screen\n"; //? 1</span> +void check_screen<span class="Delimiter">(</span>const string& expected_contents<span class="Delimiter">,</span> const int color<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="CommentedCode">//? cerr << "Checking screen for color " << color << "\n"; //? 2</span> assert<span class="Delimiter">(</span>!Current_routine<span class="Delimiter">-></span>calls<span class="Delimiter">.</span>front<span class="Delimiter">().</span>default_space<span class="Delimiter">);</span> <span class="Comment">// not supported</span> long long int screen_location = Memory[SCREEN]<span class="Delimiter">;</span> int data_offset = find_element_name<span class="Delimiter">(</span>Type_number[<span class="Constant">"screen"</span>]<span class="Delimiter">,</span> <span class="Constant">"data"</span><span class="Delimiter">);</span> @@ -171,26 +233,49 @@ void check_screen<span class="Delimiter">(</span>const string& expected_cont cursor<span class="Delimiter">.</span>skip_whitespace_and_comments<span class="Delimiter">();</span> if <span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>at_end<span class="Delimiter">())</span> <span class="Identifier">break</span><span class="Delimiter">;</span> assert<span class="Delimiter">(</span>cursor<span class="Delimiter">.</span>get<span class="Delimiter">()</span> == <span class="Constant">'.'</span><span class="Delimiter">);</span> - for <span class="Delimiter">(</span>long long int column = <span class="Constant">0</span><span class="Delimiter">;</span> column < screen_width<span class="Delimiter">;</span> ++column<span class="Delimiter">,</span> ++addr<span class="Delimiter">)</span> <span class="Delimiter">{</span> + for <span class="Delimiter">(</span>long long int column = <span class="Constant">0</span><span class="Delimiter">;</span> column < screen_width<span class="Delimiter">;</span> ++column<span class="Delimiter">,</span> addr+= <span class="Comment">/*</span><span class="Comment">size of screen-cell</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + const int cell_color_offset = <span class="Constant">1</span><span class="Delimiter">;</span> uint32_t curr = cursor<span class="Delimiter">.</span>get<span class="Delimiter">();</span> if <span class="Delimiter">(</span>Memory[addr] == <span class="Constant">0</span> && isspace<span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - if <span class="Delimiter">(</span>Memory[addr] != <span class="Constant">0</span> && Memory[addr] == curr<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> - <span class="Comment">// mismatch</span> +<span class="CommentedCode">//? cerr << color << " vs " << Memory[addr+1] << '\n'; //? 1</span> + if <span class="Delimiter">(</span>curr == <span class="Constant">' '</span> && color != -<span class="Constant">1</span> && color != Memory[addr+cell_color_offset]<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// filter out other colors</span> + <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>Memory[addr] != <span class="Constant">0</span> && Memory[addr] == curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>color == -<span class="Constant">1</span> || color == Memory[addr+cell_color_offset]<span class="Delimiter">)</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> + <span class="Comment">// contents match but color is off</span> + if <span class="Delimiter">(</span>Current_scenario && !Hide_warnings<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Comment">// genuine test in a mu file</span> + raise << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": expected screen location ("</span> << row << <span class="Constant">", "</span> << column << <span class="Constant">", address "</span> << addr << <span class="Constant">", value "</span> << Memory[addr] << <span class="Constant">") to be in color "</span> << color << <span class="Constant">" instead of "</span> << Memory[addr+cell_color_offset] << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + else <span class="Delimiter">{</span> + <span class="Comment">// just testing check_screen</span> + raise << <span class="Constant">"expected screen location ("</span> << row << <span class="Constant">", "</span> << column << <span class="Constant">") to be in color "</span> << color << <span class="Constant">" instead of "</span> << Memory[addr+cell_color_offset] << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + if <span class="Delimiter">(</span>!Hide_warnings<span class="Delimiter">)</span> <span class="Delimiter">{</span> + Passed = <span class="Constant">false</span><span class="Delimiter">;</span> + ++Num_failures<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + + <span class="Comment">// really a mismatch</span> <span class="Comment">// can't print multi-byte unicode characters in warnings just yet. not very useful for debugging anyway.</span> char expected_pretty[<span class="Constant">10</span>] = <span class="Delimiter">{</span><span class="Constant">0</span><span class="Delimiter">};</span> - if <span class="Delimiter">(</span>curr < <span class="Constant">256</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>curr < <span class="Constant">256</span> && !iscntrl<span class="Delimiter">(</span>curr<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// " ('<curr>')"</span> expected_pretty[<span class="Constant">0</span>] = <span class="Constant">' '</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">1</span>] = <span class="Constant">'('</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">2</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">3</span>] = static_cast<unsigned char><span class="Delimiter">(</span>curr<span class="Delimiter">),</span> expected_pretty[<span class="Constant">4</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">5</span>] = <span class="Constant">')'</span><span class="Delimiter">,</span> expected_pretty[<span class="Constant">6</span>] = <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> char actual_pretty[<span class="Constant">10</span>] = <span class="Delimiter">{</span><span class="Constant">0</span><span class="Delimiter">};</span> - if <span class="Delimiter">(</span>Memory[addr] < <span class="Constant">256</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Memory[addr] < <span class="Constant">256</span> && !iscntrl<span class="Delimiter">(</span>Memory[addr]<span class="Delimiter">))</span> <span class="Delimiter">{</span> <span class="Comment">// " ('<curr>')"</span> actual_pretty[<span class="Constant">0</span>] = <span class="Constant">' '</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">1</span>] = <span class="Constant">'('</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">2</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">3</span>] = static_cast<unsigned char><span class="Delimiter">(</span>Memory[addr]<span class="Delimiter">),</span> actual_pretty[<span class="Constant">4</span>] = <span class="cSpecial">'\''</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">5</span>] = <span class="Constant">')'</span><span class="Delimiter">,</span> actual_pretty[<span class="Constant">6</span>] = <span class="cSpecial">'\0'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>Current_scenario && !Hide_warnings<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// genuine test in a mu file</span> - raise << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": expected screen location ("</span> << row << <span class="Constant">", "</span> << column << <span class="Constant">") to contain "</span> << curr << expected_pretty << <span class="Constant">" instead of "</span> << Memory[addr] << actual_pretty << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span><span class="Delimiter">;</span> + raise << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": expected screen location ("</span> << row << <span class="Constant">", "</span> << column << <span class="Constant">") to contain "</span> << curr << expected_pretty << <span class="Constant">" instead of "</span> << Memory[addr] << actual_pretty << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> dump_screen<span class="Delimiter">();</span> <span class="Delimiter">}</span> else <span class="Delimiter">{</span> @@ -278,7 +363,7 @@ void dump_screen<span class="Delimiter">()</span> <span class="Delimiter">{</spa <span class="CommentedCode">//? cerr << curr << ":\n"; //? 1</span> for <span class="Delimiter">(</span>long long int col = <span class="Constant">0</span><span class="Delimiter">;</span> col < screen_width<span class="Delimiter">;</span> ++col<span class="Delimiter">)</span> <span class="Delimiter">{</span> cerr << static_cast<char><span class="Delimiter">(</span>Memory[curr]<span class="Delimiter">);</span> - ++curr<span class="Delimiter">;</span> + curr += <span class="Comment">/*</span><span class="Comment">size of screen-cell</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> cerr << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> diff --git a/html/073scenario_screen_test.mu.html b/html/073scenario_screen_test.mu.html index 6422dd59..8df66f7b 100644 --- a/html/073scenario_screen_test.mu.html +++ b/html/073scenario_screen_test.mu.html @@ -10,13 +10,13 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; 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 558c8d16..dc0ab783 100644 --- a/html/074keyboard.mu.html +++ b/html/074keyboard.mu.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.CommentedCode { color: #6c6c6c; } -.muRecipe { color: #ff8700; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -80,7 +80,7 @@ container keyboard <span class="Constant">[ # can't think of another word like <span class="Delimiter">{</span> <span class="Identifier">break-unless</span> x:address:keyboard <span class="Comment"># on fake keyboards 'wait-for-key' behaves just like 'read-key'</span> - c:character, x:address:keyboard<span class="Special"> <- </span>read-key x:address:keyboard + 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="Delimiter">}</span> c:character<span class="Special"> <- </span>wait-for-key-from-keyboard @@ -93,7 +93,7 @@ container keyboard <span class="Constant">[ # can't think of another word like 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="Delimiter">{</span> - c:character, found?:boolean<span class="Special"> <- </span>read-key keyboard:address + c:character, found?:boolean, keyboard:address<span class="Special"> <- </span>read-key keyboard:address <span class="Identifier">loop-unless</span> found?:boolean <span class="CommentedCode">#? print-integer screen:address, c:character #? 1</span> print-character screen:address, c:character diff --git a/html/075scenario_keyboard.cc.html b/html/075scenario_keyboard.cc.html index dc14321b..9ebee7a4 100644 --- a/html/075scenario_keyboard.cc.html +++ b/html/075scenario_keyboard.cc.html @@ -10,14 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -32,7 +33,8 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } <span class="Comment">//: Clean syntax to manipulate and check the keyboard in scenarios.</span> <span class="Comment">//: Instruction 'assume-keyboard' implicitly creates a variable called</span> <span class="Comment">//: 'keyboard' that is accessible inside other 'run' instructions in the</span> -<span class="Comment">//: scenario.</span> +<span class="Comment">//: scenario. Like with the fake screen, 'assume-keyboard' transparently</span> +<span class="Comment">//: supports unicode.</span> <span class="Delimiter">:(scenarios run_mu_scenario)</span> <span class="Delimiter">:(scenario keyboard_in_scenario)</span> @@ -89,6 +91,28 @@ if <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == < curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">"keyboard:address"</span><span class="Delimiter">));</span> curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>set_value<span class="Delimiter">(</span>KEYBOARD<span class="Delimiter">);</span> <span class="Delimiter">}</span> + +<span class="Comment">//: Since we don't yet have a clean way to represent characters like backspace</span> +<span class="Comment">//: in literal strings we can't easily pretend they were typed into the fake</span> +<span class="Comment">//: keyboard. So we'll use special unicode characters in the literal and then</span> +<span class="Comment">//: manually replace them with backspace.</span> +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +REPLACE_IN_KEYBOARD<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +Recipe_number[<span class="Constant">"replace-in-keyboard"</span>] = REPLACE_IN_KEYBOARD<span class="Delimiter">;</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +case REPLACE_IN_KEYBOARD: <span class="Delimiter">{</span> + long long int size = Memory[KEYBOARD]<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> + assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)));</span> + for <span class="Delimiter">(</span>long long int curr = KEYBOARD+<span class="Constant">1</span><span class="Delimiter">;</span> curr <= KEYBOARD+size<span class="Delimiter">;</span> ++curr<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Memory[curr] == 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="Delimiter">{</span> +<span class="CommentedCode">//? cerr << "replacing\n"; //? 1</span> + Memory[curr] = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> + <span class="Delimiter">}</span> + <span class="Delimiter">}</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/076scenario_keyboard_test.mu.html b/html/076scenario_keyboard_test.mu.html index 974b9ff8..cb73c7ac 100644 --- a/html/076scenario_keyboard_test.mu.html +++ b/html/076scenario_keyboard_test.mu.html @@ -10,13 +10,13 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; 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/077trace_browser.cc.html b/html/077trace_browser.cc.html index 567371cc..d600ef8b 100644 --- a/html/077trace_browser.cc.html +++ b/html/077trace_browser.cc.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .cSpecial { color: #008000; } -.CommentedCode { color: #6c6c6c; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Identifier { color: #008080; } +.CommentedCode { color: #6c6c6c; } --> </style> @@ -103,10 +103,9 @@ void start_trace_browser<span class="Delimiter">()</span> <span class="Delimiter <span class="Delimiter">}</span> if <span class="Delimiter">(</span>key == <span class="Constant">'K'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// page-up is more convoluted</span> - int max = tb_height<span class="Delimiter">();</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 = max<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> + 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> @@ -117,6 +116,20 @@ void start_trace_browser<span class="Delimiter">()</span> <span class="Delimiter 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> diff --git a/html/999spaces.cc.html b/html/999spaces.cc.html index 4e3fe2f2..99c38f35 100644 --- a/html/999spaces.cc.html +++ b/html/999spaces.cc.html @@ -10,8 +10,8 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } .Constant { color: #008080; } .Comment { color: #8080ff; } diff --git a/html/callcc.mu.html b/html/callcc.mu.html index 32aec54d..50037f46 100644 --- a/html/callcc.mu.html +++ b/html/callcc.mu.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } --> </style> @@ -33,7 +33,7 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } <span class="muRecipe">recipe</span> main [ c:continuation<span class="Special"> <- </span>f - continue-from c:continuation <span class="Comment"># <-- ..when you hit this</span> + <span class="Identifier">continue-from</span> c:continuation <span class="Comment"># <-- ..when you hit this</span> ] <span class="muRecipe">recipe</span> f [ @@ -42,7 +42,7 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } ] <span class="muRecipe">recipe</span> g [ - c:continuation<span class="Special"> <- </span>current-continuation <span class="Comment"># <-- loop back to here</span> + 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> ] diff --git a/html/channel.mu.html b/html/channel.mu.html index 2460211d..e6d5a456 100644 --- a/html/channel.mu.html +++ b/html/channel.mu.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } --> </style> diff --git a/html/chessboard.mu.html b/html/chessboard.mu.html index 6602d663..457df812 100644 --- a/html/chessboard.mu.html +++ b/html/chessboard.mu.html @@ -10,18 +10,18 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } .CommentedCode { color: #6c6c6c; } .Delimiter { color: #c000c0; } +.SalientComment { color: #00ffff; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } -.SalientComment { color: #00ffff; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } --> </style> @@ -223,8 +223,8 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } done?:boolean<span class="Special"> <- </span>equal col:number, <span class="Constant">8:literal</span> <span class="Identifier">break-if</span> done?:boolean f:address:array:character<span class="Special"> <- </span>index board:address:array:address:array:character/deref, col:number - s:character<span class="Special"> <- </span>index f:address:array:character/deref, row:number - print-character screen:address, s:character + 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> @@ -318,7 +318,7 @@ container move [ <span class="Identifier">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 <span class="Constant">move:literal</span> + result:address:move<span class="Special"> <- </span>new move:type x:address:number<span class="Special"> <- </span>get-address result:address:move/deref, from-file:offset 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 @@ -701,7 +701,6 @@ F read-move-file: routine failed to pause <span class="muRecipe">after</span> co <span class="Constant"> . +---------------- .</span> <span class="Constant"> . a b c d e f g h .</span> <span class="Constant"> . .</span> - <span class="Constant"> . .</span> ] ] </pre> diff --git a/html/counters.mu.html b/html/counters.mu.html index 2baae9e4..5b762232 100644 --- a/html/counters.mu.html +++ b/html/counters.mu.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } --> </style> diff --git a/html/display.mu.html b/html/display.mu.html index 01b8d90f..253d9eba 100644 --- a/html/display.mu.html +++ b/html/display.mu.html @@ -10,13 +10,13 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } +.muRecipe { color: #ff8700; } --> </style> diff --git a/html/factorial.mu.html b/html/factorial.mu.html index c7c7723b..d8d58b93 100644 --- a/html/factorial.mu.html +++ b/html/factorial.mu.html @@ -10,16 +10,16 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } -.muScenario { color: #00af00; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } --> </style> diff --git a/html/fork.mu.html b/html/fork.mu.html index 414dfd3d..1dbd922c 100644 --- a/html/fork.mu.html +++ b/html/fork.mu.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } --> </style> diff --git a/html/keyboard.mu.html b/html/keyboard.mu.html index ac1d9a87..5b700513 100644 --- a/html/keyboard.mu.html +++ b/html/keyboard.mu.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Constant { color: #008080; } .Comment { color: #8080ff; } .Delimiter { color: #c000c0; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } --> </style> diff --git a/html/repl.mu.html b/html/repl.mu.html new file mode 100644 index 00000000..807e9308 --- /dev/null +++ b/html/repl.mu.html @@ -0,0 +1,606 @@ +<!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 - repl.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: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } +* { font-size: 1em; } +.CommentedCode { color: #6c6c6c; } +.Delimiter { color: #c000c0; } +.Comment { color: #8080ff; } +.Constant { color: #008080; } +.Special { color: #ff6060; } +.Identifier { color: #008080; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } +--> +</style> + +<script type='text/javascript'> +<!-- + +--> +</script> +</head> +<body> +<pre id='vimCodeElement'> +<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> + 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> + <span class="Constant">0:literal/real-screen</span><span class="Special"> <- </span>print-string <span class="Constant">0:literal/real-screen</span>, msg:address:array:character + <span class="Delimiter">{</span> + inst:address:array:character, <span class="Constant">0:literal/real-keyboard</span>, <span class="Constant">0:literal/real-screen</span><span class="Special"> <- </span>read-instruction <span class="Constant">0:literal/real-keyboard</span>, <span class="Constant">0:literal/real-screen</span> + <span class="Identifier">break-unless</span> inst:address:array:character + <span class="Constant">0:literal/real-screen</span><span class="Special"> <- </span>print-string <span class="Constant">0:literal/real-screen</span>, inst:address:array:character + <span class="Identifier">loop</span> + <span class="Delimiter">}</span> + return-to-console +] + +<span class="Comment"># basic keyboard input; just text and enter</span> +<span class="muScenario">scenario</span> read-instruction1 [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[x <- copy y</span> +<span class="Constant">]</span> + run [ + 1:address:array:character<span class="Special"> <- </span>read-instruction keyboard:address, screen:address + 2:address:array:character<span class="Special"> <- </span>new <span class="Constant">[=> ]</span> + print-string screen:address, 2:address:array:character + print-string screen:address, 1:address:array:character + ] + screen-should-contain [ + <span class="Constant"> .x <- copy y .</span> + <span class="Constant"> .=> x <- copy y .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .x <- copy y .</span> + <span class="Constant"> .=> x <- copy y .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="Comment"># Read characters as they're typed at the keyboard, print them to the screen,</span> +<span class="Comment"># accumulate them in a string, return the string at the end.</span> +<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> + 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> + <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="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 + trace <span class="Constant">[error]</span>, <span class="Constant">[slurp-regular-characters should never return normally]</span> + <span class="Identifier"> +completed</span> + result2:address:array:character<span class="Special"> <- </span>buffer-to-array result:address:buffer + 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="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">60: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> + 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="Delimiter">{</span> + <span class="Identifier"> +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 + 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="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 + 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="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 + 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="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 + 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="Delimiter">}</span> + <span class="Comment"># print</span> + print-character x:address:screen, c:character <span class="Comment"># default color</span> + <span class="Comment"># append</span> + result:address:buffer<span class="Special"> <- </span>buffer-append result:address:buffer, c:character + <span class="Comment"># backspace? decrement and maybe 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 + characters-slurped:number<span class="Special"> <- </span>subtract characters-slurped:number, <span class="Constant">1:literal</span> + <span class="Delimiter">{</span> + done?:boolean<span class="Special"> <- </span>lesser-or-equal characters-slurped:number, <span class="Constant">0:literal</span> + <span class="Identifier">break-unless</span> done?:boolean + trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters: 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="Delimiter">}</span> + <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <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="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="Comment"># read characters from keyboard, print them to screen in the comment color.</span> +<span class="Comment">#</span> +<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">60: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> + 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="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 + 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="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 + 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="Delimiter">}</span> + <span class="Comment"># print</span> + print-character x:address:screen, c:character, <span class="Constant">4:literal/blue</span> + <span class="Comment"># append</span> + result:address:buffer<span class="Special"> <- </span>buffer-append result:address:buffer, c:character + <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 + 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 + 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="Delimiter">}</span> + <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <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="Delimiter">}</span> + trace <span class="Constant">[app]</span>, <span class="Constant">[slurp-regular-characters: newline encountered; 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="Comment"># read characters from keyboard, print them to screen in the string color and</span> +<span class="Comment"># accumulate them into a buffer.</span> +<span class="Comment">#</span> +<span class="Comment"># Version of slurp-regular-characters that:</span> +<span class="Comment"># a) doesn't handle comments</span> +<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">60: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> + 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="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 + 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="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 + 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="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 + 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 + <span class="Comment"># make a recursive call to handle nested strings</span> + 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="Delimiter">}</span> + <span class="Comment"># print</span> + print-character x:address:screen, c:character, <span class="Constant">6:literal/cyan</span> + <span class="Comment"># append</span> + result:address:buffer<span class="Special"> <- </span>buffer-append result:address:buffer, c:character + <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 + 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 + 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="Delimiter">}</span> + <span class="Identifier">loop</span><span class="Identifier"> +next-character</span>:label + <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="Delimiter">}</span> + <span class="Delimiter">{</span> + <span class="Identifier">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="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="muScenario">scenario</span> read-instruction-color-comment [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[# comment</span> +<span class="Constant">]</span> + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain-in-color <span class="Constant">4:literal/blue</span>, [ + <span class="Constant"> .# comment .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-cancel-comment-on-backspace [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[#a««z</span> +<span class="Constant">]</span> + replace-in-keyboard <span class="Constant">171:literal/«</span>, <span class="Constant">8:literal/backspace</span> + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain-in-color <span class="Constant">4:literal/blue</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .z .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-cancel-comment-on-backspace2 [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[#ab«««z</span> +<span class="Constant">]</span> + replace-in-keyboard <span class="Constant">171:literal/«</span>, <span class="Constant">8:literal/backspace</span> + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain-in-color <span class="Constant">4:literal/blue</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .z .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-cancel-comment-on-backspace3 [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[#a«z</span> +<span class="Constant">]</span> + replace-in-keyboard <span class="Constant">171:literal/«</span>, <span class="Constant">8:literal/backspace</span> + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain-in-color <span class="Constant">4:literal/blue</span>, [ + <span class="Constant"> .#z .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-color-string [ +<span class="CommentedCode">#? $start-tracing #? 1</span> + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[abc [string]</span> +] + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain [ + <span class="Constant"> .abc [string] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> . [string] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .abc .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-color-string-multiline [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[abc [line1</span> +<span class="Constant">line2]</span> +] + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain [ + <span class="Constant"> .abc [line1 .</span> + <span class="Constant"> .line2] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> . [line1 .</span> + <span class="Constant"> .line2] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .abc .</span> + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-color-string-and-comment [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[abc [string]</span> <span class="Comment"># comment</span> +] + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain [ + <span class="Constant"> .abc [string] # comment .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">4:literal/blue</span>, [ + <span class="Constant"> . # comment .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> . [string] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .abc .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-ignore-comment-inside-string [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[abc [string # not a comment]</span> +] + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain [ + <span class="Constant"> .abc [string # not a comment] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> . [string # not a comment] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .abc .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">4:literal/blue</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-ignore-string-inside-comment [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[abc # comment [not a string]</span> +] + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain [ + <span class="Constant"> .abc # comment [not a string] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .abc .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">4:literal/blue</span>, [ + <span class="Constant"> . # comment [not a string] .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-color-string-inside-string [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[abc [string [inner string]</span>] +] + run [ +<span class="CommentedCode">#? $start-tracing #? 1</span> + read-instruction keyboard:address, screen:address +<span class="CommentedCode">#? $stop-tracing #? 1</span> +<span class="CommentedCode">#? $browse-trace #? 1</span> + ] + screen-should-contain [ + <span class="Constant"> .abc [string [inner string]] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> . [string [inner string]] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .abc .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-cancel-string-on-backspace [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + <span class="Comment"># need to escape the '[' once for 'scenario' and once for 'assume-keyboard'</span> + assume-keyboard <span class="Constant">[\\\[a««z</span> +<span class="Constant">]</span> + replace-in-keyboard <span class="Constant">171:literal/«</span>, <span class="Constant">8:literal/backspace</span> + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> .z .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-cancel-string-inside-string-on-backspace [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + assume-keyboard <span class="Constant">[[a[b]</span>«««b] +] + replace-in-keyboard <span class="Constant">171:literal/«</span>, <span class="Constant">8:literal/backspace</span> + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> .[ab] .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] +] + +<span class="muScenario">scenario</span> read-instruction-backspace-back-into-string [ + assume-screen <span class="Constant">30:literal/width</span>, <span class="Constant">5:literal/height</span> + <span class="Comment"># need to escape the '[' once for 'scenario' and once for 'assume-keyboard'</span> + assume-keyboard <span class="Constant">[[a]</span>«b +] + replace-in-keyboard <span class="Constant">171:literal/«</span>, <span class="Constant">8:literal/backspace</span> + run [ + read-instruction keyboard:address, screen:address + ] + screen-should-contain [ + <span class="Constant"> .\\\[ab .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">6:literal/cyan</span>, [ + <span class="Constant"> .\\\[ab .</span> + <span class="Constant"> . .</span> + ] + screen-should-contain-in-color <span class="Constant">7:literal/white</span>, [ + <span class="Constant"> . .</span> + <span class="Constant"> . .</span> + ] + <span class="Comment"># todo: trace sequence of events</span> + <span class="Comment"># slurp-regular-characters: [</span> + <span class="Comment"># slurp-regular-characters/slurp-string: a</span> + <span class="Comment"># slurp-regular-characters/slurp-string: ]</span> + <span class="Comment"># slurp-regular-characters/slurp-string/slurp-regular-characters: backspace</span> + <span class="Comment"># slurp-regular-characters/slurp-string: b</span> +] +</pre> +</body> +</html> +<!-- vim: set foldmethod=manual : --> diff --git a/html/screen.mu.html b/html/screen.mu.html index e893b214..9956cfa3 100644 --- a/html/screen.mu.html +++ b/html/screen.mu.html @@ -10,13 +10,13 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } +.muRecipe { color: #ff8700; } --> </style> @@ -35,7 +35,7 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } <span class="muRecipe">recipe</span> main [ switch-to-display - print-character <span class="Constant">0:literal/screen</span>, <span class="Constant">97:literal</span> + print-character <span class="Constant">0:literal/screen</span>, <span class="Constant">97:literal</span>, <span class="Constant">2:literal/red</span> 1:number/<span class="Special">raw</span>, 2:number/<span class="Special">raw <- </span>cursor-position <span class="Constant">0:literal/screen</span> wait-for-key <span class="Constant">0:literal/keyboard</span> clear-screen <span class="Constant">0:literal/screen</span> diff --git a/html/tangle.mu.html b/html/tangle.mu.html index d0a41559..8dd2b7f9 100644 --- a/html/tangle.mu.html +++ b/html/tangle.mu.html @@ -10,15 +10,15 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Delimiter { color: #c000c0; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } --> </style> diff --git a/html/x.mu.html b/html/x.mu.html index 15451361..4c5803d2 100644 --- a/html/x.mu.html +++ b/html/x.mu.html @@ -10,14 +10,14 @@ <meta name="colorscheme" content="minimal"> <style type="text/css"> <!-- -pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; } -body { font-family: monospace; color: #d0d0d0; background-color: #000000; } +pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #080808; } +body { font-family: monospace; color: #d0d0d0; background-color: #080808; } * { font-size: 1em; } -.muRecipe { color: #ff8700; } .Comment { color: #8080ff; } .Constant { color: #008080; } .Special { color: #ff6060; } .Identifier { color: #008080; } +.muRecipe { color: #ff8700; } --> </style> |