More steps towards tracking of identifier scopes.

- provide scope to parse functions; if non-nil, parser uses the scope
  to declare and lookup identifiers
- resolve forward references where possible

R=rsc
CC=golang-dev
https://golang.org/cl/194098
This commit is contained in:
Robert Griesemer 2010-01-27 09:44:28 -08:00
parent 1c369bd55f
commit f39dc9fff2
13 changed files with 103 additions and 70 deletions

View file

@ -122,7 +122,7 @@ func isPkgDir(dir *os.Dir) bool {
func pkgName(filename string) string {
file, err := parser.ParseFile(filename, nil, parser.PackageClauseOnly)
file, err := parser.ParseFile(filename, nil, nil, parser.PackageClauseOnly)
if err != nil || file == nil {
return ""
}
@ -207,7 +207,7 @@ func newDirTree(path, name string, depth, maxDepth int) *Directory {
nfiles++
if text == "" {
// no package documentation yet; take the first found
file, err := parser.ParseFile(pathutil.Join(path, d.Name), nil,
file, err := parser.ParseFile(pathutil.Join(path, d.Name), nil, nil,
parser.ParseComments|parser.PackageClauseOnly)
if err == nil &&
// Also accept fakePkgName, so we get synopses for commmands.
@ -845,7 +845,7 @@ func serveGoSource(c *http.Conn, r *http.Request, path string) {
Error string
}
file, err := parser.ParseFile(path, nil, parser.ParseComments)
file, err := parser.ParseFile(path, nil, nil, parser.ParseComments)
info.Source = StyledNode{file, &Styler{linetags: true, highlight: r.FormValue("h")}}
if err != nil {
info.Error = err.String()