From 3eb0e88f911386a4e6eca991c1471070596c5554 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sat, 7 May 2022 20:41:33 +0900 Subject: Change syntax for top-level directives %name changes to: #name example; %left and %right change to: #prec ( #left a b #right c d ); --- driver/conflict_test.go | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'driver/conflict_test.go') diff --git a/driver/conflict_test.go b/driver/conflict_test.go index 7672c00..042d932 100644 --- a/driver/conflict_test.go +++ b/driver/conflict_test.go @@ -18,7 +18,7 @@ func TestParserWithConflicts(t *testing.T) { { caption: "when a shift/reduce conflict occurred, we prioritize the shift action", specSrc: ` -%name test +#name test; expr : expr assign expr @@ -48,7 +48,7 @@ assign: '='; { caption: "when a reduce/reduce conflict occurred, we prioritize the production defined earlier in the grammar", specSrc: ` -%name test +#name test; s : a @@ -73,10 +73,12 @@ id: "[A-Za-z0-9_]+"; { caption: "left associativities defined earlier in the grammar have higher precedence", specSrc: ` -%name test +#name test; -%left mul -%left add +#prec ( + #left mul + #left add +); expr : expr add expr @@ -120,9 +122,11 @@ mul: '*'; { caption: "left associativities defined in the same line have the same precedence", specSrc: ` -%name test +#name test; -%left add sub +#prec ( + #left add sub +); expr : expr add expr @@ -166,10 +170,12 @@ sub: '-'; { caption: "right associativities defined earlier in the grammar have higher precedence", specSrc: ` -%name test +#name test; -%right r1 -%right r2 +#prec ( + #right r1 + #right r2 +); expr : expr r2 expr @@ -218,9 +224,11 @@ id { caption: "right associativities defined in the same line have the same precedence", specSrc: ` -%name test +#name test; -%right r1 r2 +#prec ( + #right r1 r2 +); expr : expr r2 expr @@ -269,11 +277,13 @@ id { caption: "left and right associativities can be mixed", specSrc: ` -%name test +#name test; -%left mul div -%left add sub -%right assign +#prec ( + #left mul div + #left add sub + #right assign +); expr : expr add expr -- cgit v1.2.3