aboutsummaryrefslogtreecommitdiff
path: root/driver/parser.go
diff options
context:
space:
mode:
authorRyo Nihei <nihei.dev@gmail.com>2021-07-15 00:48:15 +0900
committerRyo Nihei <nihei.dev@gmail.com>2021-07-15 00:48:15 +0900
commit6a18024f4fa3b96044d50e6308dad5e78128a9c3 (patch)
tree84f91a26abee8df1083a94cb5aa9b55f75e13486 /driver/parser.go
parentAllow directives to take multiple parameters (diff)
downloadcotia-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.go3
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:]