From 1746609e248151d575f6e3913ad5023fd421bfff Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Mon, 28 Mar 2022 01:30:49 +0900 Subject: Simplify the syntax of #ast directive This change allows using the simple syntax of the directive like `#ast $1 $3...` instead of `#ast #(foo $1 $3...)`. --- driver/parser_test.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'driver/parser_test.go') diff --git a/driver/parser_test.go b/driver/parser_test.go index 89d0e79..3f67bf2 100644 --- a/driver/parser_test.go +++ b/driver/parser_test.go @@ -322,10 +322,10 @@ fragment words: "[A-Za-z\u{0020}]+"; %name test list - : "\[" elems "]" #ast #(list $2...) + : "\[" elems "]" #ast $2... ; elems - : elems "," id #ast #(elems $1... $3) + : elems "," id #ast $1... $3 | id ; whitespace: "\u{0020}+" #skip; @@ -353,21 +353,6 @@ id: "[A-Za-z]+"; termNode("id", "Langly"), ), }, - // The first element of a tree structure must be the same ID as an LHS of a production. - { - specSrc: ` -%name test - -s - : foo #ast #(start $1) - ; -foo - : bar - ; -bar: "bar"; -`, - specErr: true, - }, // An ast action cannot be applied to a terminal symbol. { specSrc: ` @@ -377,7 +362,7 @@ s : foo ; foo - : "foo" #ast #(s $1...) + : "foo" #ast $1... ; `, specErr: true, @@ -388,7 +373,7 @@ foo %name test s - : foo #ast #(s $1...) + : foo #ast $1... ; foo: "foo"; `, -- cgit v1.2.3