Mercurial > lcfOS
comparison 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 |
comparison
equal
deleted
inserted
replaced
145:c101826ffe2b | 146:91af0e40f868 |
---|---|
1 | |
2 from .parser import KsParser | |
3 from .irgenerator import KsIrGenerator | |
4 | |
5 class KsFrontend: | |
6 """ | |
7 Frontend for the K# language. | |
8 | |
9 This module can parse K# code and create LLVM intermediate code. | |
10 """ | |
11 def __init__(self, context): | |
12 self.context = context | |
13 def compilesource(self, src): | |
14 """ Front end that handles parsing and Module generation """ | |
15 self.errorlist = [] | |
16 # Pass 1: parsing and type checking | |
17 p = KsParser(src) | |
18 ast = p.parseModule() # Parse source into an AST | |
19 print(ast) | |
20 | |
21 # Store ast: | |
22 self.ast = ast | |
23 | |
24 # Generate ir (a core.Module): | |
25 ir = KsIrGenerator().generateIr(self.context, ast) | |
26 | |
27 return ir | |
28 |