view python/c3/builder.py @ 190:65dda7e7e8bd

Disable test with qt
author Windel Bouwman
date Sat, 25 May 2013 15:15:42 +0200
parents 46d62dadd61b
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