diff python/testc3.py @ 151:afc8c0207984

Added ir code generator stub
author Windel Bouwman
date Fri, 01 Mar 2013 17:13:56 +0100
parents 4ae0e02599de
children b73bc14a3aa3
line wrap: on
line diff
--- a/python/testc3.py	Fri Mar 01 16:53:22 2013 +0100
+++ b/python/testc3.py	Fri Mar 01 17:13:56 2013 +0100
@@ -50,17 +50,18 @@
    for c in ast.getChildren():
       printAst(c, indent + '  ')
 
-def do():
+def c3compile(src):
    print('[0] source:')
-   print(testsrc)
+   print(src)
    print('[1] parsing')
    diag = Diagnostics()
    sema = c3.Semantics(diag)
    p = c3.Parser(sema, diag)
    tc = c3.TypeChecker(diag)
    al = c3.Analyzer(diag)
+   cg = c3.CodeGenerator()
    t1 = time.time()
-   p.parseSource(testsrc)
+   p.parseSource(src)
    t2 = time.time() 
    print('parsetime: {0} [s]'.format(t2 - t1))
    t2 = time.time() 
@@ -75,5 +76,14 @@
    print('[2] ast:')
    printAst(sema.mod)
 
+   ok = len(diag.diags) == 0
+   if ok:
+      cg.gencode(sema.mod)
+   else:
+      print('Not generating code')
+   
+def do():
+   c3compile(testsrc)
+
 do()