From 0a63c6d2fb7e78c668b7bf012fe64ebff3868f38 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Thu, 19 May 2022 18:05:09 +0000 Subject: [PATCH] tint: intrinsic-gen: Fix parsing of multiple decorations Change-Id: I61365dea17ab9174cfcb2d513cf1f7ee28ce0647 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90528 Reviewed-by: David Neto Commit-Queue: Ben Clayton --- tools/src/cmd/intrinsic-gen/parser/parser.go | 2 +- tools/src/cmd/intrinsic-gen/parser/parser_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/src/cmd/intrinsic-gen/parser/parser.go b/tools/src/cmd/intrinsic-gen/parser/parser.go index b0acb44c38..f381b3a7b0 100644 --- a/tools/src/cmd/intrinsic-gen/parser/parser.go +++ b/tools/src/cmd/intrinsic-gen/parser/parser.go @@ -154,7 +154,7 @@ func (p *parser) decorations() ast.Decorations { Name: string(name.Runes), Values: values, }) - if !p.peekIs(0, tok.Comma) { + if p.match(tok.Comma) == nil { break } } diff --git a/tools/src/cmd/intrinsic-gen/parser/parser_test.go b/tools/src/cmd/intrinsic-gen/parser/parser_test.go index 0ca1f686bc..0dea9b3239 100644 --- a/tools/src/cmd/intrinsic-gen/parser/parser_test.go +++ b/tools/src/cmd/intrinsic-gen/parser/parser_test.go @@ -90,6 +90,18 @@ func TestParser(t *testing.T) { Name: "T", }}, }, + }, { /////////////////////////////////////////////////////////////////// + utils.ThisLine(), + "[[deco_a, deco_b]] type T", + ast.AST{ + Types: []ast.TypeDecl{{ + Decorations: ast.Decorations{ + {Name: "deco_a", Values: []string{}}, + {Name: "deco_b", Values: []string{}}, + }, + Name: "T", + }}, + }, }, { /////////////////////////////////////////////////////////////////// utils.ThisLine(), `[[deco("a", "b")]] type T`, ast.AST{