diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-08 13:07:56 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2022-05-10 23:14:41 +0900 |
commit | 2438fa4435d6393168412574a3ef94396a4debe5 (patch) | |
tree | 390ea502d7472af78b68f7bfef928d48525d533e /spec/parser_test.go | |
parent | Change syntax for top-level directives (diff) | |
download | cotia-2438fa4435d6393168412574a3ef94396a4debe5.tar.gz cotia-2438fa4435d6393168412574a3ef94396a4debe5.tar.xz |
Add #assign directive
An #assign directive changes only precedence.
Diffstat (limited to 'spec/parser_test.go')
-rw-r--r-- | spec/parser_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/parser_test.go b/spec/parser_test.go index de2c6f7..3fe950f 100644 --- a/spec/parser_test.go +++ b/spec/parser_test.go @@ -34,6 +34,12 @@ func TestParse(t *testing.T) { Parameters: params, } } + assign := func(params ...*ParameterNode) *DirectiveNode { + return &DirectiveNode{ + Name: "assign", + Parameters: params, + } + } prod := func(lhs string, alts ...*AlternativeNode) *ProductionNode { return &ProductionNode{ LHS: lhs, @@ -148,6 +154,7 @@ func TestParse(t *testing.T) { #prec ( #left a b #right c d + #assign e f ); `, ast: &RootNode{ @@ -191,6 +198,19 @@ func TestParse(t *testing.T) { ), newPos(6), ), + withDirPos( + assign( + withParamPos( + idParam("e"), + newPos(7), + ), + withParamPos( + idParam("f"), + newPos(7), + ), + ), + newPos(7), + ), ), newPos(4), ), |