Commit e952e241 authored by Robert Griesemer's avatar Robert Griesemer

gotype: provide -comments flag

When debugging ASTs, it's useful to also
see the comments on occasion. Usage:

gotype -ast -comments file.go

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5703043
parent 64bc38eb
...@@ -34,6 +34,8 @@ The flags are: ...@@ -34,6 +34,8 @@ The flags are:
Verbose mode. Verbose mode.
Debugging flags: Debugging flags:
-comments
Parse comments (ignored if -ast not set).
-ast -ast
Print AST (disables concurrent parsing). Print AST (disables concurrent parsing).
-trace -trace
......
...@@ -27,6 +27,7 @@ var ( ...@@ -27,6 +27,7 @@ var (
allErrors = flag.Bool("e", false, "print all (including spurious) errors") allErrors = flag.Bool("e", false, "print all (including spurious) errors")
// debugging support // debugging support
parseComments = flag.Bool("comments", false, "parse comments (ignored if -ast not set)")
printTrace = flag.Bool("trace", false, "print parse trace") printTrace = flag.Bool("trace", false, "print parse trace")
printAST = flag.Bool("ast", false, "print AST") printAST = flag.Bool("ast", false, "print AST")
) )
...@@ -73,6 +74,9 @@ func parse(fset *token.FileSet, filename string, src []byte) *ast.File { ...@@ -73,6 +74,9 @@ func parse(fset *token.FileSet, filename string, src []byte) *ast.File {
if *allErrors { if *allErrors {
mode |= parser.SpuriousErrors mode |= parser.SpuriousErrors
} }
if *parseComments && *printAST {
mode |= parser.ParseComments
}
if *printTrace { if *printTrace {
mode |= parser.Trace mode |= parser.Trace
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment