aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/syntax.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2018-02-14 16:59:36 -0800
committerRobert Griesemer <gri@golang.org>2018-02-15 01:48:21 +0000
commiteda39fe9b2bdae054a6d0b93efb9b40cc9d24391 (patch)
treed5f20329ea31440dd98871d6cab46d8e89e41c72 /src/cmd/compile/internal/syntax/syntax.go
parent1a2273874953517cc38f7005e985c91d16ebf33c (diff)
downloadgo-eda39fe9b2bdae054a6d0b93efb9b40cc9d24391.tar.gz
go-eda39fe9b2bdae054a6d0b93efb9b40cc9d24391.zip
cmd/compile/internal/syntax: fix syntax.Parse doc string, improved tests
1) Fix the doc string for syntax.Parse: The returned AST is always nil if there was an error and an error handler is missing. 2) Adjust the syntax Print and Dump tests such that they print and dump the AST even in the presence of errors. Change-Id: If658eabdcc83f578d815070bc65d1a5f6cfaddfc Reviewed-on: https://go-review.googlesource.com/94157 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/syntax.go')
-rw-r--r--src/cmd/compile/internal/syntax/syntax.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/syntax/syntax.go b/src/cmd/compile/internal/syntax/syntax.go
index f6e9303290..7de7d4d9fa 100644
--- a/src/cmd/compile/internal/syntax/syntax.go
+++ b/src/cmd/compile/internal/syntax/syntax.go
@@ -50,12 +50,13 @@ type FilenameHandler func(name string) string
// Parse parses a single Go source file from src and returns the corresponding
// syntax tree. If there are errors, Parse will return the first error found,
-// and a possibly partially constructed syntax tree, or nil if no correct package
-// clause was found. The base argument is only used for position information.
+// and a possibly partially constructed syntax tree, or nil.
//
// If errh != nil, it is called with each error encountered, and Parse will
-// process as much source as possible. If errh is nil, Parse will terminate
-// immediately upon encountering an error.
+// process as much source as possible. In this case, the returned syntax tree
+// is only nil if no correct package clause was found.
+// If errh is nil, Parse will terminate immediately upon encountering the first
+// error, and the returned syntax tree is nil.
//
// If pragh != nil, it is called with each pragma encountered.
//