Exemplo n.º 1
0
 def parse(self):
     self.id = Id()
     self.id.parse(TokList.getIdOrConst())
     TokList.nextToken()
     TokList.match('ASSIGN', 'assign')
     self.expr = Expr()
     self.expr.parse()
     TokList.match('SEMICOLON', 'assign')
Exemplo n.º 2
0
 def parse(self):
     self.leftExpr = Expr()
     self.leftExpr.parse()
     if TokList.checkTok('EQUAL'):
         self.checkValue = '='
         TokList.nextToken()
     elif TokList.checkTok('LESSTHAN'):
         self.checkValue = '<'
         TokList.nextToken()
     elif TokList.checkTok('LESSTHANEQUAL'):
         self.checkValue = '<='
         TokList.nextToken()
     else:
         print('Error: improper syntax for comparator')
         exit()
     self.rightExpr = Expr()
     self.rightExpr.parse()
Exemplo n.º 3
0
 def parse(self):
     self.const = Const()
     self.const.parse(TokList.getIdOrConst())
     TokList.nextToken()
     if TokList.currentToken() == 'COMMA':
         self.constList = ConstList()
         self.constList.parse()
     TokList.match('COLON', 'case line')
     self.expr = Expr()
     self.expr.parse()
     self.caseLineFollow = CaseLineFollow()
     self.caseLineFollow.parse()
Exemplo n.º 4
0
 def parse(self):
     TokList.match('CASE','case')
     self.id = Id()
     self.id.parse(TokList.getIdOrConst())
     TokList.nextToken()
     TokList.match('OF','case')
     self.case_line = CaseLine()
     self.case_line.parse()
     TokList.match('ELSE','case')
     self.expr = Expr()
     self.expr.parse()
     TokList.match('END','case')
     TokList.match('SEMICOLON','case')
Exemplo n.º 5
0
 def parse(self):
     TokList.match('OUTPUT', 'output')
     self.expr = Expr()
     self.expr.parse()
     TokList.match('SEMICOLON', 'output')