def eval_exp(exp): '''Evaluate single expression''' try: result = ply.yacc.parse(exp) except: interpreter_helper.internal_error(exp, sys.exc_info()[0]) # Uncomment for debugging sys.excepthook(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) sys.exit(1) return result
def print_repl_result(result): '''Print the result of the evaluation of an expression. This is another wrapper, but will soon be more encompassing. I will need to do some serious type checking and coercion''' try: if result is None: return else: str_result = result.CL_repr() except: interpreter_helper.internal_error(result, sys.exc_info()[0]) # Uncomment for debugging sys.excepthook(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) sys.exit(1) print str_result