From 6a18024f4fa3b96044d50e6308dad5e78128a9c3 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Thu, 15 Jul 2021 00:48:15 +0900 Subject: Add testing for the driver The driver can reduce productions that have the empty alternative and can generate a CST (and AST) node. --- driver/parser.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'driver/parser.go') diff --git a/driver/parser.go b/driver/parser.go index 7b6df7b..fa89fcf 100644 --- a/driver/parser.go +++ b/driver/parser.go @@ -121,8 +121,11 @@ func (p *Parser) Parse() error { } // semantic action + prodNum := act lhs := p.gram.ParsingTable.LHSSymbols[prodNum] + + // When an alternative is empty, `n` will be 0, and `handle` will be empty slice. n := p.gram.ParsingTable.AlternativeSymbolCounts[prodNum] handle := p.semStack[len(p.semStack)-n:] -- cgit v1.2.3