Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(699)

Side by Side Diff: src/pkg/go/ast/ast.go

Issue 2319041: code review 2319041: go ast/parser/printer: permit elision of composite lite... (Closed)
Patch Set: code review 2319041: go ast/parser/printer: permit elision of composite lite... Created 13 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/gofmt/testdata/test.sh ('k') | src/pkg/go/parser/parser.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // The AST package declares the types used to represent 5 // The AST package declares the types used to represent
6 // syntax trees for Go packages. 6 // syntax trees for Go packages.
7 // 7 //
8 package ast 8 package ast
9 9
10 import ( 10 import (
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 // A FuncLit node represents a function literal. 163 // A FuncLit node represents a function literal.
164 FuncLit struct { 164 FuncLit struct {
165 Type *FuncType // function type 165 Type *FuncType // function type
166 Body *BlockStmt // function body 166 Body *BlockStmt // function body
167 } 167 }
168 168
169 // A CompositeLit node represents a composite literal. 169 // A CompositeLit node represents a composite literal.
170 CompositeLit struct { 170 CompositeLit struct {
171 » » Type Expr // literal type 171 » » Type Expr // literal type; or nil
172 Lbrace token.Position // position of "{" 172 Lbrace token.Position // position of "{"
173 Elts []Expr // list of composite elements 173 Elts []Expr // list of composite elements
174 Rbrace token.Position // position of "}" 174 Rbrace token.Position // position of "}"
175 } 175 }
176 176
177 // A ParenExpr node represents a parenthesized expression. 177 // A ParenExpr node represents a parenthesized expression.
178 ParenExpr struct { 178 ParenExpr struct {
179 token.Position // position of "(" 179 token.Position // position of "("
180 X Expr // parenthesized expression 180 X Expr // parenthesized expression
181 Rparen token.Position // position of ")" 181 Rparen token.Position // position of ")"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 token.Position // position of "chan" keyword or "<-" (wh ichever comes first) 311 token.Position // position of "chan" keyword or "<-" (wh ichever comes first)
312 Dir ChanDir // channel direction 312 Dir ChanDir // channel direction
313 Value Expr // value type 313 Value Expr // value type
314 } 314 }
315 ) 315 )
316 316
317 317
318 // Pos() implementations for expression/type where the position 318 // Pos() implementations for expression/type where the position
319 // corresponds to the position of a sub-node. 319 // corresponds to the position of a sub-node.
320 // 320 //
321 func (x *FuncLit) Pos() token.Position { return x.Type.Pos() } 321 func (x *FuncLit) Pos() token.Position { return x.Type.Pos() }
322 func (x *CompositeLit) Pos() token.Position { return x.Type.Pos() } 322 func (x *CompositeLit) Pos() token.Position {
323 » if x.Type != nil {
324 » » return x.Type.Pos()
325 » }
326 » return x.Lbrace
327 }
323 func (x *SelectorExpr) Pos() token.Position { return x.X.Pos() } 328 func (x *SelectorExpr) Pos() token.Position { return x.X.Pos() }
324 func (x *IndexExpr) Pos() token.Position { return x.X.Pos() } 329 func (x *IndexExpr) Pos() token.Position { return x.X.Pos() }
325 func (x *SliceExpr) Pos() token.Position { return x.X.Pos() } 330 func (x *SliceExpr) Pos() token.Position { return x.X.Pos() }
326 func (x *TypeAssertExpr) Pos() token.Position { return x.X.Pos() } 331 func (x *TypeAssertExpr) Pos() token.Position { return x.X.Pos() }
327 func (x *CallExpr) Pos() token.Position { return x.Fun.Pos() } 332 func (x *CallExpr) Pos() token.Position { return x.Fun.Pos() }
328 func (x *BinaryExpr) Pos() token.Position { return x.X.Pos() } 333 func (x *BinaryExpr) Pos() token.Position { return x.X.Pos() }
329 func (x *KeyValueExpr) Pos() token.Position { return x.Key.Pos() } 334 func (x *KeyValueExpr) Pos() token.Position { return x.Key.Pos() }
330 335
331 336
332 // exprNode() ensures that only expression/type nodes can be 337 // exprNode() ensures that only expression/type nodes can be
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 736
732 737
733 // A Package node represents a set of source files 738 // A Package node represents a set of source files
734 // collectively building a Go package. 739 // collectively building a Go package.
735 // 740 //
736 type Package struct { 741 type Package struct {
737 Name string // package name 742 Name string // package name
738 Scope *Scope // package scope; or nil 743 Scope *Scope // package scope; or nil
739 Files map[string]*File // Go source files by filename 744 Files map[string]*File // Go source files by filename
740 } 745 }
OLDNEW
« no previous file with comments | « src/cmd/gofmt/testdata/test.sh ('k') | src/pkg/go/parser/parser.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b