-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnums.py
56 lines (50 loc) · 1.19 KB
/
Enums.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from enum import Enum
class Errornr(Enum):
NO_ERROR = "No Error"
SYNTAX_ERROR = "Syntax Error"
FileNotFoundError = "File Not Found Error"
MATH_ERROR = "Math Error"
NameError = "Name Error"
ZeroDivisionError= "ZeroDivisionError"
class Error():
def __init__(self, errornr : Errornr = Errornr.NO_ERROR, errormsg = ""):
self.nr = errornr
self.msg = errormsg
def __str__(self):
return (str(self.nr.value) + ": " + self.msg)
def __repr__(self):
return self.__str__()
class State(Enum):
Idle = 0
Math = 1
ASSIGN = 2
COMPARISON = 3
ERROR = 4
IF_WHILE = 5
PRINT = 6
class TokenValues(Enum):
PLUS = "PLUS"
MIN = "MIN"
MULTIPLY = "MULTIPLY"
DIVIDED_BY = "DIVIDED_BY"
NUMBER = "NUMBER"
IF = "IF"
ELSE = "ELSE"
ASSIGN = "ASSIGN"
WHILE = "WHILE"
EQUAL = "EQUAL"
NOTEQUAL = "NOTEQUAL"
GE = "GE"
SE = "SE"
GREATER = "GREATER"
SMALLER = "SMALLER"
SEMICOLON = "SEMICOLON"
LPAREN = "LPAREN"
RPAREN = "RPAREN"
LBRACE = "LBRACE"
RBRACE = "RBRACE"
PRINT = "PRINT"
PRINT_END = "PRINT_END"
VAR = "VAR"
VAR_ASSIGN = "VAR_ASSIGN"
ERROR = "ERROR"