From 63ed2b710b1d03976c3ae72ce952a5b43bb868d0 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Fri, 24 Oct 2008 14:08:01 -0700 Subject: [PATCH] - missing file R=r OCL=17813 CL=17813 --- usr/gri/pretty/compilation.go | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 usr/gri/pretty/compilation.go diff --git a/usr/gri/pretty/compilation.go b/usr/gri/pretty/compilation.go new file mode 100644 index 0000000000..793863281d --- /dev/null +++ b/usr/gri/pretty/compilation.go @@ -0,0 +1,46 @@ +// 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 Compilation + +import Scanner "scanner" +import Parser "parser" +import AST "ast" + + + +export type Flags struct { + verbose bool; + sixg bool; + deps bool; + columns bool; + testmode bool; + tokenchan bool; +} + + +type Compilation struct { + prog *AST.Program; + nerrors int; +} + + +export func Compile(src_file, src string, flags *Flags) *Compilation { + var scanner Scanner.Scanner; + scanner.Open(src_file, src, flags.columns, flags.testmode); + + var tstream *<-chan *Scanner.Token; + if flags.tokenchan { + tstream = scanner.TokenStream(); + } + + var parser Parser.Parser; + parser.Open(flags.verbose, flags.sixg, &scanner, tstream); + + C := new(Compilation); + C.prog = parser.ParseProgram(); + C.nerrors = scanner.nerrors; + + return C; +} -- 2.48.1