diff options
author | Russ Cox <rsc@golang.org> | 2009-04-16 20:52:37 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-04-16 20:52:37 -0700 |
commit | c93d66a312c9b1a271cf3a68c84c5e9f98cefd37 (patch) | |
tree | fc0d1bfb34a87c27e16c2bc4978b7cf4dd7b134e /src/lib/go | |
parent | 1a5a70789067ecf10d6a560c873c8a5552c6e82d (diff) | |
download | golang-c93d66a312c9b1a271cf3a68c84c5e9f98cefd37.tar.gz |
Convert go tree to hierarchical pkg directory:
import (
"vector" -> "container/vector"
"ast" -> "go/ast"
"sha1" -> "hash/sha1"
etc.
)
and update Makefiles. Because I did the conversion
semi-automatically, I sorted all the import blocks
as a post-processing. Some files have therefore
changed that didn't strictly need to.
Rename local packages to lower case.
The upper/lower distinction doesn't work on OS X
and complicates the "single-package directories
with the same package name as directory name"
heuristic used by gobuild and godoc to create
the correlation between source and binary locations.
Now that we have a plan to avoid globally unique
names, the upper/lower is unnecessary.
The renamings will cause trouble for a few users,
but so will the change in import paths.
This way, the two maintenance fixes are rolled into
one inconvenience.
R=r
OCL=27573
CL=27575
Diffstat (limited to 'src/lib/go')
-rw-r--r-- | src/lib/go/Makefile | 44 | ||||
-rw-r--r-- | src/lib/go/ast.go | 2 | ||||
-rw-r--r-- | src/lib/go/parser.go | 38 | ||||
-rw-r--r-- | src/lib/go/parser_test.go | 4 | ||||
-rw-r--r-- | src/lib/go/scanner.go | 6 | ||||
-rw-r--r-- | src/lib/go/scanner_test.go | 4 |
6 files changed, 51 insertions, 47 deletions
diff --git a/src/lib/go/Makefile b/src/lib/go/Makefile index 5cfb54985..bfe1cede3 100644 --- a/src/lib/go/Makefile +++ b/src/lib/go/Makefile @@ -5,13 +5,15 @@ # DO NOT EDIT. Automatically generated by gobuild. # gobuild -m >Makefile +D=/go + O_arm=5 O_amd64=6 O_386=8 OS=568vq O=$(O_$(GOARCH)) -GC=$(O)g +GC=$(O)g -I_obj CC=$(O)c -FVw AS=$(O)a AR=6ar @@ -19,7 +21,7 @@ AR=6ar default: packages clean: - rm -f *.[$(OS)] *.a [$(OS)].out + rm -rf *.[$(OS)] *.a [$(OS)].out _obj test: packages gotest @@ -49,30 +51,31 @@ O3=\ phases: a1 a2 a3 -ast.a: phases -parser.a: phases -scanner.a: phases -token.a: phases +_obj$D/ast.a: phases +_obj$D/parser.a: phases +_obj$D/scanner.a: phases +_obj$D/token.a: phases a1: $(O1) - $(AR) grc token.a token.$O + $(AR) grc _obj$D/token.a token.$O rm -f $(O1) a2: $(O2) - $(AR) grc scanner.a scanner.$O - $(AR) grc ast.a ast.$O + $(AR) grc _obj$D/scanner.a scanner.$O + $(AR) grc _obj$D/ast.a ast.$O rm -f $(O2) a3: $(O3) - $(AR) grc parser.a parser.$O + $(AR) grc _obj$D/parser.a parser.$O rm -f $(O3) newpkg: clean - $(AR) grc ast.a - $(AR) grc parser.a - $(AR) grc scanner.a - $(AR) grc token.a + mkdir -p _obj$D + $(AR) grc _obj$D/ast.a + $(AR) grc _obj$D/parser.a + $(AR) grc _obj$D/scanner.a + $(AR) grc _obj$D/token.a $(O1): newpkg $(O2): a1 @@ -80,12 +83,13 @@ $(O3): a2 $(O4): a3 nuke: clean - rm -f $(GOROOT)/pkg/ast.a $(GOROOT)/pkg/parser.a $(GOROOT)/pkg/scanner.a $(GOROOT)/pkg/token.a + rm -f $(GOROOT)/pkg$D/ast.a $(GOROOT)/pkg$D/parser.a $(GOROOT)/pkg$D/scanner.a $(GOROOT)/pkg$D/token.a -packages: ast.a parser.a scanner.a token.a +packages: _obj$D/ast.a _obj$D/parser.a _obj$D/scanner.a _obj$D/token.a install: packages - cp ast.a $(GOROOT)/pkg/ast.a - cp parser.a $(GOROOT)/pkg/parser.a - cp scanner.a $(GOROOT)/pkg/scanner.a - cp token.a $(GOROOT)/pkg/token.a + test -d $(GOROOT)/pkg && mkdir -p $(GOROOT)/pkg$D + cp _obj$D/ast.a $(GOROOT)/pkg$D/ast.a + cp _obj$D/parser.a $(GOROOT)/pkg$D/parser.a + cp _obj$D/scanner.a $(GOROOT)/pkg$D/scanner.a + cp _obj$D/token.a $(GOROOT)/pkg$D/token.a diff --git a/src/lib/go/ast.go b/src/lib/go/ast.go index beaa743ac..6045c945f 100644 --- a/src/lib/go/ast.go +++ b/src/lib/go/ast.go @@ -8,7 +8,7 @@ package ast import ( - "token"; + "go/token"; "unicode"; "utf8"; ) diff --git a/src/lib/go/parser.go b/src/lib/go/parser.go index 6cabaa7fe..f3a5d1233 100644 --- a/src/lib/go/parser.go +++ b/src/lib/go/parser.go @@ -10,12 +10,12 @@ package parser import ( - "ast"; + "container/vector"; "fmt"; + "go/ast"; + "go/scanner"; + "go/token"; "io"; - "scanner"; - "token"; - "vector"; ) @@ -135,7 +135,7 @@ func (p *parser) collectComment() int { } p.comments.Push(&ast.Comment{p.pos, p.lit, endline}); p.next0(); - + return endline; } @@ -155,7 +155,7 @@ func (p *parser) getComments() interval { func (p *parser) getDoc() ast.Comments { doc := p.last_doc; n := doc.end - doc.beg; - + if n <= 0 || p.comments.At(doc.end - 1).(*ast.Comment).EndLine + 1 < p.pos.Line { // no comments or empty line between last comment and current token; // do not use as documentation @@ -348,7 +348,7 @@ func (p *parser) parseArrayOrSliceType(ellipsis_ok bool) ast.Expr { if len != nil { return &ast.ArrayType{lbrack, len, elt}; } - + return &ast.SliceType{lbrack, elt}; } @@ -769,7 +769,7 @@ func (p *parser) parseStatementList() []ast.Stmt { expect_semi = true; } } - + return makeStmtList(list); } @@ -800,7 +800,7 @@ func (p *parser) parseStringList(x *ast.StringLit) []*ast.StringLit { if x != nil { list.Push(x); } - + for p.tok == token.STRING { list.Push(&ast.StringLit{p.pos, p.lit}); p.next(); @@ -811,7 +811,7 @@ func (p *parser) parseStringList(x *ast.StringLit) []*ast.StringLit { for i := 0; i < list.Len(); i++ { strings[i] = list.At(i).(*ast.StringLit); } - + return strings; } @@ -972,7 +972,7 @@ func (p *parser) parseKeyValueExpr() ast.Expr { value := p.parseExpression(); return &ast.KeyValueExpr{key, colon, value}; } - + return key; } @@ -1010,13 +1010,13 @@ func (p *parser) parseExpressionOrKeyValueList() []ast.Expr { break; } } - + // convert list elts := make([]ast.Expr, list.Len()); for i := 0; i < list.Len(); i++ { elts[i] = list.At(i).(ast.Expr); } - + return elts; } @@ -1133,7 +1133,7 @@ func (p *parser) checkExprOrType(x ast.Expr) ast.Expr { x = &ast.BadExpr{x.Pos()}; } } - + // all other nodes are expressions or types return x; } @@ -1386,7 +1386,7 @@ func (p *parser) parseControlClause(isForStmt bool) (s1, s2, s3 ast.Stmt) { } else { s1, s2 = nil, s1; } - + p.expr_lev = prev_lev; } @@ -1426,7 +1426,7 @@ func (p *parser) parseCaseClause() *ast.CaseClause { } else { p.expect(token.DEFAULT); } - + colon := p.expect(token.COLON); body := p.parseStatementList(); @@ -1594,7 +1594,7 @@ func (p *parser) parseForStmt() ast.Stmt { // regular for statement return &ast.ForStmt{pos, s1, p.makeExpr(s2), s3, body}; } - + panic(); // unreachable return nil; } @@ -1824,7 +1824,7 @@ func (p *parser) parseDeclaration() ast.Decl { p.next(); // make progress return &ast.BadDecl{pos}; } - + return p.parseGenDecl(p.tok, f); } @@ -1941,7 +1941,7 @@ func readSource(src interface{}, err ErrorHandler) []byte { // Parse returns an AST and the boolean value true if no errors occured; // it returns a partial AST (or nil if the source couldn't be read) and // the boolean value false to indicate failure. -// +// // If syntax errors were found, the AST may only be constructed partially, // with ast.BadX nodes representing the fragments of erroneous source code. // diff --git a/src/lib/go/parser_test.go b/src/lib/go/parser_test.go index 715d464db..e35d18799 100644 --- a/src/lib/go/parser_test.go +++ b/src/lib/go/parser_test.go @@ -5,9 +5,9 @@ package parser import ( - "ast"; + "go/ast"; + "go/parser"; "os"; - "parser"; "testing"; ) diff --git a/src/lib/go/scanner.go b/src/lib/go/scanner.go index ea5f13769..7cfc48d88 100644 --- a/src/lib/go/scanner.go +++ b/src/lib/go/scanner.go @@ -9,10 +9,10 @@ package scanner import ( - "utf8"; - "unicode"; + "go/token"; "strconv"; - "token"; + "unicode"; + "utf8"; ) diff --git a/src/lib/go/scanner_test.go b/src/lib/go/scanner_test.go index f6edea10a..19fe9864f 100644 --- a/src/lib/go/scanner_test.go +++ b/src/lib/go/scanner_test.go @@ -5,9 +5,9 @@ package scanner import ( + "go/scanner"; + "go/token"; "io"; - "token"; - "scanner"; "testing"; ) |