diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-07-15 00:48:15 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-07-15 00:48:15 +0900 |
commit | 6a18024f4fa3b96044d50e6308dad5e78128a9c3 (patch) | |
tree | 84f91a26abee8df1083a94cb5aa9b55f75e13486 /driver/parser.go | |
parent | Allow directives to take multiple parameters (diff) | |
download | cotia-6a18024f4fa3b96044d50e6308dad5e78128a9c3.tar.gz cotia-6a18024f4fa3b96044d50e6308dad5e78128a9c3.tar.xz |
Add testing for the driver
The driver can reduce productions that have the empty alternative and can generate a CST (and AST) node.
Diffstat (limited to 'driver/parser.go')
-rw-r--r-- | driver/parser.go | 3 |
1 files changed, 3 insertions, 0 deletions
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:] |