diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-07 20:41:33 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-10 23:14:41 +0900 |
commit | 3eb0e88f911386a4e6eca991c1471070596c5554 (patch) | |
tree | 4c3ea445a804d781b846739d70392ceb1353ea6d /driver/conflict_test.go | |
parent | Make #prec directive change only precedence and not associativity (diff) | |
download | cotia-3eb0e88f911386a4e6eca991c1471070596c5554.tar.gz cotia-3eb0e88f911386a4e6eca991c1471070596c5554.tar.xz |
Change syntax for top-level directives
%name changes to:
#name example;
%left and %right change to:
#prec (
#left a b
#right c d
);
Diffstat (limited to 'driver/conflict_test.go')
-rw-r--r-- | driver/conflict_test.go | 42 |
1 files changed, 26 insertions, 16 deletions
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 |