Disallow backgrounding in conditionals and before and/or bool statements

Fixes #1136
This commit is contained in:
ridiculousfish
2014-11-02 13:11:27 -08:00
parent c33a3862cc
commit c31ad3ed07
6 changed files with 144 additions and 21 deletions

View File

@@ -1649,6 +1649,30 @@ parse_node_tree_t::parse_node_list_t parse_node_tree_t::specific_statements_for_
return result;
}
enum parse_bool_statement_type_t parse_node_tree_t::statement_boolean_type(const parse_node_t &node)
{
assert(node.type == symbol_boolean_statement);
switch (node.production_idx)
{
// These magic numbers correspond to productions for boolean_statement
case 0:
return parse_bool_and;
case 1:
return parse_bool_or;
case 2:
return parse_bool_not;
default:
{
fprintf(stderr, "Unexpected production in boolean statement\n");
PARSER_DIE();
return (enum parse_bool_statement_type_t)(-1);
}
}
}
bool parse_node_tree_t::job_should_be_backgrounded(const parse_node_t &job) const
{
assert(job.type == symbol_job);
@@ -1657,7 +1681,8 @@ bool parse_node_tree_t::job_should_be_backgrounded(const parse_node_t &job) cons
const parse_node_t *opt_background = get_child(job, 2, symbol_optional_background);
if (opt_background != NULL)
{
assert(opt_background->production_idx <= 1);
// We may get the value -1 if the node is not yet materialized (i.e. an incomplete parse tree)
assert(opt_background->production_idx == uint8_t(-1) || opt_background->production_idx <= 1);
result = (opt_background->production_idx == 1);
}
return result;