summaryrefslogtreecommitdiff
path: root/src/pkg/go/ast/ast.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-08-03 17:26:15 +0200
committerOndřej Surý <ondrej@sury.org>2011-08-03 17:31:49 +0200
commitb757d264230d65f988e08158e096a09497d39eb4 (patch)
treee20ec608a2ec8ebf603fa7aa060eb9723c4780b9 /src/pkg/go/ast/ast.go
parent5976088995f5c0d0bcada7d491fda4b6245e54e0 (diff)
downloadgolang-b757d264230d65f988e08158e096a09497d39eb4.tar.gz
Imported Upstream version 2011.07.29
Diffstat (limited to 'src/pkg/go/ast/ast.go')
-rw-r--r--src/pkg/go/ast/ast.go42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/pkg/go/ast/ast.go b/src/pkg/go/ast/ast.go
index b1c7d4ab1..22bd5ee22 100644
--- a/src/pkg/go/ast/ast.go
+++ b/src/pkg/go/ast/ast.go
@@ -13,7 +13,6 @@ import (
"utf8"
)
-
// ----------------------------------------------------------------------------
// Interfaces
//
@@ -31,35 +30,30 @@ import (
// That position information is needed to properly position comments
// when printing the construct.
-
// All node types implement the Node interface.
type Node interface {
Pos() token.Pos // position of first character belonging to the node
End() token.Pos // position of first character immediately after the node
}
-
// All expression nodes implement the Expr interface.
type Expr interface {
Node
exprNode()
}
-
// All statement nodes implement the Stmt interface.
type Stmt interface {
Node
stmtNode()
}
-
// All declaration nodes implement the Decl interface.
type Decl interface {
Node
declNode()
}
-
// ----------------------------------------------------------------------------
// Comments
@@ -69,11 +63,9 @@ type Comment struct {
Text string // comment text (excluding '\n' for //-style comments)
}
-
func (c *Comment) Pos() token.Pos { return c.Slash }
func (c *Comment) End() token.Pos { return token.Pos(int(c.Slash) + len(c.Text)) }
-
// A CommentGroup represents a sequence of comments
// with no other tokens and no empty lines between.
//
@@ -81,11 +73,9 @@ type CommentGroup struct {
List []*Comment // len(List) > 0
}
-
func (g *CommentGroup) Pos() token.Pos { return g.List[0].Pos() }
func (g *CommentGroup) End() token.Pos { return g.List[len(g.List)-1].End() }
-
// ----------------------------------------------------------------------------
// Expressions and types
@@ -101,7 +91,6 @@ type Field struct {
Comment *CommentGroup // line comments; or nil
}
-
func (f *Field) Pos() token.Pos {
if len(f.Names) > 0 {
return f.Names[0].Pos()
@@ -109,7 +98,6 @@ func (f *Field) Pos() token.Pos {
return f.Type.Pos()
}
-
func (f *Field) End() token.Pos {
if f.Tag != nil {
return f.Tag.End()
@@ -117,7 +105,6 @@ func (f *Field) End() token.Pos {
return f.Type.End()
}
-
// A FieldList represents a list of Fields, enclosed by parentheses or braces.
type FieldList struct {
Opening token.Pos // position of opening parenthesis/brace, if any
@@ -125,7 +112,6 @@ type FieldList struct {
Closing token.Pos // position of closing parenthesis/brace, if any
}
-
func (f *FieldList) Pos() token.Pos {
if f.Opening.IsValid() {
return f.Opening
@@ -138,7 +124,6 @@ func (f *FieldList) Pos() token.Pos {
return token.NoPos
}
-
func (f *FieldList) End() token.Pos {
if f.Closing.IsValid() {
return f.Closing + 1
@@ -151,7 +136,6 @@ func (f *FieldList) End() token.Pos {
return token.NoPos
}
-
// NumFields returns the number of (named and anonymous fields) in a FieldList.
func (f *FieldList) NumFields() int {
n := 0
@@ -167,7 +151,6 @@ func (f *FieldList) NumFields() int {
return n
}
-
// An expression is represented by a tree consisting of one
// or more of the following concrete expression nodes.
//
@@ -298,7 +281,6 @@ type (
}
)
-
// The direction of a channel type is indicated by one
// of the following constants.
//
@@ -309,7 +291,6 @@ const (
RECV
)
-
// A type is represented by a tree consisting of one
// or more of the following type-specific expression
// nodes.
@@ -360,7 +341,6 @@ type (
}
)
-
// Pos and End implementations for expression/type nodes.
//
func (x *BadExpr) Pos() token.Pos { return x.From }
@@ -391,7 +371,6 @@ func (x *InterfaceType) Pos() token.Pos { return x.Interface }
func (x *MapType) Pos() token.Pos { return x.Map }
func (x *ChanType) Pos() token.Pos { return x.Begin }
-
func (x *BadExpr) End() token.Pos { return x.To }
func (x *Ident) End() token.Pos { return token.Pos(int(x.NamePos) + len(x.Name)) }
func (x *Ellipsis) End() token.Pos {
@@ -430,7 +409,6 @@ func (x *InterfaceType) End() token.Pos { return x.Methods.End() }
func (x *MapType) End() token.Pos { return x.Value.End() }
func (x *ChanType) End() token.Pos { return x.Value.End() }
-
// exprNode() ensures that only expression/type nodes can be
// assigned to an ExprNode.
//
@@ -458,7 +436,6 @@ func (x *InterfaceType) exprNode() {}
func (x *MapType) exprNode() {}
func (x *ChanType) exprNode() {}
-
// ----------------------------------------------------------------------------
// Convenience functions for Idents
@@ -469,7 +446,6 @@ var noPos token.Pos
//
func NewIdent(name string) *Ident { return &Ident{noPos, name, nil} }
-
// IsExported returns whether name is an exported Go symbol
// (i.e., whether it begins with an uppercase letter).
//
@@ -478,13 +454,11 @@ func IsExported(name string) bool {
return unicode.IsUpper(ch)
}
-
// IsExported returns whether id is an exported Go symbol
// (i.e., whether it begins with an uppercase letter).
//
func (id *Ident) IsExported() bool { return IsExported(id.Name) }
-
func (id *Ident) String() string {
if id != nil {
return id.Name
@@ -492,7 +466,6 @@ func (id *Ident) String() string {
return "<nil>"
}
-
// ----------------------------------------------------------------------------
// Statements
@@ -660,7 +633,6 @@ type (
}
)
-
// Pos and End implementations for statement nodes.
//
func (s *BadStmt) Pos() token.Pos { return s.From }
@@ -685,7 +657,6 @@ func (s *SelectStmt) Pos() token.Pos { return s.Select }
func (s *ForStmt) Pos() token.Pos { return s.For }
func (s *RangeStmt) Pos() token.Pos { return s.For }
-
func (s *BadStmt) End() token.Pos { return s.To }
func (s *DeclStmt) End() token.Pos { return s.Decl.End() }
func (s *EmptyStmt) End() token.Pos {
@@ -737,7 +708,6 @@ func (s *SelectStmt) End() token.Pos { return s.Body.End() }
func (s *ForStmt) End() token.Pos { return s.Body.End() }
func (s *RangeStmt) End() token.Pos { return s.Body.End() }
-
// stmtNode() ensures that only statement nodes can be
// assigned to a StmtNode.
//
@@ -763,7 +733,6 @@ func (s *SelectStmt) stmtNode() {}
func (s *ForStmt) stmtNode() {}
func (s *RangeStmt) stmtNode() {}
-
// ----------------------------------------------------------------------------
// Declarations
@@ -805,7 +774,6 @@ type (
}
)
-
// Pos and End implementations for spec nodes.
//
func (s *ImportSpec) Pos() token.Pos {
@@ -817,7 +785,6 @@ func (s *ImportSpec) Pos() token.Pos {
func (s *ValueSpec) Pos() token.Pos { return s.Names[0].Pos() }
func (s *TypeSpec) Pos() token.Pos { return s.Name.Pos() }
-
func (s *ImportSpec) End() token.Pos { return s.Path.End() }
func (s *ValueSpec) End() token.Pos {
if n := len(s.Values); n > 0 {
@@ -830,7 +797,6 @@ func (s *ValueSpec) End() token.Pos {
}
func (s *TypeSpec) End() token.Pos { return s.Type.End() }
-
// specNode() ensures that only spec nodes can be
// assigned to a Spec.
//
@@ -838,7 +804,6 @@ func (s *ImportSpec) specNode() {}
func (s *ValueSpec) specNode() {}
func (s *TypeSpec) specNode() {}
-
// A declaration is represented by one of the following declaration nodes.
//
type (
@@ -880,14 +845,12 @@ type (
}
)
-
// Pos and End implementations for declaration nodes.
//
func (d *BadDecl) Pos() token.Pos { return d.From }
func (d *GenDecl) Pos() token.Pos { return d.TokPos }
func (d *FuncDecl) Pos() token.Pos { return d.Type.Pos() }
-
func (d *BadDecl) End() token.Pos { return d.To }
func (d *GenDecl) End() token.Pos {
if d.Rparen.IsValid() {
@@ -902,7 +865,6 @@ func (d *FuncDecl) End() token.Pos {
return d.Type.End()
}
-
// declNode() ensures that only declaration nodes can be
// assigned to a DeclNode.
//
@@ -910,7 +872,6 @@ func (d *BadDecl) declNode() {}
func (d *GenDecl) declNode() {}
func (d *FuncDecl) declNode() {}
-
// ----------------------------------------------------------------------------
// Files and packages
@@ -931,7 +892,6 @@ type File struct {
Comments []*CommentGroup // list of all comments in the source file
}
-
func (f *File) Pos() token.Pos { return f.Package }
func (f *File) End() token.Pos {
if n := len(f.Decls); n > 0 {
@@ -940,7 +900,6 @@ func (f *File) End() token.Pos {
return f.Name.End()
}
-
// A Package node represents a set of source files
// collectively building a Go package.
//
@@ -951,6 +910,5 @@ type Package struct {
Files map[string]*File // Go source files by filename
}
-
func (p *Package) Pos() token.Pos { return token.NoPos }
func (p *Package) End() token.Pos { return token.NoPos }