From bbbaf1634cead71bd3997e062213bb63bd3ce544 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Fri, 21 Jun 2013 15:00:04 +0200 Subject: [PATCH] add an assertion checking that HLR_REDUCE is always followed by HLR_SHIFT --- src/backends/lr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/backends/lr.c b/src/backends/lr.c index 1ea6a395..2f7d5e48 100644 --- a/src/backends/lr.c +++ b/src/backends/lr.c @@ -314,6 +314,12 @@ bool h_lrengine_step(HLREngine *engine, const HLRAction *action) // push result (value, symbol) onto the right stack h_slist_push(right, value); h_slist_push(right, symbol); + + // this is LR, building a right-most derivation bottom-up, so no reduce can + // follow a reduce. we can also assume no conflict follows for GLR if we + // use LALR tables, because only terminal symbols (lookahead) get reduces. + const HLRAction *next = h_lr_lookup(engine->table, engine->state, symbol); + assert(next == NULL || next->type == HLR_SHIFT); } return true; -- GitLab