diff options
Diffstat (limited to '023boolean.cc')
-rw-r--r-- | 023boolean.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/023boolean.cc b/023boolean.cc index 40ce068e..558421a5 100644 --- a/023boolean.cc +++ b/023boolean.cc @@ -12,6 +12,14 @@ case AND: { goto finish_checking_instruction; } } + if (SIZE(inst.products) > 1) { + raise << maybe(get(Recipe, r).name) << "'and' yields exactly one product in '" << to_string(inst) << "'\n" << end(); + break; + } + if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { + raise << maybe(get(Recipe, r).name) << "'and' should yield a boolean, but got " << inst.products.at(0).original_string << '\n' << end(); + break; + } break; } :(before "End Primitive Recipe Implementations") @@ -62,6 +70,14 @@ case OR: { goto finish_checking_instruction; } } + if (SIZE(inst.products) > 1) { + raise << maybe(get(Recipe, r).name) << "'or' yields exactly one product in '" << to_string(inst) << "'\n" << end(); + break; + } + if (!inst.products.empty() && !is_dummy(inst.products.at(0)) && !is_mu_boolean(inst.products.at(0))) { + raise << maybe(get(Recipe, r).name) << "'or' should yield a boolean, but got " << inst.products.at(0).original_string << '\n' << end(); + break; + } break; } :(before "End Primitive Recipe Implementations") @@ -116,6 +132,13 @@ case NOT: { goto finish_checking_instruction; } } + for (long long int i = 0; i < SIZE(inst.products); ++i) { + if (is_dummy(inst.products.at(i))) continue; + if (!is_mu_boolean(inst.products.at(i))) { + raise << maybe(get(Recipe, r).name) << "'not' should yield a boolean, but got " << inst.products.at(i).original_string << '\n' << end(); + goto finish_checking_instruction; + } + } break; } :(before "End Primitive Recipe Implementations") |