forked from OrignalLazyCoder/Lazy_Language
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (25 loc) · 704 Bytes
/
main.py
File metadata and controls
30 lines (25 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
sys.path.insert(0, 'Interpreter')
import Interpreter
import sys
compileFile = False
def getFileText(name):
nameArray = name.split('.')
if nameArray[len(nameArray) - 1] != 'lca':
print('INVALID FILE EXTENTION')
return None
f = open(name, 'r')
text = f.read()
return text
while True and not compileFile:
if len(sys.argv) < 2:
text = input('lazy > ')
if text.strip() == "quit()": break
if text.strip() == "": continue
else:
compileFile = True
text = getFileText(sys.argv[1])
if text != None:
result, error = Interpreter.run('<stdin>', text)
if error:
print(error.as_string())