Mercurial > lcfOS
diff python/ks/__init__.py @ 146:91af0e40f868
Moved several files
author | Windel Bouwman |
---|---|
date | Fri, 22 Feb 2013 10:31:58 +0100 |
parents | python/ppci/frontends/ks/__init__.py@9e552d34bd60 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/ks/__init__.py Fri Feb 22 10:31:58 2013 +0100 @@ -0,0 +1,28 @@ + +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 +