annotate python/c3/builder.py @ 168:49f1ab80d040

Added awesome icons
author Windel Bouwman
date Fri, 22 Mar 2013 19:09:38 +0100
parents 0b5b2ee6b435
children 46d62dadd61b
rev   line source
165
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
1 import ppci
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
2 from . import Parser, Semantics, TypeChecker, Analyzer, CodeGenerator, AstPrinter
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
3
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
4 class Builder:
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
5 def __init__(self, diag):
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
6 self.diag = diag
166
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
7 self.p = Parser(diag)
165
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
8 self.tc = TypeChecker(diag)
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
9 self.al = Analyzer(diag)
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
10 self.cg = CodeGenerator()
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
11 self.ap = AstPrinter()
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
12 def build(self, src):
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
13 # Store src for later:
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
14 self.src = src
166
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
15 self.pkg = self.p.parseSource(src)
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
16 self.al.analyzePackage(self.pkg)
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
17 self.tc.checkPackage(self.pkg)
165
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
18 ok = len(self.diag.diags) == 0
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
19 if ok:
166
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
20 i = self.cg.gencode(self.pkg)
165
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
21 return i
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents:
diff changeset
22