Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix for changes in go/ast from last release.

Tested-on: collins (Linux 2.6.32-5-amd64)
  • Loading branch information...
commit 679a4294cc86923f07358a20365ff68b3917083a 1 parent a21870d
@droundy authored
View
2  Makefile
@@ -1,7 +1,7 @@
# Copyright 2010 David Roundy, roundyd@physics.oregonstate.edu.
# All rights reserved.
-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
TARG=go-crazy
View
2  go-crazy.go
@@ -33,7 +33,7 @@ func main() {
}
filename := goopt.Args[0]
- fileast,err := parser.ParseFile(filename, nil, nil, parser.ParseComments)
+ fileast,err := parser.ParseFile(filename, nil, parser.ParseComments)
if err != nil {
fmt.Println("Parse error:\n", err)
os.Exit(1)
View
2  parser/Makefile
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
TARG=github.com/droundy/go-crazy/parser
GOFILES=\
View
38 parser/interface.go
@@ -57,52 +57,52 @@ func (p *parser) parseEOF() os.Error {
// ParseExpr parses a Go expression and returns the corresponding
-// AST node. The filename, src, and scope arguments have the same interpretation
+// AST node. The filename and src arguments have the same interpretation
// as for ParseFile. If there is an error, the result expression
// may be nil or contain a partial AST.
//
-func ParseExpr(filename string, src interface{}, scope *ast.Scope) (ast.Expr, os.Error) {
+func ParseExpr(filename string, src interface{}) (ast.Expr, os.Error) {
data, err := readSource(filename, src)
if err != nil {
return nil, err
}
var p parser
- p.init(filename, data, scope, 0)
+ p.init(filename, data, 0)
return p.parseExpr(), p.parseEOF()
}
// ParseStmtList parses a list of Go statements and returns the list
-// of corresponding AST nodes. The filename, src, and scope arguments have the same
+// of corresponding AST nodes. The filename and src arguments have the same
// interpretation as for ParseFile. If there is an error, the node
// list may be nil or contain partial ASTs.
//
-func ParseStmtList(filename string, src interface{}, scope *ast.Scope) ([]ast.Stmt, os.Error) {
+func ParseStmtList(filename string, src interface{}) ([]ast.Stmt, os.Error) {
data, err := readSource(filename, src)
if err != nil {
return nil, err
}
var p parser
- p.init(filename, data, scope, 0)
+ p.init(filename, data, 0)
return p.parseStmtList(), p.parseEOF()
}
// ParseDeclList parses a list of Go declarations and returns the list
-// of corresponding AST nodes. The filename, src, and scope arguments have the same
+// of corresponding AST nodes. The filename and src arguments have the same
// interpretation as for ParseFile. If there is an error, the node
// list may be nil or contain partial ASTs.
//
-func ParseDeclList(filename string, src interface{}, scope *ast.Scope) ([]ast.Decl, os.Error) {
+func ParseDeclList(filename string, src interface{}) ([]ast.Decl, os.Error) {
data, err := readSource(filename, src)
if err != nil {
return nil, err
}
var p parser
- p.init(filename, data, scope, 0)
+ p.init(filename, data, 0)
return p.parseDeclList(), p.parseEOF()
}
@@ -116,11 +116,6 @@ func ParseDeclList(filename string, src interface{}, scope *ast.Scope) ([]ast.De
//
// If src == nil, ParseFile parses the file specified by filename.
//
-// If scope != nil, it is the immediately surrounding scope for the file
-// (the package scope) and it is used to lookup and declare identifiers.
-// When parsing multiple files belonging to a package, the same scope should
-// be provided to all files.
-//
// The mode parameter controls the amount of source text parsed and other
// optional parser functionality.
//
@@ -130,14 +125,14 @@ func ParseDeclList(filename string, src interface{}, scope *ast.Scope) ([]ast.De
// representing the fragments of erroneous source code). Multiple errors
// are returned via a scanner.ErrorList which is sorted by file position.
//
-func ParseFile(filename string, src interface{}, scope *ast.Scope, mode uint) (*ast.File, os.Error) {
+func ParseFile(filename string, src interface{}, mode uint) (*ast.File, os.Error) {
data, err := readSource(filename, src)
if err != nil {
return nil, err
}
var p parser
- p.init(filename, data, scope, mode)
+ p.init(filename, data, mode)
return p.parseFile(), p.GetError(scanner.NoMultiples) // parseFile() reads to EOF
}
@@ -150,14 +145,14 @@ func ParseFile(filename string, src interface{}, scope *ast.Scope, mode uint) (*
// be incomplete (missing packages and/or incomplete packages) and the first
// error encountered is returned.
//
-func ParseFiles(filenames []string, scope *ast.Scope, mode uint) (pkgs map[string]*ast.Package, first os.Error) {
+func ParseFiles(filenames []string, mode uint) (pkgs map[string]*ast.Package, first os.Error) {
pkgs = make(map[string]*ast.Package)
for _, filename := range filenames {
- if src, err := ParseFile(filename, nil, scope, mode); err == nil {
- name := src.Name.Name()
+ if src, err := ParseFile(filename, nil, mode); err == nil {
+ name := src.Name.Name
pkg, found := pkgs[name]
if !found {
- pkg = &ast.Package{name, scope, make(map[string]*ast.File)}
+ pkg = &ast.Package{name, nil, make(map[string]*ast.File)}
pkgs[name] = pkg
}
pkg.Files[filename] = src
@@ -201,6 +196,5 @@ func ParseDir(path string, filter func(*os.FileInfo) bool, mode uint) (map[strin
}
filenames = filenames[0:n]
- var scope *ast.Scope = nil // for now tracking of declarations is disabled
- return ParseFiles(filenames, scope, mode)
+ return ParseFiles(filenames, mode)
}
View
265 parser/parser.go
@@ -56,12 +56,6 @@ type parser struct {
// Non-syntactic parser control
exprLev int // < 0: in control clause, >= 0: in expression
-
- // Scopes
- checkDecl bool // if set, check declarations
- pkgScope *ast.Scope
- fileScope *ast.Scope
- funcScope *ast.Scope
}
@@ -75,16 +69,10 @@ func scannerMode(mode uint) uint {
}
-func (p *parser) init(filename string, src []byte, scope *ast.Scope, mode uint) {
+func (p *parser) init(filename string, src []byte, mode uint) {
p.scanner.Init(filename, src, p, scannerMode(mode))
p.mode = mode
p.trace = mode&Trace != 0 // for convenience (p.trace is used frequently)
- if scope != nil {
- p.checkDecl = true
- } else {
- scope = ast.NewScope(nil) // provide a dummy scope
- }
- p.pkgScope = scope
p.next()
}
@@ -276,39 +264,31 @@ func (p *parser) expectSemi() {
// ----------------------------------------------------------------------------
-// Scope support
-
-func (p *parser) openScope() *ast.Scope {
- p.funcScope = ast.NewScope(p.funcScope)
- return p.funcScope
-}
+// Identifiers
-
-func (p *parser) closeScope() { p.funcScope = p.funcScope.Outer }
-
-
-func (p *parser) parseIdent(kind ast.ObjKind) *ast.Ident {
- obj := ast.NewObj(kind, p.pos, "_")
+func (p *parser) parseIdent() *ast.Ident {
+ pos := p.pos
+ name := "_"
if p.tok == token.IDENT {
- obj.Name = string(p.lit)
+ name = string(p.lit)
p.next()
} else {
p.expect(token.IDENT) // use expect() error handling
}
- return &ast.Ident{obj.Pos, obj}
+ return &ast.Ident{pos, name, nil}
}
-func (p *parser) parseIdentList(kind ast.ObjKind) []*ast.Ident {
+func (p *parser) parseIdentList() []*ast.Ident {
if p.trace {
defer un(trace(p, "IdentList"))
}
var list vector.Vector
- list.Push(p.parseIdent(kind))
+ list.Push(p.parseIdent())
for p.tok == token.COMMA {
p.next()
- list.Push(p.parseIdent(kind))
+ list.Push(p.parseIdent())
}
// convert vector
@@ -321,82 +301,6 @@ func (p *parser) parseIdentList(kind ast.ObjKind) []*ast.Ident {
}
-func (p *parser) declIdent(scope *ast.Scope, id *ast.Ident) {
- decl := scope.Declare(id.Obj)
- if p.checkDecl && decl != id.Obj {
- if decl.Kind == ast.Err {
- // declared object is a forward declaration - update it
- *decl = *id.Obj
- id.Obj = decl
- return
- }
- p.Error(id.Pos(), "'"+id.Name()+"' declared already at "+decl.Pos.String())
- }
-}
-
-
-func (p *parser) declIdentList(scope *ast.Scope, list []*ast.Ident) {
- for _, id := range list {
- p.declIdent(scope, id)
- }
-}
-
-
-func (p *parser) declFieldList(scope *ast.Scope, list []*ast.Field) {
- for _, f := range list {
- p.declIdentList(scope, f.Names)
- }
-}
-
-
-func (p *parser) findIdent() *ast.Ident {
- pos := p.pos
- name := "_"
- var obj *ast.Object
- if p.tok == token.IDENT {
- name = string(p.lit)
- obj = p.funcScope.Lookup(name)
- p.next()
- } else {
- p.expect(token.IDENT) // use expect() error handling
- }
- if obj == nil {
- // No declaration found: either we are outside any function
- // (p.funcScope == nil) or the identifier is not declared
- // in any function. Try the file and package scope.
- obj = p.fileScope.Lookup(name) // file scope is nested in package scope
- if obj == nil {
- // No declaration found anywhere: track as
- // unresolved identifier in the package scope.
- obj = ast.NewObj(ast.Err, pos, name)
- p.pkgScope.Declare(obj)
- }
- }
- return &ast.Ident{pos, obj}
-}
-
-
-func (p *parser) findIdentInScope(scope *ast.Scope) *ast.Ident {
- pos := p.pos
- name := "_"
- var obj *ast.Object
- if p.tok == token.IDENT {
- name = string(p.lit)
- obj = scope.Lookup(name)
- p.next()
- } else {
- p.expect(token.IDENT) // use expect() error handling
- }
- if obj == nil {
- // TODO(gri) At the moment we always arrive here because
- // we don't track the lookup scope (and sometimes
- // we can't). Just create a useable ident for now.
- obj = ast.NewObj(ast.Err, pos, name)
- }
- return &ast.Ident{pos, obj}
-}
-
-
// ----------------------------------------------------------------------------
// Common productions
@@ -450,11 +354,11 @@ func (p *parser) parseQualifiedIdent() ast.Expr {
defer un(trace(p, "QualifiedIdent"))
}
- var x ast.Expr = p.findIdent()
+ var x ast.Expr = p.parseIdent()
if p.tok == token.PERIOD {
// first identifier is a package identifier
p.next()
- sel := p.findIdentInScope(nil)
+ sel := p.parseIdent()
x = &ast.SelectorExpr{x, sel}
}
return x
@@ -497,7 +401,7 @@ func (p *parser) makeIdentList(list *vector.Vector) []*ast.Ident {
if !isIdent {
pos := x.(ast.Expr).Pos()
p.errorExpected(pos, "identifier")
- ident = &ast.Ident{pos, ast.NewObj(ast.Err, pos, "_")}
+ ident = &ast.Ident{pos, "_", nil}
}
idents[i] = ident
}
@@ -565,9 +469,6 @@ func (p *parser) parseStructType() *ast.StructType {
fields[i] = x.(*ast.Field)
}
- // TODO(gri) The struct scope shouldn't get lost.
- p.declFieldList(ast.NewScope(nil), fields)
-
return &ast.StructType{pos, &ast.FieldList{lbrace, fields, rbrace}, false}
}
@@ -655,7 +556,7 @@ func (p *parser) parseParameterList(ellipsisOk bool) []*ast.Field {
}
for p.tok != token.RPAREN && p.tok != token.EOF {
- idents := p.parseIdentList(ast.Var)
+ idents := p.parseIdentList()
typ := p.parseVarType(ellipsisOk)
list.Push(&ast.Field{nil, idents, typ, nil, nil})
if p.tok != token.COMMA {
@@ -682,7 +583,7 @@ func (p *parser) parseParameterList(ellipsisOk bool) []*ast.Field {
}
-func (p *parser) parseParameters(scope *ast.Scope, ellipsisOk bool) *ast.FieldList {
+func (p *parser) parseParameters(ellipsisOk bool) *ast.FieldList {
if p.trace {
defer un(trace(p, "Parameters"))
}
@@ -691,7 +592,6 @@ func (p *parser) parseParameters(scope *ast.Scope, ellipsisOk bool) *ast.FieldLi
lparen := p.expect(token.LPAREN)
if p.tok != token.RPAREN {
params = p.parseParameterList(ellipsisOk)
- p.declFieldList(scope, params)
}
rparen := p.expect(token.RPAREN)
@@ -699,13 +599,13 @@ func (p *parser) parseParameters(scope *ast.Scope, ellipsisOk bool) *ast.FieldLi
}
-func (p *parser) parseResult(scope *ast.Scope) *ast.FieldList {
+func (p *parser) parseResult() *ast.FieldList {
if p.trace {
defer un(trace(p, "Result"))
}
if p.tok == token.LPAREN {
- return p.parseParameters(scope, false)
+ return p.parseParameters(false)
}
typ := p.tryType()
@@ -719,28 +619,27 @@ func (p *parser) parseResult(scope *ast.Scope) *ast.FieldList {
}
-func (p *parser) parseSignature(scope *ast.Scope) (params, results *ast.FieldList) {
+func (p *parser) parseSignature() (params, results *ast.FieldList) {
if p.trace {
defer un(trace(p, "Signature"))
}
- params = p.parseParameters(scope, true)
- results = p.parseResult(scope)
+ params = p.parseParameters(true)
+ results = p.parseResult()
return
}
-func (p *parser) parseFuncType() (*ast.Scope, *ast.FuncType) {
+func (p *parser) parseFuncType() *ast.FuncType {
if p.trace {
defer un(trace(p, "FuncType"))
}
pos := p.expect(token.FUNC)
- scope := ast.NewScope(p.funcScope)
- params, results := p.parseSignature(scope)
+ params, results := p.parseSignature()
- return scope, &ast.FuncType{pos, params, results}
+ return &ast.FuncType{pos, params, results}
}
@@ -756,7 +655,7 @@ func (p *parser) parseMethodSpec() *ast.Field {
if ident, isIdent := x.(*ast.Ident); isIdent && p.tok == token.LPAREN {
// method
idents = []*ast.Ident{ident}
- params, results := p.parseSignature(ast.NewScope(p.funcScope))
+ params, results := p.parseSignature()
typ = &ast.FuncType{noPos, params, results}
} else {
// embedded interface
@@ -787,9 +686,6 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
methods[i] = x.(*ast.Field)
}
- // TODO(gri) The interface scope shouldn't get lost.
- p.declFieldList(ast.NewScope(nil), methods)
-
return &ast.InterfaceType{pos, &ast.FieldList{lbrace, methods, rbrace}, false}
}
@@ -844,8 +740,7 @@ func (p *parser) tryRawType(ellipsisOk bool) ast.Expr {
case token.MUL:
return p.parsePointerType()
case token.FUNC:
- _, typ := p.parseFuncType()
- return typ
+ return p.parseFuncType()
case token.INTERFACE:
return p.parseInterfaceType()
case token.MAP:
@@ -894,20 +789,15 @@ func (p *parser) parseStmtList() []ast.Stmt {
}
-func (p *parser) parseBody(scope *ast.Scope) *ast.BlockStmt {
+func (p *parser) parseBody() *ast.BlockStmt {
if p.trace {
defer un(trace(p, "Body"))
}
- savedScope := p.funcScope
- p.funcScope = scope
-
lbrace := p.expect(token.LBRACE)
list := p.parseStmtList()
rbrace := p.expect(token.RBRACE)
- p.funcScope = savedScope
-
return &ast.BlockStmt{lbrace, list, rbrace}
}
@@ -917,9 +807,6 @@ func (p *parser) parseBlockStmt() *ast.BlockStmt {
defer un(trace(p, "BlockStmt"))
}
- p.openScope()
- defer p.closeScope()
-
lbrace := p.expect(token.LBRACE)
list := p.parseStmtList()
rbrace := p.expect(token.RBRACE)
@@ -936,14 +823,14 @@ func (p *parser) parseFuncTypeOrLit() ast.Expr {
defer un(trace(p, "FuncTypeOrLit"))
}
- scope, typ := p.parseFuncType()
+ typ := p.parseFuncType()
if p.tok != token.LBRACE {
// function type only
return typ
}
p.exprLev++
- body := p.parseBody(scope)
+ body := p.parseBody()
p.exprLev--
return &ast.FuncLit{typ, body}
@@ -960,7 +847,7 @@ func (p *parser) parseOperand() ast.Expr {
switch p.tok {
case token.IDENT:
- return p.findIdent()
+ return p.parseIdent()
case token.INT, token.FLOAT, token.IMAG, token.CHAR, token.STRING:
x := &ast.BasicLit{p.pos, p.tok, p.lit}
@@ -1000,7 +887,7 @@ func (p *parser) parseSelectorOrTypeAssertion(x ast.Expr) ast.Expr {
p.expect(token.PERIOD)
if p.tok == token.IDENT {
// selector
- sel := p.findIdentInScope(nil)
+ sel := p.parseIdent()
return &ast.SelectorExpr{x, sel}
}
@@ -1461,7 +1348,7 @@ func (p *parser) parseBranchStmt(tok token.Token) *ast.BranchStmt {
s := &ast.BranchStmt{p.pos, tok, nil}
p.expect(tok)
if tok != token.FALLTHROUGH && p.tok == token.IDENT {
- s.Label = p.findIdentInScope(nil)
+ s.Label = p.parseIdent()
}
p.expectSemi()
@@ -1517,10 +1404,6 @@ func (p *parser) parseIfStmt() *ast.IfStmt {
defer un(trace(p, "IfStmt"))
}
- // IfStmt block
- p.openScope()
- defer p.closeScope()
-
pos := p.expect(token.IF)
s1, s2, _ := p.parseControlClause(false)
body := p.parseBlockStmt()
@@ -1541,10 +1424,6 @@ func (p *parser) parseCaseClause() *ast.CaseClause {
defer un(trace(p, "CaseClause"))
}
- // CaseClause block
- p.openScope()
- defer p.closeScope()
-
// SwitchCase
pos := p.pos
var x []ast.Expr
@@ -1583,10 +1462,6 @@ func (p *parser) parseTypeCaseClause() *ast.TypeCaseClause {
defer un(trace(p, "TypeCaseClause"))
}
- // TypeCaseClause block
- p.openScope()
- defer p.closeScope()
-
// TypeSwitchCase
pos := p.pos
var types []ast.Expr
@@ -1623,10 +1498,6 @@ func (p *parser) parseSwitchStmt() ast.Stmt {
defer un(trace(p, "SwitchStmt"))
}
- // SwitchStmt block
- p.openScope()
- defer p.closeScope()
-
pos := p.expect(token.SWITCH)
s1, s2, _ := p.parseControlClause(false)
@@ -1661,10 +1532,6 @@ func (p *parser) parseCommClause() *ast.CommClause {
defer un(trace(p, "CommClause"))
}
- // CommClause block
- p.openScope()
- defer p.closeScope()
-
// CommCase
pos := p.pos
var tok token.Token
@@ -1725,10 +1592,6 @@ func (p *parser) parseForStmt() ast.Stmt {
defer un(trace(p, "ForStmt"))
}
- // ForStmt block
- p.openScope()
- defer p.closeScope()
-
pos := p.expect(token.FOR)
s1, s2, s3 := p.parseControlClause(true)
body := p.parseBlockStmt()
@@ -1841,14 +1704,10 @@ func parseImportSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
var ident *ast.Ident
if p.tok == token.PERIOD {
- ident = &ast.Ident{p.pos, ast.NewObj(ast.Pkg, p.pos, ".")}
+ ident = &ast.Ident{p.pos, ".", nil}
p.next()
} else if p.tok == token.IDENT {
- ident = p.parseIdent(ast.Pkg)
- // TODO(gri) Make sure the ident is not already declared in the
- // package scope. Also, cannot add the same name to
- // the package scope later.
- p.declIdent(p.fileScope, ident)
+ ident = p.parseIdent()
}
var path *ast.BasicLit
@@ -1869,23 +1728,13 @@ func parseConstSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
defer un(trace(p, "ConstSpec"))
}
- idents := p.parseIdentList(ast.Con)
- if p.funcScope == nil {
- // the scope of a constant outside any function
- // is the package scope
- p.declIdentList(p.pkgScope, idents)
- }
+ idents := p.parseIdentList()
typ := p.tryType()
var values []ast.Expr
if typ != nil || p.tok == token.ASSIGN {
p.expect(token.ASSIGN)
values = p.parseExprList()
}
- if p.funcScope != nil {
- // the scope of a constant inside a function
- // begins after the the ConstSpec
- p.declIdentList(p.funcScope, idents)
- }
p.expectSemi()
return &ast.ValueSpec{doc, idents, typ, values, p.lineComment}
@@ -1897,15 +1746,7 @@ func parseTypeSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
defer un(trace(p, "TypeSpec"))
}
- ident := p.parseIdent(ast.Typ)
- // the scope of a type outside any function is
- // the package scope; the scope of a type inside
- // a function starts at the type identifier
- scope := p.funcScope
- if scope == nil {
- scope = p.pkgScope
- }
- p.declIdent(scope, ident)
+ ident := p.parseIdent()
typ := p.parseType()
p.expectSemi()
@@ -1918,23 +1759,13 @@ func parseVarSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
defer un(trace(p, "VarSpec"))
}
- idents := p.parseIdentList(ast.Var)
- if p.funcScope == nil {
- // the scope of a variable outside any function
- // is the pkgScope
- p.declIdentList(p.pkgScope, idents)
- }
+ idents := p.parseIdentList()
typ := p.tryType()
var values []ast.Expr
if typ == nil || p.tok == token.ASSIGN {
p.expect(token.ASSIGN)
values = p.parseExprList()
}
- if p.funcScope != nil {
- // the scope of a variable inside a function
- // begins after the the VarSpec
- p.declIdentList(p.funcScope, idents)
- }
p.expectSemi()
return &ast.ValueSpec{doc, idents, typ, values, p.lineComment}
@@ -1972,13 +1803,13 @@ func (p *parser) parseGenDecl(keyword token.Token, f parseSpecFunction) *ast.Gen
}
-func (p *parser) parseReceiver(scope *ast.Scope) *ast.FieldList {
+func (p *parser) parseReceiver() *ast.FieldList {
if p.trace {
defer un(trace(p, "Receiver"))
}
pos := p.pos
- par := p.parseParameters(scope, false)
+ par := p.parseParameters(false)
// must have exactly one receiver
if par.NumFields() != 1 {
@@ -1989,7 +1820,6 @@ func (p *parser) parseReceiver(scope *ast.Scope) *ast.FieldList {
// recv type must be of the form ["*"] identifier
recv := par.List[0]
-
base := deref(recv.Type)
if _, isIdent := base.(*ast.Ident); !isIdent {
p.errorExpected(base.Pos(), "(unqualified) identifier")
@@ -2020,31 +1850,29 @@ func (p *parser) parseFuncDecl() *ast.FuncDecl {
doc := p.leadComment
pos := p.expect(token.FUNC)
- scope := ast.NewScope(p.funcScope)
var recv *ast.FieldList
if p.tok == token.LPAREN {
- recv = p.parseReceiver(scope)
+ recv = p.parseReceiver()
}
- ident := ast.NewIdent("foo")
+ ident := &ast.Ident{ p.pos, "", nil }
switch p.tok {
case token.ADD, token.ADD_ASSIGN, token.SUB, token.SUB_ASSIGN, token.MUL, token.MUL_ASSIGN, token.QUO, token.QUO_ASSIGN:
if string(p.lit) == "*." {
- ident = ast.NewIdent("_mul_dot")
+ ident.Name = "_mul_dot"
} else {
- ident = ast.NewIdent(MungeOperator(p.tok))
+ ident.Name = MungeOperator(p.tok)
}
p.expect(p.tok) // hokey!
default:
- ident = p.parseIdent(ast.Fun)
+ ident = p.parseIdent()
}
- p.declIdent(p.pkgScope, ident) // there are no local function declarations
- params, results := p.parseSignature(scope)
+ params, results := p.parseSignature()
var body *ast.BlockStmt
if p.tok == token.LBRACE {
- body = p.parseBody(scope)
+ body = p.parseBody()
}
p.expectSemi()
@@ -2114,10 +1942,9 @@ func (p *parser) parseFile() *ast.File {
// package clause
doc := p.leadComment
pos := p.expect(token.PACKAGE)
- ident := p.parseIdent(ast.Pkg) // package name is in no scope
+ ident := p.parseIdent()
p.expectSemi()
- p.fileScope = ast.NewScope(p.pkgScope)
var decls []ast.Decl
// Don't bother parsing the rest if we had errors already.
View
2  scanner/Makefile
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
TARG=github.com/droundy/go-crazy/scanner
GOFILES=\
View
2  testfiles/example.go.sh
@@ -9,7 +9,7 @@ grep _dot_sub example-compiled.go
./example | grep 'Hello world!'
cat > Makefile <<EOF
-include \$(GOROOT)/src/Make.\$(GOARCH)
+include \$(GOROOT)/src/Make.inc
TARG=foo
View
2  transform/Makefile
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
-include $(GOROOT)/src/Make.$(GOARCH)
+include $(GOROOT)/src/Make.inc
TARG=github.com/droundy/go-crazy/transform
GOFILES=\
Please sign in to comment.
Something went wrong with that request. Please try again.