165
|
1 import ppci
|
|
2 from . import Parser, Semantics, TypeChecker, Analyzer, CodeGenerator, AstPrinter
|
|
3
|
|
4 class Builder:
|
|
5 def __init__(self, diag):
|
|
6 self.diag = diag
|
166
|
7 self.p = Parser(diag)
|
165
|
8 self.tc = TypeChecker(diag)
|
|
9 self.al = Analyzer(diag)
|
|
10 self.cg = CodeGenerator()
|
|
11 self.ap = AstPrinter()
|
|
12 def build(self, src):
|
|
13 # Store src for later:
|
|
14 self.src = src
|
166
|
15 self.pkg = self.p.parseSource(src)
|
|
16 self.al.analyzePackage(self.pkg)
|
|
17 self.tc.checkPackage(self.pkg)
|
165
|
18 ok = len(self.diag.diags) == 0
|
|
19 if ok:
|
166
|
20 i = self.cg.gencode(self.pkg)
|
165
|
21 return i
|
|
22
|