1
0
mirror of https://github.com/golang/go synced 2024-10-04 02:31:22 -06:00
go/usr/gri/gosrc/go.go

89 lines
2.2 KiB
Go
Raw Normal View History

2008-07-10 19:46:30 -06:00
// 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 Build "build"
import Globals "globals"
2008-07-15 20:59:00 -06:00
import Compilation "compilation"
2008-07-10 19:46:30 -06:00
func PrintHelp() {
print
"go (" + Build.time + ")\n" +
"usage:\n" +
" go { flag } { file }\n" +
" -d debug mode, additional self tests and prints\n" +
" -o filename explicit object filename\n" +
" -r recursively update imported packages in current directory\n" +
" -p print package interface\n" +
" -v [0 .. 3] verbosity level\n" +
" -6g 6g compatibility mode\n" +
" -scan scan only, print tokens\n" +
" -parse parse only, print productions\n" +
" -ast analyse only, print ast\n" +
" -deps print package dependencies\n" +
" -token_chan use token channel to scan and parse in parallel\n";
}
var argno int = 1;
func Next() string {
arg := "";
if argno < sys.argc() {
arg = sys.argv(argno);
argno++;
}
return arg;
2008-07-10 19:46:30 -06:00
}
func main() {
arg := Next();
if arg == "" {
2008-07-10 19:46:30 -06:00
PrintHelp();
return;
2008-07-10 19:46:30 -06:00
}
// collect flags and files
flags := new(Globals.Flags);
files := Globals.NewList();
for arg != "" {
switch arg {
case "-d": flags.debug = true;
case "-o": flags.object_filename = Next();
print "note: -o flag ignored at the moment\n";
case "-r": flags.update_packages = true;
case "-p": flags.print_interface = true;
case "-v":
arg = Next();
switch arg {
case "0", "1", "2", "3":
flags.verbosity = uint(arg[0] - '0');
default:
// anything else is considered the next argument
flags.verbosity = 1;
continue;
}
case "-6g": flags.sixg = true;
case "-scan": flags.scan = true;
print "note: -scan flag ignored at the moment\n";
case "-parse": flags.parse = true;
print "note: -parse flag ignored at the moment\n";
case "-ast": flags.ast = true;
case "-deps": flags.deps = true;
print "note: -deps flag ignored at the moment\n";
case "-token_chan": flags.token_chan = true;
default: files.AddStr(arg);
2008-07-10 19:46:30 -06:00
}
arg = Next();
}
// compile files
for p := files.first; p != nil; p = p.next {
Compilation.Compile(flags, p.str);
2008-07-10 19:46:30 -06:00
}
}