-
Notifications
You must be signed in to change notification settings - Fork 2
/
ifelse.py
32 lines (28 loc) · 876 Bytes
/
ifelse.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
from nodes import *
class IfStatement(Statement):
def __init__(self, parent, linenr):
Node.__init__(self, parent)
self.linenr = linenr
self.ifclause = None
self.elseifclauses = []
self.elseclause = None
def addif(self, ifclause):
self.ifclause = ifclause
def addelseif(self, elseifclause):
self.elseifclauses.append(elseifclause)
def addelse(self, elseclause):
self.elseclause = elseclause
class IfClause(BodyClause):
def __init__(self, parent, tokens):
Node.__init__(self, parent)
parent.addif(self)
self.conditionclause = ConditionClause(self, tokens)
class ElseIfClause(BodyClause):
def __init__(self, parent, tokens):
Node.__init__(self, parent)
parent.addelseif(self)
self.conditionclause = ConditionClause(self, tokens)
class ElseClause(BodyClause):
def __init__(self, parent):
Node.__init__(self, parent)
parent.addelse(self)