Mercurial > lcfOS
view python/c3/builder.py @ 235:ff40407c0240
Fix ALabel to Label
author | Windel Bouwman |
---|---|
date | Mon, 15 Jul 2013 17:20:37 +0200 |
parents | 240111e0456f |
children | 6ed3d3a82a63 |
line wrap: on
line source
import ppci from . import Parser, TypeChecker, Analyzer, CodeGenerator from . astprinter import AstPrinter class Builder: """ Generates IR-code from c3 source. Reports errors to the diagnostics system """ def __init__(self, diag): self.diag = diag self.parser = Parser(diag) self.tc = TypeChecker(diag) self.al = Analyzer(diag) self.cg = CodeGenerator() def build(self, src): """ Create IR-code from sources """ pkg = self.parser.parseSource(src) if not pkg: return self.pkg = pkg # TODO: merge the two below? #AstPrinter().printAst(pkg) if not self.al.analyzePackage(pkg): return if not self.tc.checkPackage(pkg): return # Only return ircode when everything is OK return self.cg.gencode(pkg)