diff options
Diffstat (limited to 'Classes.py')
-rw-r--r-- | Classes.py | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/Classes.py b/Classes.py deleted file mode 100644 index f144e77..0000000 --- a/Classes.py +++ /dev/null @@ -1,145 +0,0 @@ -class KlassType: - def __init__(self, name): - self.name = name - - def __str__(self): - return self.name - - def __repr__(self): - return "<KlassType: %s>" % self - -KlassType.CONST = KlassType("const") -KlassType.VAR = KlassType("var") -KlassType.FUNCNAME = KlassTupe("function name") - -class OperatorType: - def __init__(self, name): - self.name = name - - def __str__(self): - return self.name - - def __repr__(self): - return "<OperatorType: %s>" % self - -OperatorType.EQ = OperatorType("==") -OperatorType.NE = OperatorType("!=") -OperatorType.GE = OperatorType(">=") -OperatorType.LE = OperatorType("<=") -OperatorType.GT = OperatorType(">") -OperatorType.LT = OperatorType("<") -OperatorType.ADD = OperatorType("+") -OperatorType.SUB = OperatorType("-") -OperatorType.MUL = OperatorType("*") -OperatorType.DIV = OperatorType("/") -OperatorType.MOD = OperatorType("%") -OperatorType.AND = OperatorType("&&") -OperatorType.OR = OperatorType("||") - -class TokenType: - def __init__(self, name): - self.name = name - - def __str__(self): - return self.name - - def __repr__(self): - return "<TokenType: %s>" % self - -TokenType.FUN = TokenType("fun") -TokenType.IDENT = TokenType("identifier") -TokenType.LBRAK = TokenType("[") -TokenType.RBRAK = TokenType("]") -TokenType.LPAREN = TokenType("(") -TokenType.RPAREN = TokenType(")") -TokenType.NEWLINE = TokenType("newline") -TokenType.IF = TokenType("if") -TokenType.TAB = TokenType("tab") -TokenType.OPERATOR = TokenType("operator") -TokenType.NUMBER = TokenType("number") -TokenType.RETURN = TokenType("return") -TokenType.END = TokenType("end") - -class NonTerminalType: - def __init__(self, name): - self.name = name - - def __str__(self): - return self.name - - def __repr__(self): - return "<NonTerminalType: %s>" % self - -NonTerminalType.FACTOR = NonTerminalType("factor") -NonTerminalType.TERM = NonTerminalType("term") -NonTerminalType.SIMPLE_EXPRESSION = NonTerminalType("simple_expression") -NonTerminalType.EXPRESSION = NonTerminalType("expression") -NonTerminalType.IDENT_LIST = NonTerminalType("ident_list") -NonTerminalType.EXPRESSION_LIST = NonTerminalType("expression_list") -NonTerminalType.PROGRAM = NonTerminalType("program") -NonTerminalType.FUNCTION = NonTerminalType("function") -NonTerminalType.STATEMENT = NonTerminalType("statement") -NonTerminalType.STATEMENTS = NonTerminalType("statements") -NonTerminalType.IF_STATEMENT = NonTerminalType("if_statement") -NonTerminalType.WHILE_STATEMENT = NonTerminalType("while_statement") -NonTerminalType.RETURN_STATEMENT = NonTerminalType("return_statement") -NonTerminalType.ASSIGNMENT = NonTerminalType("assignment") -NonTerminalType.FUNCTION_CALL = NonTerminalType("function_call") - -class NonTerminal: - # bsp: <FUNCTION, Zwischencode> - def __init__(self,type,code=None): - self.type = type - self.code = code - -class Token: - # bsp: <identifier,0> - def __init__(self,type,value=None): - self.type = type - self.value = value - -class Tokenlist: - tokenlist = [] - - def __init__(self,source): - self.source = source - - def getNextToken(self): - #... irgendwann.. - return tokenlist.next() - - def getValue(self,key) - # ... blublub - return somevalue - -class Symbol: - name = None - value = None - type = None # int, string,.. - klass = None # const, var, functionName - - def __init__(self, name): - self.name = name - -class ParseTree: - def __init__(self, root): - self.root = root - -class ParseTreeNode: - children = [] - value = None # Token oder NonTerminal - - def __init__(self, value): - self.value = value - -class ThreeAddressCodeToken: - - -class ThreeAddressCode: - codelist = [] - - # returns code or -1 if end of list - getNextCode(): - return someCode - -############################### |