Created
April 27, 2017 05:52
-
-
Save aurorapar/44112b3700c3122f52fd3768305ab1dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for arg in sys.argv: | |
if arg != sys.argv[0]: | |
if arg.endswith(".4z"): | |
debug("Calling interpreter") | |
if os.path.exists(sys.argv[1]): | |
output = sys.argv[1].replace(".4z", ".java") | |
if not os.path.exists(output): | |
file = open(output, 'w+') | |
file.close() | |
else: | |
print("Overwriting %s..."%output) | |
with open(output, 'w') as file: | |
file.write("import java.util.*;\n") | |
file.write("\n\n") | |
file.write("class %s\n"%sys.argv[1].replace(".4z", "")) | |
file.write("\n") | |
file.write(" public static void main(String[] args)\n") | |
file.write(" {\n") | |
file.write(" Random rng = new Random();\n") | |
with open(sys.argv[1], 'r') as program: | |
lineNumber = 1 | |
for line in program: | |
print(line) | |
interpret(line, lineNumber, output, True) | |
lineNumber += 1 | |
print("Program closed") | |
else: | |
throwError("%s was not found on the system"%script, "Parameters", sys.argv) | |
else: | |
print("%s is not a valiid FORTRANZ script"%arg) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment