Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7)

Unified Diff: src/pkg/exp/parser/interface.go

Issue 180070: code review 180070: Don't ignore flags controlling the amount of source cod... (Closed)
Patch Set: code review 180070: Don't ignore flags controlling the amount of source cod... Created 15 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/pkg/go/parser/interface.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/exp/parser/interface.go
===================================================================
--- a/src/pkg/exp/parser/interface.go
+++ b/src/pkg/exp/parser/interface.go
@@ -135,8 +135,7 @@
// ParsePkgFile parses the file specified by filename and returns the
// corresponding AST. If the file cannot be read, has syntax errors, or
// does not belong to the package (i.e., pkgname != "" and the package
-// name in the file doesn't match pkkname), an error is returned. Mode
-// flags that control the amount of source text parsed are ignored.
+// name in the file doesn't match pkkname), an error is returned.
//
func ParsePkgFile(pkgname, filename string, mode uint) (*ast.File, os.Error) {
src, err := ioutil.ReadFile(filename)
@@ -152,10 +151,12 @@
if prog.Name.Value != pkgname {
return nil, os.NewError(fmt.Sprintf("multiple packages found: %s, %s", prog.Name.Value, pkgname))
}
+ if mode == PackageClauseOnly {
+ return prog, nil
+ }
}
- // ignore flags that control partial parsing
- return ParseFile(filename, src, mode&^(PackageClauseOnly|ImportsOnly))
+ return ParseFile(filename, src, mode)
}
@@ -164,7 +165,6 @@
// restricted by providing a non-nil filter function; only the files with
// os.Dir entries passing through the filter are considered.
// If ParsePackage does not find exactly one package, it returns an error.
-// Mode flags that control the amount of source text parsed are ignored.
//
func ParsePackage(path string, filter func(*os.Dir) bool, mode uint) (*ast.Package, os.Error) {
fd, err := os.Open(path, os.O_RDONLY, 0)
« no previous file with comments | « no previous file | src/pkg/go/parser/interface.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b