def main(): lang = u"எழில்" if len(sys.argv) == 1: add_stdin() [fnames, debug, dostdin, encoding, stacksize, doprofile] = get_prog_name( lang) if dostdin : # ignore fnames, and encoding here ezhil_interactive_interpreter(lang,debug) else: ## evaluate a files sequentially except when exit() was called in ## one of them, while exceptions trapped per file without stopping ## the flow # print(u"mode with fnames") for idx, file_name in enumerate(fnames): if debug: print(u" **** Executing file # {} named {} ".format( idx + 1, file_name)) exit_code = execute_file(file_name=file_name, debug=debug, encoding=encoding, doprofile=doprofile) sys.exit(exit_code) pass
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 @staticmethod def runforever(): EzhilInterpExecuter(sys.stdin) return def ezhil_interactive_interpreter(lang = "எழில்",debug=False): ## interactive interpreter lexer = EzhilLex(debug) parse_eval = EzhilInterpreter( lexer, debug ) REPL( lang, lexer, parse_eval, debug ) if __name__ == "__main__": lang = "எழில்" [fname, debug, dostdin ]= get_prog_name(lang) if ( dostdin ): ezhil_interactive_interpreter(lang,debug) else: ## evaluate a files sequentially for files in fname: EzhilFileExecuter( files, debug ) pass
sys.stdin = self.old_stdin @staticmethod def runforever(): EzhilInterpExecuter(sys.stdin) return def ezhil_interactive_interpreter(lang = u"எழில்",debug=False): ## interactive interpreter lexer = EzhilLex(debug) parse_eval = EzhilInterpreter( lexer, debug ) REPL( lang, lexer, parse_eval, debug ) if __name__ == u"__main__": lang = u"எழில்" [fnames, debug, dostdin, encoding ]= get_prog_name(lang) if ( dostdin ): # ignore fnames, and encoding here ezhil_interactive_interpreter(lang,debug) else: ## evaluate a files sequentially except when exit() was called in one of them, ## while exceptions trapped per file without stopping the flow exitcode = 0 for idx,aFile in enumerate(fnames): if ( debug): print(u" **** Executing file # ",1+idx,u"named ",aFile) try: EzhilFileExecuter( aFile, debug, encoding=encoding ).run() except Exception as e: print(u"executing file, "+aFile.decode("utf-8")+u" with exception "+unicode(e)) if ( debug ): #traceback.print_tb(sys.exc_info()[2])
#!/usr/bin/python ## ## (C) 2007, 2008, 2013 Muthiah Annamalai, ## Licensed under GPL Version 3 ## ## Interpreter for EXRS language import os, sys, string, inspect, codecs from Interpreter import Interpreter, REPL, Lex, get_prog_name sys.stdout = codecs.getwriter('utf-8')(sys.stdout) #sys.stdin = codecs.getreader('utf-8')(sys.stdin) if __name__ == "__main__": lang = 'exprs'; [fname, debug, dostdin, encoding,stacksize,profile]= get_prog_name(lang) update=True; safe_mode=True; # don't care about encoding right now if ( dostdin ): ## interactive interpreter lexer = Lex( ) parse_eval = Interpreter( lexer, debug, safe_mode,update,stacksize ) REPL( lang, lexer, parse_eval, debug ) else: ## evaluate a files sequentially exitcode = 0 for files in fname: ## evaluate a file lexer = Lex(files) if ( debug ): lexer.dump_tokens() parse_eval = Interpreter( lexer, debug, safe_mode, update, stacksize )
@staticmethod def runforever(): EzhilInterpExecuter(sys.stdin) return def ezhil_interactive_interpreter(lang=u"எழில்", debug=False): ## interactive interpreter lexer = EzhilLex(debug) parse_eval = EzhilInterpreter(lexer, debug) REPL(lang, lexer, parse_eval, debug) if __name__ == u"__main__": lang = u"எழில்" [fnames, debug, dostdin] = get_prog_name(lang) if (dostdin): ezhil_interactive_interpreter(lang, debug) else: ## evaluate a files sequentially except when exit() was called in one of them, ## while exceptions trapped per file without stopping the flow exitcode = 0 for idx, aFile in enumerate(fnames): if (debug): print(u" **** Executing file # ", 1 + idx, u"named ", aFile) try: EzhilFileExecuter(aFile, debug).run() except Exception as e: print(u"executing file, " + aFile.decode("utf-8") + u" with exception " + unicode(e)) if (debug):