diff --git a/src/cfgrammar.c b/src/cfgrammar.c index a9005e9bafd787d19b5394561ed771b93be9d086..684a39c8663156239a9f8e7ae3e52268c27f1b83 100644 --- a/src/cfgrammar.c +++ b/src/cfgrammar.c @@ -37,6 +37,15 @@ static void collect_nts(HCFGrammar *grammar, HCFChoice *symbol); static void collect_geneps(HCFGrammar *grammar); +static const HParsedToken *h_act_first(const HParseResult *p) +{ + assert(p->ast); + assert(p->ast->token_type == TT_SEQUENCE); + assert(p->ast->seq->used > 0); + + return p->ast->seq->elements[0]; +} + /* Convert 'parser' into CFG representation by desugaring and compiling the set * of nonterminals. * A NULL return means we are unable to represent the parser as a CFG. @@ -63,6 +72,7 @@ HCFGrammar *h_cfgrammar(HAllocator* mm__, const HParser *parser) nt->seq[0]->items[0] = desugared; nt->seq[0]->items[1] = NULL; nt->seq[1] = NULL; + nt->reshape = h_act_first; h_hashset_put(g->nts, nt); g->start = nt; } else {