view python/c3/builder.py @ 171:3eb9b9e2958d

Improved IR code
author Windel Bouwman
date Wed, 03 Apr 2013 22:20:20 +0200
parents 49f1ab80d040
children 46d62dadd61b
line wrap: on
line source

import ppci
from . import Parser, Semantics, TypeChecker, Analyzer, CodeGenerator, AstPrinter

class Builder:
   def __init__(self, diag):
      self.diag = diag
      self.p = Parser(diag)
      self.tc = TypeChecker(diag)
      self.al = Analyzer(diag)
      self.cg = CodeGenerator()
      self.ap = AstPrinter()
   def build(self, src):
      # Store src for later:
      self.src = src
      self.pkg = self.p.parseSource(src)
      self.al.analyzePackage(self.pkg)
      self.tc.checkPackage(self.pkg)
      ok = len(self.diag.diags) == 0
      if ok:
         i = self.cg.gencode(self.pkg)
         return i