def roll(self): while True: try: line = read_form() except (KeyboardInterrupt,EOFError) as e: print("\nMoriturus te saluto.") exit(0) tokens = scan_lexer.tokenize(line) balance = 0 ast,balance = scan_lexer.prstree_balance(tokens) if balance < 0: print("Exception: Cannot close more than opened parentheses") continue elif balance > 0: print("Exception: All opened parentheses must be closed") continue """ Replacing the string format""" ast = str_format(ast) for expr in ast: """ Print the evaluation of the expression in scope.evaluate(expression) """ try: print(evaluator.evaluate(expr)) except Exception as e: print(str(e))
def completer(self, input, state): tokens = scan_lexer.tokenize(input) symbol = tokens[-1] if not scan_lexer.is_smbl(symbol): return None options = self.get_options(symbol.name) if state >= len(options): return None tokens[-1] = options[state] return ''.join(tokens)