Mercurial > lcfOS
comparison python/c3/builder.py @ 215:c1ccb1cb4cef
Major changes in c3 frontend
author | Windel Bouwman |
---|---|
date | Fri, 05 Jul 2013 13:00:03 +0200 |
parents | 003c8a976fff |
children | 1c7364bd74c7 |
comparison
equal
deleted
inserted
replaced
214:6875360e8390 | 215:c1ccb1cb4cef |
---|---|
1 import ppci | 1 import ppci |
2 from . import Parser, Semantics, TypeChecker, Analyzer, CodeGenerator, AstPrinter | 2 from . import Parser, TypeChecker, Analyzer, CodeGenerator |
3 | 3 |
4 class Builder: | 4 class Builder: |
5 """ | 5 """ |
6 Generates IR-code from c3 source. | 6 Generates IR-code from c3 source. |
7 Reports errors to the diagnostics system | 7 Reports errors to the diagnostics system |
10 self.diag = diag | 10 self.diag = diag |
11 self.parser = Parser(diag) | 11 self.parser = Parser(diag) |
12 self.tc = TypeChecker(diag) | 12 self.tc = TypeChecker(diag) |
13 self.al = Analyzer(diag) | 13 self.al = Analyzer(diag) |
14 self.cg = CodeGenerator() | 14 self.cg = CodeGenerator() |
15 self.ap = AstPrinter() | |
16 def build(self, src): | 15 def build(self, src): |
17 """ Create IR-code from sources """ | 16 """ Create IR-code from sources """ |
18 pkg = self.parser.parseSource(src) | 17 pkg = self.parser.parseSource(src) |
19 if not pkg: | 18 if not pkg: |
20 return | 19 return |
21 self.pkg = pkg | 20 self.pkg = pkg |
21 # TODO: merge the two below? | |
22 if not self.al.analyzePackage(pkg): | 22 if not self.al.analyzePackage(pkg): |
23 return | 23 return |
24 if not self.tc.checkPackage(pkg): | 24 if not self.tc.checkPackage(pkg): |
25 return | 25 return |
26 | 26 |