view python/ks/__init__.py @ 198:33d50727a23c

Fixup testscript
author Windel Bouwman
date Sat, 01 Jun 2013 13:11:22 +0200
parents 91af0e40f868
children
line wrap: on
line source


from .parser import KsParser
from .irgenerator import KsIrGenerator

class KsFrontend:
   """
    Frontend for the K# language.

    This module can parse K# code and create LLVM intermediate code.
   """
   def __init__(self, context):
      self.context = context
   def compilesource(self, src):
      """ Front end that handles parsing and Module generation """
      self.errorlist = []
      # Pass 1: parsing and type checking
      p = KsParser(src)
      ast = p.parseModule() # Parse source into an AST
      print(ast)

      # Store ast:
      self.ast = ast

      # Generate ir (a core.Module):
      ir = KsIrGenerator().generateIr(self.context, ast)

      return ir