1
0
mirror of https://github.com/golang/go synced 2024-11-20 11:04:56 -07:00
go/usr/gri/pretty/pretty.go
Robert Griesemer 732b53a1fe - snapshot of state before trying yet another, hopefully better working
way to integrate comments into the generated output
- various simplificatins and cleanups throughout

R=r
OCL=20062
CL=20062
2008-11-26 13:23:26 -08:00

57 lines
1.5 KiB
Go

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import Flag "flag"
import Platform "platform"
import Printer "printer"
import Compilation "compilation"
var (
flags Compilation.Flags;
silent = Flag.Bool("s", false, nil, "silent mode: no pretty print output");
verbose = Flag.Bool("v", false, &flags.verbose, "verbose mode: trace parsing");
sixg = Flag.Bool("6g", true, &flags.sixg, "6g compatibility mode");
deps = Flag.Bool("d", false, &flags.deps, "print dependency information only");
columns = Flag.Bool("columns", Platform.USER == "gri", &flags.columns, "print column info in error messages");
testmode = Flag.Bool("t", false, &flags.testmode, "test mode: interprets /* ERROR */ and /* SYNC */ comments");
tokenchan = Flag.Bool("token_chan", false, &flags.tokenchan, "use token channel for scanner-parser connection");
)
func Usage() {
print("usage: pretty { flags } { files }\n");
Flag.PrintDefaults();
sys.exit(0);
}
func main() {
Flag.Parse();
if Flag.NFlag() == 0 && Flag.NArg() == 0 {
Usage();
}
// process files
for i := 0; i < Flag.NArg(); i++ {
src_file := Flag.Arg(i);
if flags.deps {
Compilation.ComputeDeps(src_file, &flags);
} else {
prog, nerrors := Compilation.Compile(src_file, &flags);
if nerrors > 0 {
return;
}
if !silent.BVal() && !flags.testmode {
Printer.Print(prog);
}
}
}
}