-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeNode.py
71 lines (54 loc) · 1.29 KB
/
TreeNode.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from enum import Enum
class Token:
pass
columna = 0
linea = 0
tipo = ""
lexema = ""
def __init__(self, linea, columna, tipo, lexema):
self.columna = columna
self.linea = linea
self.tipo = tipo
self.lexema = lexema
class NodeKind(Enum):
StmtK = 1
ExpK = 2
class StmtKind(Enum):
MainK = 1
IfK = 2
CoutK = 3
CinK = 4
DeclK = 5
AssignK = 6
RepeatK = 7
UntilK = 8
WhileK = 9
ThenK = 10
ElseK = 11
class ExpKind(Enum):
OpK = 1
ConstK = 2
IdK = 3
class ExpType:
def __init__(self):
self.Real = 0.0
self.Integer = 0
self.Boolean = False
class Kind(Enum):
stmt = StmtKind # StmtKind = Objeto que contiene el tipo de Statement
exp = ExpKind # ExpKind = Objecto que contiene el tipo de Expresión
class Attr:
def __init__(self):
self.tipe = None
self.val = None
self.name = None
class TreeNode:
pass
def __init__(self):
self.token = Token(None, None, None, None) # Token
self.sibling = [] # Hermanos
self.nodeKind = None # Exp o Stmt
self.kind = None # Kind
self.attr = Attr() # Atributos
self.expType = None # Real,Int,Boolean
self.branch = [None] * 3 # Hijos