2008-07-07 18:27:14 -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 Scanner "scanner"
|
|
|
|
import Parser "parser"
|
|
|
|
|
|
|
|
|
2008-07-10 15:42:33 -06:00
|
|
|
func Parse(filename, src string, verbose int) {
|
2008-07-07 18:27:14 -06:00
|
|
|
S := new(Scanner.Scanner);
|
2008-07-10 15:42:33 -06:00
|
|
|
S.Open(filename, src);
|
2008-07-07 18:27:14 -06:00
|
|
|
|
|
|
|
P := new(Parser.Parser);
|
|
|
|
P.Open(S, verbose);
|
|
|
|
|
|
|
|
P.ParseProgram();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
2008-07-08 17:39:04 -06:00
|
|
|
verbose := 0;
|
2008-07-07 18:27:14 -06:00
|
|
|
for i := 1; i < sys.argc(); i++ {
|
2008-07-08 17:39:04 -06:00
|
|
|
switch sys.argv(i) {
|
|
|
|
case "-v":
|
|
|
|
verbose = 1;
|
|
|
|
continue;
|
|
|
|
case "-vv":
|
|
|
|
verbose = 2;
|
2008-07-07 18:27:14 -06:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-07-10 15:42:33 -06:00
|
|
|
src, ok := sys.readfile(sys.argv(i));
|
2008-07-07 18:27:14 -06:00
|
|
|
if ok {
|
|
|
|
print "parsing " + sys.argv(i) + "\n";
|
2008-07-10 15:42:33 -06:00
|
|
|
Parse(sys.argv(i), src, verbose);
|
2008-07-07 18:27:14 -06:00
|
|
|
} else {
|
|
|
|
print "error: cannot read " + sys.argv(i) + "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|