1
0
mirror of https://github.com/golang/go synced 2024-10-04 12:21:26 -06:00
go/usr/gri/src/test_parser.go

45 lines
779 B
Go
Raw Normal View History

// 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-08 17:39:04 -06:00
func Parse(src string, verbose int) {
S := new(Scanner.Scanner);
S.Open(src);
P := new(Parser.Parser);
P.Open(S, verbose);
P.ParseProgram();
}
func main() {
2008-07-08 17:39:04 -06:00
verbose := 0;
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;
continue;
}
var src string;
var ok bool;
src, ok = sys.readfile(sys.argv(i));
if ok {
print "parsing " + sys.argv(i) + "\n";
Parse(src, verbose);
} else {
print "error: cannot read " + sys.argv(i) + "\n";
}
}
}