]> Cypherpunks repositories - gostls13.git/commit
go/ast, go/parser: populate identifier scopes at parse time
authorRobert Griesemer <gri@golang.org>
Mon, 7 Mar 2011 19:01:23 +0000 (11:01 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 7 Mar 2011 19:01:23 +0000 (11:01 -0800)
commit021b040a1e9a6551dcaed2acfec0232f740ee416
tree0b2879263961134408c3027d981dd4a6f1bf8a64
parent4b4a1ea899e6a269ee01c811b9f6998a1541ceab
go/ast, go/parser: populate identifier scopes at parse time

The parser populates all scopes for a given file (except
type-related scopes for structs, interfaces, and methods
of types) at parse time.

A new parser flag, DeclarationErrors, enables error messages
related to declaration errors (as far as it is possible to
provide them).

The resulting AST has all (non-field, non-method) identifiers
resolved that can be resolved w/o doing imports or parsing
missing package files.

The ast.File node contains the (partially complete)
package scope and a list of unresolved global identifiers.

All type-specific data structures have been removed from the AST.

The existing typechecker is functional but needs to be adjusted
(simplified) accordingly. Utility functions to resolve all
identifiers for a package (after handling imports and parsing
all package files) are  missing.

Unrelated changes:
- Rename typechecker/testdata files to that they are not considered
  by gofmt.
- Minor cleanups/simplifications.

Parses all .go files in src and misc without declaration errors.
Runs all tests. Changes do not affect gofmt output.

R=rsc
CC=golang-dev
https://golang.org/cl/4244049
16 files changed:
src/pkg/exp/eval/stmt_test.go
src/pkg/go/ast/ast.go
src/pkg/go/ast/filter.go
src/pkg/go/ast/scope.go
src/pkg/go/parser/parser.go
src/pkg/go/parser/parser_test.go
src/pkg/go/typechecker/Makefile
src/pkg/go/typechecker/scope.go
src/pkg/go/typechecker/testdata/test0.src [moved from src/pkg/go/typechecker/testdata/test0.go with 100% similarity]
src/pkg/go/typechecker/testdata/test1.src [moved from src/pkg/go/typechecker/testdata/test1.go with 100% similarity]
src/pkg/go/typechecker/testdata/test3.src [moved from src/pkg/go/typechecker/testdata/test3.go with 80% similarity]
src/pkg/go/typechecker/testdata/test4.src [moved from src/pkg/go/typechecker/testdata/test4.go with 100% similarity]
src/pkg/go/typechecker/type.go [new file with mode: 0644]
src/pkg/go/typechecker/typechecker.go
src/pkg/go/typechecker/typechecker_test.go
src/pkg/go/typechecker/universe.go