go/ast: reflect communication operator changes accurately in ast
- go/ast: introduce SendStmt; adjust SelectStmt
- go/parser: accept new communication syntax, minor
unrelated cleanups
- go/printer: adjustments for new ast, fewer binary
expression precedences
- go/token: remove one binary precedence
Adjusted dependent code. gofmt -w src -misc. Ran all tests.
http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go File src/pkg/go/parser/parser.go (right): http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go#newcode1522 src/pkg/go/parser/parser.go:1522: arrow := p.expect(token.ARROW) Again I'm not sure that I'm ...
14 years, 1 month ago
(2011-02-01 19:13:22 UTC)
#4
http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go
File src/pkg/go/parser/parser.go (right):
http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go#...
src/pkg/go/parser/parser.go:1522: arrow := p.expect(token.ARROW)
Again I'm not sure that I'm reading this right, but what about
case <-1+2
Obviously that can't type check but I believe it should parse
as (<-1)+2 while this code would parse it as <-(1+2).
I think that, like in the last change, this should call p.parseExprList
and then check that len(list) == 1 and list[0] is a UnaryExpr with token.ARROW.
The interpretation I am proposing is different from the spec
(the code here now agrees with the spec). I think the spec
should be changed too. The rationale is that otherwise the
AssignStmts in:
x = <-1+2
case x = <-1+2
have different parse trees.
Similarly
case <-1+2
case x = <-1+2
would have different parse trees for the expression.
It may never come up (unless we allow operator methods),
but we should probably be consistent nonetheless.
http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go#...
src/pkg/go/parser/parser.go:1535: p.errorExpected(lhs.Pos(), "receive
operation")
s/receive/send or receive/
(depends on what the user intended.
select admits both. otherwise writing
case x < 1:
(< instead of <-) will say receive operation expected.
14 years, 1 month ago
(2011-02-01 21:25:38 UTC)
#5
PTAL
http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go
File src/pkg/go/parser/parser.go (right):
http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go#...
src/pkg/go/parser/parser.go:1522: arrow := p.expect(token.ARROW)
On 2011/02/01 19:13:22, rsc wrote:
> Again I'm not sure that I'm reading this right, but what about
>
> case <-1+2
>
> Obviously that can't type check but I believe it should parse
> as (<-1)+2 while this code would parse it as <-(1+2).
> I think that, like in the last change, this should call p.parseExprList
> and then check that len(list) == 1 and list[0] is a UnaryExpr with
token.ARROW.
>
> The interpretation I am proposing is different from the spec
> (the code here now agrees with the spec). I think the spec
> should be changed too. The rationale is that otherwise the
> AssignStmts in:
>
> x = <-1+2
> case x = <-1+2
>
> have different parse trees.
>
> Similarly
>
> case <-1+2
> case x = <-1+2
>
> would have different parse trees for the expression.
>
> It may never come up (unless we allow operator methods),
> but we should probably be consistent nonetheless.
Done.
http://codereview.appspot.com/3989056/diff/14001/src/pkg/go/parser/parser.go#...
src/pkg/go/parser/parser.go:1535: p.errorExpected(lhs.Pos(), "receive
operation")
On 2011/02/01 19:13:22, rsc wrote:
> s/receive/send or receive/
>
> (depends on what the user intended.
> select admits both. otherwise writing
>
> case x < 1:
>
> (< instead of <-) will say receive operation expected.
>
Done.
Issue 3989056: code review 3989056: go/ast: reflect communication operator changes accurate...
(Closed)
Created 14 years, 1 month ago by gri
Modified 14 years, 1 month ago
Reviewers:
Base URL:
Comments: 10