diff options
-rw-r--r-- | 024jump.cc | 16 | ||||
-rw-r--r-- | 040brace.cc | 10 | ||||
-rw-r--r-- | 041jump_target.cc | 8 | ||||
-rw-r--r-- | html/024jump.cc.html | 16 | ||||
-rw-r--r-- | html/040brace.cc.html | 10 | ||||
-rw-r--r-- | html/041jump_target.cc.html | 8 |
6 files changed, 34 insertions, 34 deletions
diff --git a/024jump.cc b/024jump.cc index 8b33a083..734cfc49 100644 --- a/024jump.cc +++ b/024jump.cc @@ -16,11 +16,11 @@ put(Recipe_ordinal, "jump", JUMP); :(before "End Primitive Recipe Checks") case JUMP: { if (SIZE(inst.ingredients) != 1) { - raise << maybe(get(Recipe, r).name) << "'jump' requires exactly one ingredient, but got '" << inst.original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' should get exactly one ingredient\n" << end(); break; } if (!is_literal(inst.ingredients.at(0))) { - raise << maybe(get(Recipe, r).name) << "first ingredient of 'jump' should be a label or offset, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "first ingredient of '" << inst.original_string << "' should be a label or offset, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end(); break; } break; @@ -55,15 +55,15 @@ put(Recipe_ordinal, "jump-if", JUMP_IF); :(before "End Primitive Recipe Checks") case JUMP_IF: { if (SIZE(inst.ingredients) != 2) { - raise << maybe(get(Recipe, r).name) << "'jump-if' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' should get exactly two ingredients\n" << end(); break; } if (!is_mu_scalar(inst.ingredients.at(0))) { - raise << maybe(get(Recipe, r).name) << "'jump-if' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' requires a boolean for its first ingredient, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end(); break; } if (!is_literal(inst.ingredients.at(1))) { - raise << maybe(get(Recipe, r).name) << "'jump-if' requires a label or offset for its second ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end(); break; } // End JUMP_IF Checks @@ -108,15 +108,15 @@ put(Recipe_ordinal, "jump-unless", JUMP_UNLESS); :(before "End Primitive Recipe Checks") case JUMP_UNLESS: { if (SIZE(inst.ingredients) != 2) { - raise << maybe(get(Recipe, r).name) << "'jump-unless' requires exactly two ingredients, but got '" << inst.original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' should get exactly two ingredients\n" << end(); break; } if (!is_mu_scalar(inst.ingredients.at(0))) { - raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a boolean for its first ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' requires a boolean for its first ingredient, but '" << inst.ingredients.at(0).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(0).type) << "'\n" << end(); break; } if (!is_literal(inst.ingredients.at(1))) { - raise << maybe(get(Recipe, r).name) << "'jump-unless' requires a label or offset for its second ingredient, but got '" << inst.ingredients.at(0).original_string << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' requires a label or offset for its second ingredient, but '" << inst.ingredients.at(1).name << "' has type '" << names_to_string_without_quotes(inst.ingredients.at(1).type) << "'\n" << end(); break; } // End JUMP_UNLESS Checks diff --git a/040brace.cc b/040brace.cc index cf9a401c..e6afce89 100644 --- a/040brace.cc +++ b/040brace.cc @@ -60,7 +60,7 @@ void transform_braces(const recipe_ordinal r) { } if (inst.label == "}") { if (open_braces.empty()) { - raise << "missing '{' in '" << get(Recipe, r).name << "'\n" << end(); + raise << maybe(get(Recipe, r).name) << "missing '{' in '" << get(Recipe, r).name << "'\n" << end(); return; } open_braces.pop(); @@ -79,7 +79,7 @@ void transform_braces(const recipe_ordinal r) { // check for errors if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) { if (inst.ingredients.empty()) { - raise << "'" << inst.name << "' expects 1 or 2 ingredients, but got none\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.name << "' expects 1 or 2 ingredients, but got none\n" << end(); continue; } } @@ -117,7 +117,7 @@ void transform_braces(const recipe_ordinal r) { target.type = new type_tree("offset"); target.set_value(0); if (open_braces.empty()) - raise << "'" << old_name << "' needs a '{' before\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << old_name << "' needs a '{' before\n" << end(); else if (old_name.find("loop") != string::npos) target.set_value(open_braces.top()-index); else // break instruction @@ -350,7 +350,7 @@ def test-factorial [ def main [ break ] -+error: 'break' needs a '{' before ++error: main: 'break' needs a '{' before :(scenario break_conditional_without_ingredient_fails) % Hide_errors = true; @@ -359,7 +359,7 @@ def main [ break-if } ] -+error: 'break-if' expects 1 or 2 ingredients, but got none ++error: main: 'break-if' expects 1 or 2 ingredients, but got none //: Using break we can now implement conditional returns. diff --git a/041jump_target.cc b/041jump_target.cc index 02d933fc..426ef2ad 100644 --- a/041jump_target.cc +++ b/041jump_target.cc @@ -49,14 +49,14 @@ void transform_labels(const recipe_ordinal r) { instruction& inst = get(Recipe, r).steps.at(i); if (inst.name == "jump") { if (inst.ingredients.empty()) { - raise << maybe(get(Recipe, r).name) << "'jump' expects an ingredient but got none\n" << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' expects an ingredient but got 0\n" << end(); return; } replace_offset(inst.ingredients.at(0), offset, i, r); } if (inst.name == "jump-if" || inst.name == "jump-unless") { if (SIZE(inst.ingredients) < 2) { - raise << maybe(get(Recipe, r).name) << "'" << inst.name << "' expects 2 ingredients but got " << SIZE(inst.ingredients) << '\n' << end(); + raise << maybe(get(Recipe, r).name) << "'" << inst.original_string << "' expects 2 ingredients but got " << SIZE(inst.ingredients) << '\n' << end(); return; } replace_offset(inst.ingredients.at(1), offset, i, r); @@ -149,14 +149,14 @@ def main [ def main [ jump ] -+error: main: 'jump' expects an ingredient but got none ++error: main: 'jump' expects an ingredient but got 0 :(scenario jump_fails_without_target_2) % Hide_errors = true; def main [ jump-if 1/true ] -+error: main: 'jump-if' expects 2 ingredients but got 1 ++error: main: 'jump-if 1/true' expects 2 ingredients but got 1 :(scenario recipe_fails_on_duplicate_jump_target) % Hide_errors = true; diff --git a/html/024jump.cc.html b/html/024jump.cc.html index 52ac4c73..63f26819 100644 --- a/html/024jump.cc.html +++ b/html/024jump.cc.html @@ -80,11 +80,11 @@ if ('onhashchange' in window) { <span id="L16" class="LineNr"> 16 </span><span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span id="L17" class="LineNr"> 17 </span><span class="Normal">case</span> JUMP: <span class="Delimiter">{</span> <span id="L18" class="LineNr"> 18 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L19" class="LineNr"> 19 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump' requires exactly one ingredient, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L19" class="LineNr"> 19 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' should get exactly one ingredient</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L20" class="LineNr"> 20 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L21" class="LineNr"> 21 </span> <span class="Delimiter">}</span> <span id="L22" class="LineNr"> 22 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<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> <span class="Delimiter">{</span> -<span id="L23" class="LineNr"> 23 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of 'jump' should be a label or offset, but got '"</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>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L23" class="LineNr"> 23 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"first ingredient of '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' should be a label or offset, but '"</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>name << <span class="Constant">"' has type '"</span> << names_to_string_without_quotes<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>type<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L24" class="LineNr"> 24 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L25" class="LineNr"> 25 </span> <span class="Delimiter">}</span> <span id="L26" class="LineNr"> 26 </span> <span class="Identifier">break</span><span class="Delimiter">;</span> @@ -119,15 +119,15 @@ if ('onhashchange' in window) { <span id="L55" class="LineNr"> 55 </span><span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span id="L56" class="LineNr"> 56 </span><span class="Normal">case</span> JUMP_IF: <span class="Delimiter">{</span> <span id="L57" class="LineNr"> 57 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L58" class="LineNr"> 58 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-if' requires exactly two ingredients, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L58" class="LineNr"> 58 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' should get exactly two ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L59" class="LineNr"> 59 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L60" class="LineNr"> 60 </span> <span class="Delimiter">}</span> <span id="L61" class="LineNr"> 61 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<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> <span class="Delimiter">{</span> -<span id="L62" class="LineNr"> 62 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-if' requires a boolean for its first ingredient, but got '"</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>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L62" class="LineNr"> 62 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' requires a boolean for its first ingredient, but '"</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>name << <span class="Constant">"' has type '"</span> << names_to_string_without_quotes<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>type<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L63" class="LineNr"> 63 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L64" class="LineNr"> 64 </span> <span class="Delimiter">}</span> <span id="L65" class="LineNr"> 65 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> -<span id="L66" class="LineNr"> 66 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-if' requires a label or offset for its second ingredient, but got '"</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>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L66" class="LineNr"> 66 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' requires a label or offset for its second ingredient, but '"</span> << inst<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="Constant">"' has type '"</span> << names_to_string_without_quotes<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>type<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L67" class="LineNr"> 67 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L68" class="LineNr"> 68 </span> <span class="Delimiter">}</span> <span id="L69" class="LineNr"> 69 </span> <span class="Comment">// End JUMP_IF Checks</span> @@ -172,15 +172,15 @@ if ('onhashchange' in window) { <span id="L108" class="LineNr">108 </span><span class="Delimiter">:(before "End Primitive Recipe Checks")</span> <span id="L109" class="LineNr">109 </span><span class="Normal">case</span> JUMP_UNLESS: <span class="Delimiter">{</span> <span id="L110" class="LineNr">110 </span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L111" class="LineNr">111 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-unless' requires exactly two ingredients, but got '"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L111" class="LineNr">111 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' should get exactly two ingredients</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L112" class="LineNr">112 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L113" class="LineNr">113 </span> <span class="Delimiter">}</span> <span id="L114" class="LineNr">114 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_scalar<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> <span class="Delimiter">{</span> -<span id="L115" class="LineNr">115 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-unless' requires a boolean for its first ingredient, but got '"</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>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L115" class="LineNr">115 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' requires a boolean for its first ingredient, but '"</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>name << <span class="Constant">"' has type '"</span> << names_to_string_without_quotes<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>type<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L116" class="LineNr">116 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L117" class="LineNr">117 </span> <span class="Delimiter">}</span> <span id="L118" class="LineNr">118 </span> <span class="Normal">if</span> <span class="Delimiter">(</span>!is_literal<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> -<span id="L119" class="LineNr">119 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump-unless' requires a label or offset for its second ingredient, but got '"</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>original_string << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L119" class="LineNr">119 </span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' requires a label or offset for its second ingredient, but '"</span> << inst<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="Constant">"' has type '"</span> << names_to_string_without_quotes<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>type<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L120" class="LineNr">120 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span id="L121" class="LineNr">121 </span> <span class="Delimiter">}</span> <span id="L122" class="LineNr">122 </span> <span class="Comment">// End JUMP_UNLESS Checks</span> diff --git a/html/040brace.cc.html b/html/040brace.cc.html index 762bf34f..5c868aaa 100644 --- a/html/040brace.cc.html +++ b/html/040brace.cc.html @@ -123,7 +123,7 @@ if ('onhashchange' in window) { <span id="L60" class="LineNr"> 60 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> <span id="L61" class="LineNr"> 61 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>label == <span class="Constant">"}"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L62" class="LineNr"> 62 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>open_braces<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L63" class="LineNr"> 63 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <span class="Constant">"missing '{' in '"</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L63" class="LineNr"> 63 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"missing '{' in '"</span> << get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L64" class="LineNr"> 64 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L65" class="LineNr"> 65 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> <span id="L66" class="LineNr"> 66 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> open_braces<span class="Delimiter">.</span>pop<span class="Delimiter">();</span> @@ -142,7 +142,7 @@ if ('onhashchange' in window) { <span id="L79" class="LineNr"> 79 </span> <span class="Conceal">¦</span> <span class="Comment">// check for errors</span> <span id="L80" class="LineNr"> 80 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"-if"</span><span class="Delimiter">)</span> != string::npos || inst<span class="Delimiter">.</span>name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"-unless"</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L81" class="LineNr"> 81 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L82" class="LineNr"> 82 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">"' expects 1 or 2 ingredients, but got none</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L82" class="LineNr"> 82 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">"' expects 1 or 2 ingredients, but got none</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L83" class="LineNr"> 83 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">continue</span><span class="Delimiter">;</span> <span id="L84" class="LineNr"> 84 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> <span id="L85" class="LineNr"> 85 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> @@ -180,7 +180,7 @@ if ('onhashchange' in window) { <span id="L117" class="LineNr">117 </span> <span class="Conceal">¦</span> target<span class="Delimiter">.</span>type = <span class="Normal">new</span> type_tree<span class="Delimiter">(</span><span class="Constant">"offset"</span><span class="Delimiter">);</span> <span id="L118" class="LineNr">118 </span> <span class="Conceal">¦</span> target<span class="Delimiter">.</span><a href='010vm.cc.html#L65'>set_value</a><span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> <span id="L119" class="LineNr">119 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>open_braces<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> -<span id="L120" class="LineNr">120 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <span class="Constant">"'"</span> << old_name << <span class="Constant">"' needs a '{' before</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L120" class="LineNr">120 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << old_name << <span class="Constant">"' needs a '{' before</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L121" class="LineNr">121 </span> <span class="Conceal">¦</span> <span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>old_name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"loop"</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">)</span> <span id="L122" class="LineNr">122 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> target<span class="Delimiter">.</span><a href='010vm.cc.html#L65'>set_value</a><span class="Delimiter">(</span>open_braces<span class="Delimiter">.</span>top<span class="Delimiter">()</span>-index<span class="Delimiter">);</span> <span id="L123" class="LineNr">123 </span> <span class="Conceal">¦</span> <span class="Normal">else</span> <span class="Comment">// break instruction</span> @@ -413,7 +413,7 @@ if ('onhashchange' in window) { <span id="L350" class="LineNr">350 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L351" class="LineNr">351 </span> <span class="Identifier">break</span> <span id="L352" class="LineNr">352 </span>] -<span id="L353" class="LineNr">353 </span><span class="traceContains">+error: 'break' needs a '{' before</span> +<span id="L353" class="LineNr">353 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: 'break' needs a '{' before</span> <span id="L354" class="LineNr">354 </span> <span id="L355" class="LineNr">355 </span><span class="Delimiter">:(scenario break_conditional_without_ingredient_fails)</span> <span id="L356" class="LineNr">356 </span><span class="Special">% Hide_errors = true;</span> @@ -422,7 +422,7 @@ if ('onhashchange' in window) { <span id="L359" class="LineNr">359 </span> <span class="Conceal">¦</span> <span class="Identifier">break</span>-<span class="Normal">if</span> <span id="L360" class="LineNr">360 </span> <span class="Delimiter">}</span> <span id="L361" class="LineNr">361 </span>] -<span id="L362" class="LineNr">362 </span><span class="traceContains">+error: 'break-if' expects 1 or 2 ingredients, but got none</span> +<span id="L362" class="LineNr">362 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: 'break-if' expects 1 or 2 ingredients, but got none</span> <span id="L363" class="LineNr">363 </span> <span id="L364" class="LineNr">364 </span><span class="Comment">//: Using break we can now implement conditional returns.</span> <span id="L365" class="LineNr">365 </span> diff --git a/html/041jump_target.cc.html b/html/041jump_target.cc.html index 2ca57608..3f9e3dd7 100644 --- a/html/041jump_target.cc.html +++ b/html/041jump_target.cc.html @@ -113,14 +113,14 @@ if ('onhashchange' in window) { <span id="L49" class="LineNr"> 49 </span> <span class="Conceal">¦</span> instruction& inst = get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span>i<span class="Delimiter">);</span> <span id="L50" class="LineNr"> 50 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"jump"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L51" class="LineNr"> 51 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span> -<span id="L52" class="LineNr"> 52 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'jump' expects an ingredient but got none</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L52" class="LineNr"> 52 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' expects an ingredient but got 0</span><span class="cSpecial">\n</span><span class="Constant">"</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L53" class="LineNr"> 53 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L54" class="LineNr"> 54 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> <span id="L55" class="LineNr"> 55 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='041jump_target.cc.html#L76'>replace_offset</a><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> offset<span class="Delimiter">,</span> i<span class="Delimiter">,</span> r<span class="Delimiter">);</span> <span id="L56" class="LineNr"> 56 </span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> <span id="L57" class="LineNr"> 57 </span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>name == <span class="Constant">"jump-if"</span> || inst<span class="Delimiter">.</span>name == <span class="Constant">"jump-unless"</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L58" class="LineNr"> 58 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Normal">if</span> <span class="Delimiter">(</span><a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> < <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L59" class="LineNr"> 59 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>name << <span class="Constant">"' expects 2 ingredients but got "</span> << <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> +<span id="L59" class="LineNr"> 59 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='003trace.cc.html#L168'>raise</a> << <a href='013update_operation.cc.html#L25'>maybe</a><span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'"</span> << inst<span class="Delimiter">.</span>original_string << <span class="Constant">"' expects 2 ingredients but got "</span> << <a href='001help.cc.html#L138'>SIZE</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << <a href='003trace.cc.html#L185'>end</a><span class="Delimiter">();</span> <span id="L60" class="LineNr"> 60 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span id="L61" class="LineNr"> 61 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <span class="Delimiter">}</span> <span id="L62" class="LineNr"> 62 </span> <span class="Conceal">¦</span> <span class="Conceal">¦</span> <a href='041jump_target.cc.html#L76'>replace_offset</a><span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">),</span> offset<span class="Delimiter">,</span> i<span class="Delimiter">,</span> r<span class="Delimiter">);</span> @@ -213,14 +213,14 @@ if ('onhashchange' in window) { <span id="L149" class="LineNr">149 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L150" class="LineNr">150 </span> jump <span id="L151" class="LineNr">151 </span>] -<span id="L152" class="LineNr">152 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: 'jump' expects an ingredient but got none</span> +<span id="L152" class="LineNr">152 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: 'jump' expects an ingredient but got 0</span> <span id="L153" class="LineNr">153 </span> <span id="L154" class="LineNr">154 </span><span class="Delimiter">:(scenario jump_fails_without_target_2)</span> <span id="L155" class="LineNr">155 </span><span class="Special">% Hide_errors = true;</span> <span id="L156" class="LineNr">156 </span><span class="muRecipe">def</span> <a href='000organization.cc.html#L113'>main</a> [ <span id="L157" class="LineNr">157 </span> jump-<span class="Normal">if</span> <span class="Constant">1</span>/<span class="Constant">true</span> <span id="L158" class="LineNr">158 </span>] -<span id="L159" class="LineNr">159 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: 'jump-if' expects 2 ingredients but got 1</span> +<span id="L159" class="LineNr">159 </span><span class="traceContains">+error: <a href='000organization.cc.html#L113'>main</a>: 'jump-if 1/true' expects 2 ingredients but got 1</span> <span id="L160" class="LineNr">160 </span> <span id="L161" class="LineNr">161 </span><span class="Delimiter">:(scenario recipe_fails_on_duplicate_jump_target)</span> <span id="L162" class="LineNr">162 </span><span class="Special">% Hide_errors = true;</span> |