blob: 0f284d346d161ccb57c1fd49c752f40bc452d566 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// 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 Utils "utils"
import Globals "globals"
import Object "object"
import Type "type"
import Universe "universe"
import Scanner "scanner"
import AST "ast"
import Parser "parser"
import Export "export"
import Printer "printer"
import Verifier "verifier"
export func Compile(comp *Globals.Compilation, file_name string) {
src, ok := sys.readfile(file_name);
if !ok {
print "cannot open ", file_name, "\n"
return;
}
scanner := new(Scanner.Scanner);
scanner.Open(file_name, src);
var tstream *chan *Scanner.Token;
if comp.flags.pscan {
tstream = new(chan *Scanner.Token, 100);
go scanner.Server(tstream);
}
parser := new(Parser.Parser);
parser.Open(comp, scanner, tstream);
parser.ParseProgram();
if parser.S.nerrors > 0 {
return;
}
if !comp.flags.semantic_checks {
return;
}
Verifier.Verify(comp);
if comp.flags.print_export {
Printer.PrintObject(comp, comp.pkg_list[0].obj, false);
}
Export.Export(comp, file_name);
}
|