diff options
| author | griesemer <gri@golang.org> | 2017-10-11 15:02:10 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2017-10-16 17:18:32 +0000 |
| commit | f8f0d6c4deab0837b03ddccfe0edf775c3bbd49f (patch) | |
| tree | 531a33b903d3364538aed605f20fd9639d9d2049 /src/cmd/compile/internal/syntax/parser.go | |
| parent | 4b7325c7e30fcfd3aec4bc5968069c07f0f48e21 (diff) | |
| download | go-f8f0d6c4deab0837b03ddccfe0edf775c3bbd49f.tar.xz | |
cmd/compile/internal/syntax: match argument and parameter parsing (cleanup)
No semantic change. Move functionality not related to argument
out of the argument parsing function, and thus match parameter
parsing. Also, use a better function name.
Change-Id: Ic550875251d64e6fe1ebf91c11d33a9e4aec9fdd
Reviewed-on: https://go-review.googlesource.com/70491
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/parser.go')
| -rw-r--r-- | src/cmd/compile/internal/syntax/parser.go | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index b967279089..c7c86be27f 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -875,7 +875,11 @@ loop: p.xnest-- case _Lparen: - x = p.call(x) + t := new(CallExpr) + t.pos = pos + t.Fun = x + t.ArgList, t.HasDots = p.argList() + x = t case _Lbrace: // operand may have returned a parenthesized complit @@ -2062,24 +2066,18 @@ func (p *parser) stmtList() (l []Stmt) { } // Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" . -func (p *parser) call(fun Expr) *CallExpr { +func (p *parser) argList() (list []Expr, hasDots bool) { if trace { - defer p.trace("call")() + defer p.trace("argList")() } - // call or conversion - // convtype '(' expr ocomma ')' - c := new(CallExpr) - c.pos = p.pos() - c.Fun = fun - p.want(_Lparen) p.xnest++ for p.tok != _EOF && p.tok != _Rparen { - c.ArgList = append(c.ArgList, p.expr()) - c.HasDots = p.got(_DotDotDot) - if !p.ocomma(_Rparen) || c.HasDots { + list = append(list, p.expr()) + hasDots = p.got(_DotDotDot) + if !p.ocomma(_Rparen) || hasDots { break } } @@ -2087,7 +2085,7 @@ func (p *parser) call(fun Expr) *CallExpr { p.xnest-- p.want(_Rparen) - return c + return } // ---------------------------------------------------------------------------- |
