diff options
author | Benedikt Böhm <bb@xnull.de> | 2009-07-04 11:16:37 +0200 |
---|---|---|
committer | Benedikt Böhm <bb@xnull.de> | 2009-07-04 11:16:37 +0200 |
commit | 690644bb293d7de12abddcaaca75f8f6c6dad24e (patch) | |
tree | 94f5126a5ebe33b3d862d5aa6bc15d1f9a3fcc83 /src | |
parent | 1647e844ccff4511491ce7f2c9acf088b3e50002 (diff) | |
download | swppy-690644bb293d7de12abddcaaca75f8f6c6dad24e.tar.gz swppy-690644bb293d7de12abddcaaca75f8f6c6dad24e.tar.xz swppy-690644bb293d7de12abddcaaca75f8f6c6dad24e.zip |
cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/__init__.py | 8 | ||||
-rw-r--r-- | src/back/tac.py | 8 | ||||
-rw-r--r-- | src/front/symbol.py | 8 | ||||
-rw-r--r-- | src/front/type.py | 12 |
4 files changed, 8 insertions, 28 deletions
diff --git a/src/__init__.py b/src/__init__.py index bbe2e28..e5d6457 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -2,15 +2,17 @@ from front.lexer import Lexer from front.parser import Parser from front.scope import Scope from back.tac import TACList +from back.generator import Generator import sys def main(): ast = Parser(Lexer(sys.stdin.read())).parse() scope = Scope() ast.generate() - print scope - sys.stdout.write(repr(TACList())) - sys.stdout.flush() + #print scope + #sys.stdout.write(repr(TACList())) + #sys.stdout.flush() + Generator().generate() if __name__ == "__main__": main() diff --git a/src/back/tac.py b/src/back/tac.py index 20b14d9..03303cf 100644 --- a/src/back/tac.py +++ b/src/back/tac.py @@ -21,12 +21,13 @@ Op.OR = Op("OR") # x = x OR y Op.NOT = Op("NOT") # x = !x Op.MINUS = Op("MINUS") # x = -x +Op.MOV = Op("MOV") # x = y Op.STORE = Op("STORE") # MEM[x] = y Op.LOAD = Op("LOAD") # y = MEM[x] -Op.MOV = Op("MOV") # x = y +Op.PUSH = Op("PUSH") # push x +Op.POP = Op("POP") # pop x Op.CMP = Op("CMP") # Z = x == y, N = x < y - Op.EQ = Op("EQ") # x = Z Op.NE = Op("NE") # x = !Z Op.LT = Op("LT") # x = N @@ -36,9 +37,6 @@ Op.GT = Op("GT") # x = !Z && !N Op.BEZ = Op("BEZ") # if x == 0 goto y Op.JMP = Op("JMP") # goto x - -Op.PUSH = Op("PUSH") # push x -Op.POP = Op("POP") # pop x Op.CALL = Op("CALL") # call x return in y Op.RETURN = Op("RETURN") # return x diff --git a/src/front/symbol.py b/src/front/symbol.py deleted file mode 100644 index b93b778..0000000 --- a/src/front/symbol.py +++ /dev/null @@ -1,8 +0,0 @@ -from type import DataType - -class Symbol(object): - __slots__ = ['type', 'value'] - - def __init__(self, value, type = DataType.INT): - self.value = value - self.type = type diff --git a/src/front/type.py b/src/front/type.py deleted file mode 100644 index a8bd8c7..0000000 --- a/src/front/type.py +++ /dev/null @@ -1,12 +0,0 @@ -class DataType(object): - def __init__(self, name): - self.name = name - - def __str__(self): - return self.name - - def __repr__(self): - return "<DataType: %s>" % self - -DataType.INT = DataType("INT") -DataType.BOOL = DataType("BOOL") |