Beispiel #1
0
// ProcessSource processes yacc source code in src. It returns a *Parser or an
// error, if any.
func ProcessSource(fset *token.FileSet, fname string, src []byte, opts *Options) (*Parser, error) {
	ast, err := yparser.Parse(fset, fname, src)
	if err != nil {
		return nil, err
	}

	return ProcessAST(fset, ast, opts)
}
Beispiel #2
0
func benchmark(b *testing.B, pth string) {
	src, err := ioutil.ReadFile(pth)
	if err != nil {
		b.Fatal(err)
	}

	fset := token.NewFileSet()
	ast, err := yparser.Parse(fset, pth, src)
	if err != nil {
		b.Fatal(err)
	}

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		processAST(fset, ast, nil)
	}
}