-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.py
53 lines (40 loc) · 1002 Bytes
/
ast.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
class Node(object):
def __init__(self, name, children):
self.name = name
if children:
self.children = children
else:
self.children = [ ]
def show(self):
pass
class ProgramNode(Node):
pass
class TranslationUnit(Node):
pass
class BinaryOp(Node):
pass
class UnaryOp(Node):
pass
class FuncCall(Node):
#type will be looked up during code generation in the symbol table
pass
class Assignment(Node):
def __init__(self, name, type, children): #type is the type of the variable being assigned
self.type = type
super(Assignment, self).__init__(name, children)
class Return(Node):
pass
class FuncDecl(Node):
def __init__(self, name, params, children):
self.params = params
super(FuncDecl, self).__init__(name, children)
class ParamsList(Node):
pass
class ParamDecl(Node):
pass
class ArgList(Node):
pass
class If(Node):
pass
class While(Node):
pass