From bb9d53e570cfdf4029a08891365feb1b0785b253 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 10 Jul 2008 18:46:30 -0700 Subject: [PATCH] - added buildtime SVN=126776 --- usr/gri/gosrc/go.go | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 usr/gri/gosrc/go.go diff --git a/usr/gri/gosrc/go.go b/usr/gri/gosrc/go.go new file mode 100644 index 0000000000..8bf44d98b5 --- /dev/null +++ b/usr/gri/gosrc/go.go @@ -0,0 +1,61 @@ +// 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 Scanner "scanner" +import Parser "parser" + + +func PrintHelp() { + print "go in go (", Build.time, ")\n"; + print "usage:\n"; + print " go { -v | -vv | file }\n"; + /* + printf("flags:\n"); + for (int i = 0; Flags[i].name != NULL; i++) { + printf(" %s %s\n", Flags[i].name, Flags[i].help); + } + */ +} + + +func Compile(filename, src string, verbose int) { + S := new(Scanner.Scanner); + S.Open(filename, src); + + P := new(Parser.Parser); + P.Open(S, verbose); + + P.ParseProgram(); +} + + +func main() { + if sys.argc() <= 1 { + PrintHelp(); + sys.exit(1); + } + + verbose := 0; + for i := 1; i < sys.argc(); i++ { + switch sys.argv(i) { + case "-v": + verbose = 1; + continue; + case "-vv": + verbose = 2; + continue; + } + + src, ok := sys.readfile(sys.argv(i)); + if ok { + print "parsing " + sys.argv(i) + "\n"; + Compile(sys.argv(i), src, verbose); + } else { + print "error: cannot read " + sys.argv(i) + "\n"; + } + } +} -- 2.48.1