From 4d879b95d5368d578a39baaefba0de743a764105 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 22 Aug 2021 15:39:27 +0900 Subject: Support %left and %right to specify precedences and associativities --- driver/parser_test.go | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'driver/parser_test.go') diff --git a/driver/parser_test.go b/driver/parser_test.go index d50ee85..9467d6c 100644 --- a/driver/parser_test.go +++ b/driver/parser_test.go @@ -392,6 +392,58 @@ b foo: "foo"; bar: "bar"; b: "a"; +`, + specErr: true, + }, + // Invalid associativity type + { + specSrc: ` +%foo + +s + : a + ; + +a: 'a'; +`, + specErr: true, + }, + // Associativity needs at least one symbol. + { + specSrc: ` +%left + +s + : a + ; + +a: 'a'; +`, + specErr: true, + }, + // Associativity cannot take an undefined symbol. + { + specSrc: ` +%left b + +s + : a + ; + +a: 'a'; +`, + specErr: true, + }, + // Associativity cannot take a non-terminal symbol. + { + specSrc: ` +%left s + +s + : a + ; + +a: 'a'; `, specErr: true, }, -- cgit v1.2.3