git @ Cat's Eye Technologies Exanoke / 4719dbd
Remove RPython target. Remove doctest runner. Chris Pressey 1 year, 1 month ago
1 changed file(s) with 2 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
453453 optparser.add_option("-a", "--show-ast",
454454 action="store_true", dest="show_ast", default=False,
455455 help="show parsed AST instead of evaluating")
456 optparser.add_option("-t", "--test",
457 action="store_true", dest="test", default=False,
458 help="run test cases and exit")
459456 (options, args) = optparser.parse_args(argv[1:])
460 if options.test:
461 import doctest
462 (fails, something) = doctest.testmod()
463 if fails == 0:
464 print("All tests passed.")
465 sys.exit(0)
466 else:
467 sys.exit(1)
468 file = open(args[0])
469 text = file.read()
470 file.close()
457 with open(args[0], 'r') as f:
458 text = f.read()
471459 p = Parser(text)
472460 try:
473461 prog = p.program()
489477 sys.exit(0)
490478
491479
492 def target(*args):
493 import os
494
495 def rpython_load(filename):
496 fd = os.open(filename, os.O_RDONLY, 0o644)
497 text = ''
498 chunk = os.read(fd, 1024)
499 text += chunk
500 while len(chunk) == 1024:
501 chunk = os.read(fd, 1024)
502 text += chunk
503 os.close(fd)
504 return text
505
506 def rpython_main(argv):
507 text = rpython_load(argv[1])
508 p = Parser(text)
509 prog = p.program()
510 ev = Evaluator(prog)
511 result = ev.eval(prog)
512 print(result.__repr__())
513 return 0
514
515 return rpython_main, None
516
517
518480 if __name__ == "__main__":
519481 main(sys.argv)