aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parse_execution.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-12-15 14:59:03 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-12-19 11:17:13 -0800
commit8c707a4e2ffc30bae6d9ac3a28bd05fca0ff1195 (patch)
tree786b8ac916b5c873be902e8e3a1cbf9b38aaf53c /src/parse_execution.cpp
parent7188d94c1bdc483e6dca877631ca6dfa6af0ebbc (diff)
Simplify parser implementation
Rather than returning a list of productions and an index, return the relevant production directly from the rule function. Also introduce a tag value (replacing production_idx) which tracks information like command decorations, etc. with more clarity.
Diffstat (limited to 'src/parse_execution.cpp')
-rw-r--r--src/parse_execution.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp
index 471914f6..7946d959 100644
--- a/src/parse_execution.cpp
+++ b/src/parse_execution.cpp
@@ -320,17 +320,16 @@ parse_execution_result_t parse_execution_context_t::run_if_statement(const parse
{
/* We have an 'else continuation' (either else-if or else) */
const parse_node_t &else_cont = *get_child(*else_clause, 1, symbol_else_continuation);
- assert(else_cont.production_idx < 2);
- if (else_cont.production_idx == 0)
+ const parse_node_t *maybe_if_clause = get_child(else_cont, 0);
+ if (maybe_if_clause && maybe_if_clause->type == symbol_if_clause)
{
/* it's an 'else if', go to the next one */
- if_clause = get_child(else_cont, 0, symbol_if_clause);
+ if_clause = maybe_if_clause;
else_clause = get_child(else_cont, 1, symbol_else_clause);
}
else
{
/* it's the final 'else', we're done */
- assert(else_cont.production_idx == 1);
job_list_to_execute = get_child(else_cont, 1, symbol_job_list);
break;
}