From 1886b2a4811a4d9adbfc509505a095848cc655eb Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 10 May 2019 17:15:29 +0200 Subject: pkg/ast: refactor COLON handling This prepared for handling of bytesize[parent:foo:bar] expressions by allowing multiple identifiers after colon. No functional changes for now, just preparation for storing more than one identifier after colon. --- pkg/ast/parser.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pkg/ast/parser.go') diff --git a/pkg/ast/parser.go b/pkg/ast/parser.go index bd9d33657..b68a1a8a2 100644 --- a/pkg/ast/parser.go +++ b/pkg/ast/parser.go @@ -425,16 +425,18 @@ func (p *parser) parseType() *Type { } p.next() if allowColon && p.tryConsume(tokColon) { - arg.HasColon = true - arg.Pos2 = p.pos + col := &Type{ + Pos: p.pos, + } switch p.tok { case tokInt: - arg.Value2, arg.Value2Fmt = p.parseIntValue() + col.Value, col.ValueFmt = p.parseIntValue() case tokIdent: - arg.Ident2 = p.lit + col.Ident = p.lit default: p.expect(tokInt, tokIdent) } + arg.Colon = append(arg.Colon, col) p.next() } arg.Args = p.parseTypeList() -- cgit mrf-deployment