def parse(self): self.factor = Factor() self.factor.parse() if TokList.checkTok('MULT'): TokList.nextToken() self.term = Term() self.term.parse()
def parse(self): TokList.nextToken() self.const = Const() self.const.parse(TokList.getIdOrConst()) TokList.nextToken() if TokList.currentToken() == 'COMMA': self.constList = ConstList() self.constList.parse()
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')
def parse(self): self.id = Id() #Passing in name of id to the parse function self.id.parse(TokList.getIdOrConst()) TokList.nextToken() if TokList.checkTok('COMMA'): TokList.match('COMMA', 'id list') self.id_list = IdList() self.id_list.parse()
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()
def parse(self): self.term = Term() self.term.parse() if TokList.checkTok('PLUS'): TokList.nextToken() self.plusOrMinus = '+' self.expr = Expr() self.expr.parse() elif TokList.checkTok('MINUS'): TokList.nextToken() self.plusOrMinus = '-' self.expr = Expr() self.expr.parse()
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')
def parse(self): if TokList.checkTok('CONST'): self.const = Const() self.const.parse(TokList.getIdOrConst()) TokList.nextToken() elif TokList.checkTok('ID'): self.id = Id() self.id.parse(TokList.getIdOrConst()) TokList.nextToken() elif TokList.match('LEFTPARAN', 'factor'): self.expr = Expr.Expr() self.expr.parse() TokList.match('RIGHTPARAN', 'factor')
def parse(self): TokList.match('IF', 'if') self.cond = Cond() self.cond.parse() TokList.match('THEN', 'if') self.stmt_seq_then = StmtSeq.StmtSeq() self.stmt_seq_then.parse() if TokList.checkTok('ELSE'): TokList.nextToken() self.stmt_seq_else = StmtSeq.StmtSeq() self.stmt_seq_else.parse() TokList.match('ENDIF', 'if') TokList.match('SEMICOLON', 'if')
def parse(self): if TokList.checkTok('NOT'): self.notStr = '!' TokList.nextToken() TokList.match('LEFTPARAN', 'cond') self.cond = Cond() self.cond.parse() TokList.match('RIGHTPARAN', 'cond') return self.cmpr = Cmpr() self.cmpr.parse() if TokList.checkTok('OR'): TokList.nextToken() self.cond = Cond() self.cond.parse()
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()