def exprLevel1(self): if self.current.type in ("STRING", "CHARACTER"): return caenodes.StringNode( str(self.current.value )) if self.current.type == "STRING" else caenodes.CharNode( str(self.current.value)) if not self.signals["num"]: self.advance(-1) if self.current.type in ("INTEGER", "FLOAT"): return caenodes.NumberNode(str(self.current.value)) else: caeerr.throw(caeerr._SyntaxError, "Expected an int, float, string or char")
def exprLevel5(self): if self.current.type in ("INTEGER", "FLOAT"): self.advance(2) if self.current == "cae-end-of-file": self.advance(-2) return self.exprLevel1() else: self.signals["num"]: bool == False self.advance(-2) left = self.exprLevel4() self.advance() if self.current != "cae-end-of-file": self.advance(-1) if self.current.type in ("PLUS", "MINUS"): op = self.current.value self.advance() if self.current.type in ("INTEGER", "FLOAT"): right = self.exprLevel4() return caenodes.BinOpNode(left, op, right) elif self.current.type in ("MUL", "DIV"): self.advance(-1) return self.exprLevel4() else: return left elif self.current.type in ("STRING", "CHARACTER"): self.advance(2) if self.current == "cae-end-of-file": self.advance(-2) return self.exprLevel1() else: self.signals["num"]: bool == False self.advance(-2) left = self.exprLevel1() self.advance() if self.current.type in ("PLUS"): op = self.current.value self.advance() if self.current.type in ("INTEGER", "FLOAT"): right = self.highest() return caenodes.BinOpNode(left, op, right) elif self.current.type in ("MUL"): self.advance(-1) return self.exprLevel4() else: caeerr.throw(caeerr._SyntaxError, "Expected an int, float, string or char")
def mul(self, **args): caeerr.throw(caeerr.UnsupportedOpError, "Unsupported Operation")
def div(self, right): try: return self.num / right.num except ZeroDivisionError: caeerr.throw(caeerr._ZeroDivisionError, "Zero Division")