aboutsummaryrefslogtreecommitdiff
path: root/grammar/test_helper_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'grammar/test_helper_test.go')
-rw-r--r--grammar/test_helper_test.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/grammar/test_helper_test.go b/grammar/test_helper_test.go
index 8f5c372..cf9da2b 100644
--- a/grammar/test_helper_test.go
+++ b/grammar/test_helper_test.go
@@ -35,10 +35,10 @@ func newTestProductionGenerator(t *testing.T, genSym testSymbolGenerator) testPr
}
}
-type testLR0ItemGenerator func(lhs string, dot int, rhs ...string) *lr0Item
+type testLR0ItemGenerator func(lhs string, dot int, rhs ...string) *lrItem
func newTestLR0ItemGenerator(t *testing.T, genProd testProductionGenerator) testLR0ItemGenerator {
- return func(lhs string, dot int, rhs ...string) *lr0Item {
+ return func(lhs string, dot int, rhs ...string) *lrItem {
t.Helper()
prod := genProd(lhs, rhs...)
@@ -50,3 +50,15 @@ func newTestLR0ItemGenerator(t *testing.T, genProd testProductionGenerator) test
return item
}
}
+
+func withLookAhead(item *lrItem, lookAhead ...symbol) *lrItem {
+ if item.lookAhead.symbols == nil {
+ item.lookAhead.symbols = map[symbol]struct{}{}
+ }
+
+ for _, a := range lookAhead {
+ item.lookAhead.symbols[a] = struct{}{}
+ }
+
+ return item
+}