diff options
Diffstat (limited to 'html')
-rw-r--r-- | html/029tools.cc.html | 11 | ||||
-rw-r--r-- | html/038new_text.cc.html | 38 | ||||
-rw-r--r-- | html/058to_text.cc.html | 2 | ||||
-rw-r--r-- | html/061text.mu.html | 83 | ||||
-rw-r--r-- | html/089scenario_filesystem.cc.html | 8 |
5 files changed, 127 insertions, 15 deletions
diff --git a/html/029tools.cc.html b/html/029tools.cc.html index a6322f9c..da2f41ab 100644 --- a/html/029tools.cc.html +++ b/html/029tools.cc.html @@ -70,7 +70,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">2</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i > <span class="Constant">2</span><span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> - out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + out << inspect<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span>depth<span class="Delimiter">,</span> label<span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -91,7 +91,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> - out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + out << inspect<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> trace<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">,</span> <span class="Constant">"app"</span><span class="Delimiter">)</span> << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -117,10 +117,10 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="traceContains">+app: foo: 34</span> <span class="Delimiter">:(code)</span> -string print_mu<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> vector<<span class="Normal">double</span>>& data<span class="Delimiter">)</span> <span class="Delimiter">{</span> +string inspect<span class="Delimiter">(</span><span class="Normal">const</span> reagent& r<span class="Delimiter">,</span> <span class="Normal">const</span> vector<<span class="Normal">double</span>>& data<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_literal<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Identifier">return</span> r<span class="Delimiter">.</span>name<span class="Delimiter">;</span> - <span class="Comment">// End print Special-cases(r, data)</span> + <span class="Comment">// End inspect Special-cases(r, data)</span> ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">long</span> <span class="Normal">long</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>data<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Normal">if</span> <span class="Delimiter">(</span>i<span class="Delimiter">)</span> out << <span class="Constant">' '</span><span class="Delimiter">;</span> @@ -285,6 +285,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span cout << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> + <span class="Comment">// End $print Special-cases</span> <span class="Normal">else</span> <span class="Delimiter">{</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> j = <span class="Constant">0</span><span class="Delimiter">;</span> j < SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> ++j<span class="Delimiter">)</span> <span class="Delimiter">{</span> trace<span class="Delimiter">(</span><span class="Constant">9998</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"$print: "</span> << ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">).</span>at<span class="Delimiter">(</span>j<span class="Delimiter">)</span> << end<span class="Delimiter">();</span> @@ -368,7 +369,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Normal">case</span> _LOG: <span class="Delimiter">{</span> ostringstream out<span class="Delimiter">;</span> <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> - out << print_mu<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> + out << inspect<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">),</span> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">));</span> <span class="Delimiter">}</span> LOG << out<span class="Delimiter">.</span>str<span class="Delimiter">()</span> << <span class="cSpecial">'\n'</span><span class="Delimiter">;</span> <span class="Identifier">break</span><span class="Delimiter">;</span> diff --git a/html/038new_text.cc.html b/html/038new_text.cc.html index 0cd1e165..f86c1683 100644 --- a/html/038new_text.cc.html +++ b/html/038new_text.cc.html @@ -16,6 +16,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color .Constant { color: #00a0a0; } .CommentedCode { color: #6c6c6c; } .muRecipe { color: #ff8700; } +.SalientComment { color: #00ffff; } .Comment { color: #9090ff; } .Delimiter { color: #800080; } .Special { color: #c00000; } @@ -106,12 +107,17 @@ put<span class="Delimiter">(</span>Type_abbreviations<span class="Delimiter">,</ ] <span class="traceContains">+app: foo: abc</span> -<span class="Delimiter">:(before "End print Special-cases(r, data)")</span> +<span class="Delimiter">:(before "End inspect Special-cases(r, data)")</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_text<span class="Delimiter">(</span>r<span class="Delimiter">))</span> <span class="Delimiter">{</span> assert<span class="Delimiter">(</span>scalar<span class="Delimiter">(</span>data<span class="Delimiter">));</span> <span class="Identifier">return</span> read_mu_text<span class="Delimiter">(</span>data<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">:(before "End $print Special-cases")</span> +<span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>is_mu_text<span class="Delimiter">(</span>current_instruction<span class="Delimiter">().</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">)))</span> <span class="Delimiter">{</span> + cout << read_mu_text<span class="Delimiter">(</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<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">:(scenario unicode_string)</span> <span class="muRecipe">def</span> main [ <span class="Constant">1</span>:text<span class="Special"> <- </span><span class="Normal">new</span> [♠] @@ -172,6 +178,36 @@ string read_mu_text<span class="Delimiter">(</span><span class="Normal">int</spa <span class="Delimiter">}</span> <span class="Identifier">return</span> tmp<span class="Delimiter">.</span>str<span class="Delimiter">();</span> <span class="Delimiter">}</span> + +<span class="SalientComment">//:: 'cheating' by using the host system</span> + +<span class="Delimiter">:(before "End Primitive Recipe Declarations")</span> +_READ<span class="Delimiter">,</span> +<span class="Delimiter">:(before "End Primitive Recipe Numbers")</span> +put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">"$read"</span><span class="Delimiter">,</span> _READ<span class="Delimiter">);</span> +<span class="Delimiter">:(before "End Primitive Recipe Checks")</span> +<span class="Normal">case</span> _READ: <span class="Delimiter">{</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> +<span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> +<span class="Normal">case</span> _READ: <span class="Delimiter">{</span> + skip_whitespace<span class="Delimiter">(</span>cin<span class="Delimiter">);</span> + string result<span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>has_data<span class="Delimiter">(</span>cin<span class="Delimiter">))</span> + cin >> result<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>new_mu_text<span class="Delimiter">(</span>result<span class="Delimiter">));</span> + <span class="Identifier">break</span><span class="Delimiter">;</span> +<span class="Delimiter">}</span> + +<span class="Delimiter">:(code)</span> +<span class="Normal">void</span> skip_whitespace<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">while</span> <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()))</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> + <span class="Normal">else</span> <span class="Identifier">break</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> +<span class="Delimiter">}</span> </pre> </body> </html> diff --git a/html/058to_text.cc.html b/html/058to_text.cc.html index 961df126..e2be9a6f 100644 --- a/html/058to_text.cc.html +++ b/html/058to_text.cc.html @@ -50,7 +50,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Implementations")</span> <span class="Normal">case</span> TO_TEXT: <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>new_mu_text<span class="Delimiter">(</span>print_mu<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> ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</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>new_mu_text<span class="Delimiter">(</span>inspect<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> ingredients<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> </pre> diff --git a/html/061text.mu.html b/html/061text.mu.html index e438b576..08a836b3 100644 --- a/html/061text.mu.html +++ b/html/061text.mu.html @@ -1341,6 +1341,89 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color 1:array:character <span class="Special"><-</span> <span class="Constant">[]</span> ] ] + +<span class="muRecipe">def</span> parse-whole-number in:text<span class="muRecipe"> -> </span>out:num, error?:bool [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + out:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + result:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Comment"># temporary location</span> + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special"><-</span> length *in + <span class="Delimiter">{</span> + done?:bool <span class="Special"><-</span> greater-or-equal i, len + <span class="muControl">break-if</span> done? + c:char <span class="Special"><-</span> index *in, i + x:num <span class="Special"><-</span> character-to-code c + digit:num, error?:bool <span class="Special"><-</span> character-code-to-digit x + <span class="muControl">reply-if</span> error? + result <span class="Special"><-</span> multiply result,<span class="Constant"> 10</span> + result <span class="Special"><-</span> add result, digit + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + <span class="Comment"># no error; all digits were valid</span> + out <span class="Special"><-</span> copy result +] + +<span class="Comment"># (contributed by Ella Couch)</span> +<span class="muRecipe">recipe</span> character-code-to-digit character-code:number<span class="muRecipe"> -> </span>result:number, error?:boolean [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + result <span class="Special"><-</span> copy<span class="Constant"> 0</span> + error? <span class="Special"><-</span> lesser-than character-code,<span class="Constant"> 48</span> <span class="Comment"># '0'</span> + <span class="muControl">reply-if</span> error? + error? <span class="Special"><-</span> greater-than character-code,<span class="Constant"> 57</span> <span class="Comment"># '9'</span> + <span class="muControl">reply-if</span> error? + result <span class="Special"><-</span> subtract character-code,<span class="Constant"> 48</span> +] + +<span class="muScenario">scenario</span> character-code-to-digit-contain-only-digit [ + <span class="Constant">local-scope</span> + a:number <span class="Special"><-</span> copy<span class="Constant"> 48</span> <span class="Comment"># character code for '0'</span> + run [ + 10:number/<span class="Special">raw</span>, 11:boolean/<span class="Special">raw</span> <span class="Special"><-</span> character-code-to-digit a + ] + memory-should-contain [ + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># no error</span> + ] +] + +<span class="muScenario">scenario</span> character-code-to-digit-contain-only-digit-2 [ + <span class="Constant">local-scope</span> + a:number <span class="Special"><-</span> copy<span class="Constant"> 57</span> <span class="Comment"># character code for '9'</span> + run [ + 1:number/<span class="Special">raw</span>, 2:boolean/<span class="Special">raw</span> <span class="Special"><-</span> character-code-to-digit a + ] + memory-should-contain [ + <span class="Constant"> 1</span> <span class="Special"><-</span><span class="Constant"> 9</span> + <span class="Constant"> 2</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># no error</span> + ] +] + +<span class="muScenario">scenario</span> character-code-to-digit-handles-codes-lower-than-zero [ + <span class="Constant">local-scope</span> + a:number <span class="Special"><-</span> copy<span class="Constant"> 47</span> + run [ + 10:number/<span class="Special">raw</span>, 11:boolean/<span class="Special">raw</span> <span class="Special"><-</span> character-code-to-digit a + ] + memory-should-contain [ + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># error</span> + ] +] + +<span class="muScenario">scenario</span> character-code-to-digit-handles-codes-larger-than-nine [ + <span class="Constant">local-scope</span> + a:number <span class="Special"><-</span> copy<span class="Constant"> 58</span> + run [ + 10:number/<span class="Special">raw</span>, 11:boolean/<span class="Special">raw</span> <span class="Special"><-</span> character-code-to-digit a + ] + memory-should-contain [ + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># error</span> + ] +] </pre> </body> </html> diff --git a/html/089scenario_filesystem.cc.html b/html/089scenario_filesystem.cc.html index d0cc5e17..13cc4a90 100644 --- a/html/089scenario_filesystem.cc.html +++ b/html/089scenario_filesystem.cc.html @@ -278,14 +278,6 @@ string munge_resources_contents<span class="Delimiter">(</span><span class="Norm <span class="Normal">delete</span> type<span class="Delimiter">;</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> - -<span class="Normal">void</span> skip_whitespace<span class="Delimiter">(</span>istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">while</span> <span class="Delimiter">(</span><span class="Constant">true</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>!has_data<span class="Delimiter">(</span>in<span class="Delimiter">))</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Normal">if</span> <span class="Delimiter">(</span>isspace<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()))</span> in<span class="Delimiter">.</span>get<span class="Delimiter">();</span> - <span class="Normal">else</span> <span class="Identifier">break</span><span class="Delimiter">;</span> - <span class="Delimiter">}</span> -<span class="Delimiter">}</span> </pre> </body> </html> |