def ezhil_file_parse_eval(file_input, redirectop, debug): """ runs as a separate process with own memory space, pid etc, with @file_input, @debug values, the output is written out into a file named, "ezhil_$PID.out". Calling process is responsible to cleanup the cruft. Note file_input can be a string version of a program to be evaluated if it is enclosed properly in a list format """ if (redirectop): sys.stdout = open( EzhilRedirectOutput.pidFileName(current_process().pid), "w") sys.stderr = sys.stdout lexer = EzhilLex(file_input, debug) if (debug): lexer.dump_tokens() parse_eval = EzhilInterpreter(lexer, debug) web_ast = parse_eval.parse() if (debug): print(web_ast) if (debug): print("*" * 60) print(str(parse_eval)) exit_code = 0 try: env = parse_eval.evaluate() except Exception as e: exit_code = -1 print str(e) finally: if (redirectop): # cerrar - முடி sys.stdout.flush() sys.stderr.flush() sys.stdout.close() return exit_code
def __init__(self, src_file): """ @styler uses a Wiki/HTML/LaTeX output formatter, with a color theme specificied by @theme to render the text into the appropriate format""" Visitor.__init__(self) self.styler = WikiStyle.wrap_msg self.theme = XsyTheme() self.lexer = EzhilLex(src_file) #print self.lexer.comments.keys() self.output = [] self.line = 1 #current line self.NEWLINE = "<BR />\n"
def __init__(self, file_input, debug=False, redirectop=False): EzhilRedirectInputOutput.__init__(self, file_input, redirectop) try: lang = "எழில்" lexer = EzhilLex(debug) if (debug): print(str(lexer)) parse_eval = EzhilInterpreter(lexer, debug) ezhil_file_REPL(file_input, lang, lexer, parse_eval, debug) except Exception as e: print("exception ", str(e)) raise e finally: if (redirectop): self.tmpf.close() sys.stdout = self.old_stdout sys.stderr = self.old_stderr sys.stdin = self.old_stdin
def __init__(self, file_input, debug=False, redirectop=False): EzhilRedirectInputOutput.__init__(self, file_input, redirectop) try: lang = u"எழில்" lexer = EzhilLex(debug) if (debug): print(unicode(lexer)) parse_eval = EzhilInterpreter(lexer, debug) ezhil_file_REPL(file_input, lang, lexer, parse_eval, debug) except Exception as e: print(u"exception ", unicode(e)) traceback.print_tb(sys.exc_info()[2]) raise e finally: if (redirectop): #self.tmpf.close() sys.stdout = self.old_stdout sys.stderr = self.old_stderr sys.stdin = self.old_stdin
def __init__(self, file_input, debug=False, redirectop=False): EzhilRedirectOutput.__init__(self, redirectop) try: lexer = EzhilLex(file_input, debug) if (debug): lexer.dump_tokens() parse_eval = EzhilInterpreter(lexer, debug) parse_eval.parse() if (debug): print("*" * 60) print(str(parse_eval)) env = parse_eval.evaluate() except Exception as e: print("exception ", str(e)) raise e finally: if (redirectop): self.tmpf.close() sys.stdout = self.old_stdout sys.stderr = self.old_stderr
def ezhil_interactive_interpreter(lang=u"எழில்", debug=False): ## interactive interpreter lexer = EzhilLex(debug) parse_eval = EzhilInterpreter(lexer, debug) REPL(lang, lexer, parse_eval, debug)