diff python/ppci/frontends/ks/__init__.py @ 105:6a303f835c6d

Removed compilers directory
author Windel Bouwman
date Mon, 31 Dec 2012 17:35:17 +0100
parents 63937c8d1478
children f2d980eef509
line wrap: on
line diff
--- a/python/ppci/frontends/ks/__init__.py	Sun Dec 30 22:31:55 2012 +0100
+++ b/python/ppci/frontends/ks/__init__.py	Mon Dec 31 17:35:17 2012 +0100
@@ -1,13 +1,27 @@
-"""
- Frontend for the K# language.
-
- This module can parse K# code and create LLVM intermediate code.
-"""
 
 from .parser import KsParser
 from .irgenerator import KsIrGenerator
 
 class KsFrontend:
-   def __init__(self):
-      pass
+   """
+    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
+
+      # Store ast:
+      self.ast = ast
+
+      # Generate ir (a core.Module):
+      ir = KsIrGenerator().generateIr(context, ast)
+
+      return ir
+