view python/c3/builder.py @ 186:46d62dadd61b

Improved testsuite
author Windel Bouwman
date Sat, 25 May 2013 14:26:25 +0200
parents 49f1ab80d040
children b01429a5d695
line wrap: on
line source

import ppci
from . import Parser, Semantics, TypeChecker, Analyzer, CodeGenerator, 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()
      self.ap = AstPrinter()
    def build(self, src):
      """ Create IR-code from sources """
      pkg = self.parser.parseSource(src)
      if not pkg:
            return
      if not self.al.analyzePackage(pkg):
            return
      if not self.tc.checkPackage(pkg):
            return
      ircode = self.cg.gencode(pkg)
      return ircode