aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse_tree.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-11-02 13:11:27 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-11-02 13:11:27 -0800
commitc31ad3ed07a88f4dad5a998f005fb8c195fd1eb2 (patch)
tree078e45a3ebc4e4c71b76ade89c6e4ed11760d30f /parse_tree.cpp
parentc33a3862ccc1e694ecf31f6d0b6cf1a45d6455f7 (diff)
Disallow backgrounding in conditionals and before and/or bool statements
Fixes #1136
Diffstat (limited to 'parse_tree.cpp')
-rw-r--r--parse_tree.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/parse_tree.cpp b/parse_tree.cpp
index c3ef658e..8c38ef5a 100644
--- a/parse_tree.cpp
+++ b/parse_tree.cpp
@@ -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;