diff python/testc3.py @ 152:b73bc14a3aa3

Light coupling ide and c3 frontend
author Windel Bouwman
date Sat, 02 Mar 2013 09:56:12 +0100
parents afc8c0207984
children b28a11c01dbe
line wrap: on
line diff
--- a/python/testc3.py	Fri Mar 01 17:13:56 2013 +0100
+++ b/python/testc3.py	Sat Mar 02 09:56:12 2013 +0100
@@ -1,6 +1,4 @@
-import c3
-from ppci.errors import printError, Diagnostics
-import time
+import c3, time, ppci
 
 testsrc = """
 package test;
@@ -50,11 +48,10 @@
    for c in ast.getChildren():
       printAst(c, indent + '  ')
 
-def c3compile(src):
+def c3compile(src, diag):
    print('[0] source:')
    print(src)
    print('[1] parsing')
-   diag = Diagnostics()
    sema = c3.Semantics(diag)
    p = c3.Parser(sema, diag)
    tc = c3.TypeChecker(diag)
@@ -72,7 +69,7 @@
 
    for d in diag.diags:
       print('ERROR:')
-      printError(testsrc, d)
+      ppci.printError(testsrc, d)
    print('[2] ast:')
    printAst(sema.mod)
 
@@ -83,7 +80,8 @@
       print('Not generating code')
    
 def do():
-   c3compile(testsrc)
+   diag = ppci.DiagnosticsManager()
+   c3compile(testsrc, diag)
 
 do()