23 lines
806 B
Python
23 lines
806 B
Python
import reader
|
|
import sys
|
|
|
|
def main():
|
|
print("Welcome to the lisp interpreter! REPL expression results will be stored in an output file, output.txt by default. This can be overridden by passing an argument to the program.\n"
|
|
"Enter (quit) to exit the program. Supported functionality includes mathematical operations, conditional statements, variables, user-defined functions, logical operations, and list manipulation.")
|
|
outputfile = "output.txt" if len(sys.argv) == 1 else sys.argv[1]
|
|
interpreter = reader.Reader(outputfile)
|
|
# REPL Loop
|
|
while True:
|
|
try:
|
|
expression: str = input("> ").upper()
|
|
except KeyboardInterrupt:
|
|
print("\n>> bye")
|
|
return
|
|
except EOFError:
|
|
print("\n>> bye")
|
|
return
|
|
interpreter.tokenize(expression)
|
|
interpreter.run()
|
|
|
|
if __name__ == "__main__":
|
|
main() |