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.
This commit is contained in:
ridiculousfish
2015-12-15 14:59:03 -08:00
parent 7188d94c1b
commit 8c707a4e2f
6 changed files with 172 additions and 317 deletions

View File

@@ -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;
}