-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsajiloc.py
31 lines (26 loc) · 860 Bytes
/
sajiloc.py
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 sajilo
import sys
import os.path
# Infinite loop console func
def console():
while True:
text = input(""
"Sajilo Shell>> \n$")
if text == "exit();" or text == "anta();":
print("\n")
print("\nUsage with file sajilo filename\nSajilo Compiler prayog garda 'sajiloc filname' use garnu hola")
exit()
# If the command is not exit()
sajilo.shell(text)
# If no file is provided switch to the REPL mode.
if len(sys.argv) == 1:
console()
else:
# Get the file extension if file is provided.
ext = str(os.path.splitext(sys.argv[1])[1])
if ext == ".sajilo":
# Execute the file if extension matches
with open(sys.argv[1]) as f:
sajilo.execute(f.read())
else:
print("Sajilo Compiler only supports .sajilo files!")