diff options
author | Benedikt Böhm <bb@xnull.de> | 2009-05-26 11:58:21 +0200 |
---|---|---|
committer | Benedikt Böhm <bb@xnull.de> | 2009-05-26 11:58:21 +0200 |
commit | 844580225f0005a71d90fc2c75e8e0c33a4efa2a (patch) | |
tree | e4eace96dc6bc26b23bfb0a0cc7d378d48b71c70 | |
parent | aeecf0881e48ec91b958140b91556cd84e473abd (diff) | |
parent | 5dd84e8e76132ad2e1a58de28ec94ca7ee1ab969 (diff) | |
download | swppy-844580225f0005a71d90fc2c75e8e0c33a4efa2a.tar.gz swppy-844580225f0005a71d90fc2c75e8e0c33a4efa2a.tar.xz swppy-844580225f0005a71d90fc2c75e8e0c33a4efa2a.zip |
Merge branch 'master' of git@git.animux.de:swppy
Diffstat (limited to '')
-rw-r--r-- | src/back/tac.py | 11 | ||||
-rwxr-xr-x | src/main_test.py | 32 |
2 files changed, 38 insertions, 5 deletions
diff --git a/src/back/tac.py b/src/back/tac.py index a875a7d..fc072d9 100644 --- a/src/back/tac.py +++ b/src/back/tac.py @@ -27,10 +27,10 @@ Op.ASSIGN = Op("ASSIGN") # x = y -> x y Op.JMP = Op("JMP") # "goto" x -> x Op.BEQ = Op("EQ") # "if x == y" -> x y Op.BNE = Op("NE") # "if x != y" -> x y -Op.BLE = Op("LE") # ... -Op.BGE = Op("GE") -Op.BLT = Op("LT") -Op.BGT = Op("GT") +Op.LE = Op("LE") # ... +Op.GE = Op("GE") +Op.LT = Op("LT") +Op.GT = Op("GT") Op.PARAM = Op("PARAM") # param x -> x Op.CALL = Op("CALL") # fun x (y-args..) -> x y @@ -60,9 +60,10 @@ class TacArray: return len(self.liste)-1 def createList(self): - i = 0 + i = 1 output = "" for item in self.liste: print "%08d | %s\t%s\t%s" % (i,item.op,item.arg1,item.arg2) + i = i+1 diff --git a/src/main_test.py b/src/main_test.py new file mode 100755 index 0000000..8649a74 --- /dev/null +++ b/src/main_test.py @@ -0,0 +1,32 @@ +#!/usr/bin/python + +import sys + +from front import ast +#import SymbolTable +from back import tac + +def main(): + mUn = ast.UnaryExpression("PLUS","a") + mIf = ast.IfStatement(mUn,"true","false") + mFunc1 = ast.Function("func1",["param1","param2"],mIf) + mFunc2 = ast.Function("func2",["param0","param1"],mIf) + mProg = ast.Program([mFunc1,mFunc2]) + Test() + + +class Test: + def __init__(self): + x = tac.TacElem("PLUS",3,5) + y = tac.TacElem("MINUS",8,3) + z = tac.TacArray() + z.append(x) + z.append(y) + z.createList() + + + + + +if __name__ == "__main__": + sys.exit(main()) |