Skip to content

Instantly share code, notes, and snippets.

@aurorapar
Created April 27, 2017 05:52
Show Gist options
  • Save aurorapar/44112b3700c3122f52fd3768305ab1dd to your computer and use it in GitHub Desktop.
Save aurorapar/44112b3700c3122f52fd3768305ab1dd to your computer and use it in GitHub Desktop.
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