diff python/testc3.py @ 165:598d3888a11c

Added front class and fided AST view
author Windel Bouwman
date Fri, 22 Mar 2013 15:12:38 +0100
parents 8104fc8b5e90
children da0087b82fbe
line wrap: on
line diff
--- a/python/testc3.py	Mon Mar 18 22:15:57 2013 +0100
+++ b/python/testc3.py	Fri Mar 22 15:12:38 2013 +0100
@@ -46,51 +46,22 @@
 """
 
 def c3compile(src, diag):
-   print('[0] source:')
-   print(src)
-   print('[1] parsing')
    # Structures:
-   sema = c3.Semantics(diag)
-   p = c3.Parser(sema, diag)
-   tc = c3.TypeChecker(diag)
-   al = c3.Analyzer(diag)
-   cg = c3.CodeGenerator()
-   ap = c3.AstPrinter()
-
+   builder = c3.Builder(diag)
+   ir = builder.build(src)
+   # optional optimize here
    x86gen = x86.X86CodeGen(diag)
-   p.parseSource(src)
    ok = len(diag.diags) == 0
    if not ok:
+      print('Not generating code')
       return
-   al.analyzePackage(sema.mod)
-   tc.checkPackage(sema.mod)
-   print('{0} errors'.format(len(diag.diags)))
-
-   for d in diag.diags:
-      print('ERROR:')
-      ppci.printError(testsrc, d)
-   print('[2] ast:')
-   ap.printAst(sema.mod)
-
-   #printAst(sema.mod)
-
-   ok = len(diag.diags) == 0
-   if ok:
-      print('Generating ir-code')
-      i = cg.gencode(sema.mod)
-      #ir.printIr(i)
-
-      print('generating x86 code')
-
-      x86gen.genBin(i)
-
-      with open('dummydummy.asm', 'w') as f:
-         f.write('bits 64\n')
-         for a in x86gen.asm:
-            print(a)
-            f.write(str(a) + '\n')
-   else:
-      print('Not generating code')
+   print('generating x86 code')
+   x86gen.genBin(ir)
+   with open('dummydummy.asm', 'w') as f:
+      f.write('bits 64\n')
+      for a in x86gen.asm:
+         print(a)
+         f.write(str(a) + '\n')
    
 def do():
    diag = ppci.DiagnosticsManager()