def evaluate(self): left = self.left.evaluate() right = self.right.evaluate() if not isinstance(left, int): raise SemanticError() if not isinstance(right, int): raise SemanticError() return left * right
def evaluate(self): left = self.left.evaluate() right = self.right.evaluate() if type(left) != type(right): raise SemanticError.SemanticError() elif not isinstance(left, int) and not isinstance(left, str): raise SemanticError.SemanticError() return left + right
def execute(self): left = self.left.location() right = self.right.evaluate() if not isinstance(left, types.FunctionType): raise SemanticError.SemanticError() if not isinstance(right, int) and not isinstance( right, str) and not isinstance(right, list): raise SemanticError.SemanticError() left(right)
def evaluate(self): left = self.list.evaluate() right = self.indeces.evaluate() if not isinstance(left, str) and not isinstance(left, list): raise SemanticError() if not isinstance(right, list): raise SemanticError() for element in right: if not isinstance(element, int): raise SemanticError.SemanticError() if len(left) < element + 1: raise SemanticError.SemanticError() left = left[element] return left
def evaluate(self): for stack in reversed(glob.variables): if self.name in stack.keys(): return stack[self.name] print(self.name) raise SemanticError()
def evaluate(self): expression = self.expression.evaluate() if (isinstance(expression, int)): if (expression != 0): return True else: return False raise SemanticError.SemanticError()
def execute(self, arguments=[]): function = glob.variables[0][self.name] if (len(arguments) != len(function["arguments"])): raise SemanticError() argumentsDict = {} for index, name in enumerate(function['arguments']): argumentsDict[name] = arguments[index] # print(argumentsDict) # print(function["statements"]) function["statements"].execute(argumentsDict)
def setValue(self, array, index, value): if not isinstance(index[0], int): raise SemanticError.SemanticError() if len(index) == 1: array[index[0]] = value return array else: temp = array[index[0]] temp = self.setValue(temp, index[1:], value) array[index[0]] = temp return array
def location(self): """ Evaluates this node for a location. """ print("2") raise SemanticError.SemanticError()
def execute(self): """ Executes this node. """ raise SemanticError.SemanticError()