diff --git a/docs/highlight.py b/docs/highlight.py
index 6ebd401..4c88aba 100644
--- a/docs/highlight.py
+++ b/docs/highlight.py
@@ -1,3 +1,11 @@
+import sys
+
+if len(sys.argv) < 2:
+ exit(1)
+
+fileName = sys.argv[1]
+thefile = open(fileName).readlines()
+
def isnumber(num):
try:
float(num)
@@ -5,18 +13,19 @@ def isnumber(num):
except ValueError:
return False
-instr = 1
allstr = ""
color = ""
keywords = ["if", "jump", "end", "stdin", "stdout", "stdlnout", "set", "gettype", "exists", "setlist", "setlistat", "getlistat", "getlistsize", "listappend", "getstrsize", "getstrcharat", "add", "subtract", "multiply", "divide", "equal", "inequal", "not", "greater", "lesser", "stoi", "stod", "tostring", "fun", "return", "endfun", "pusharg", "call", "use", "extern"]
-while instr != "":
- instr = input("Code: ")
- allstr += instr + "
"
-lines = len(allstr.split("
"))-2
+for line in thefile:
+ allstr += line + "
"
+
+lines = len(allstr.split("
"))-1
a = allstr.split()
for i in range(lines):
+ instr = False
+ incom = False
words = len(allstr.split("
")[i].split())
for j in range(words):
tempword = allstr.split("
")[i].split()[j]
@@ -26,6 +35,9 @@ for i in range(lines):
color = "\033[32m"
elif tempword in keywords:
color = "\033[95m"
+ elif tempword[0] == "#":
+ incom = True
+ color = "\033[37m"
elif tempword[0] == "&":
color = "\033[93m"
elif tempword[0] == "$":
@@ -38,12 +50,17 @@ for i in range(lines):
color = "\033[94m"
elif tempword[0] == "*":
color = "\033[93m"
- elif tempword[0] == "\"" and tempword[len(tempword)-1] == "\"":
+ elif tempword[0] == "\"":
color = "\033[92m"
+ instr = not instr
elif tempword[0] == "\'" and tempword[len(tempword)-1] == "\'":
color = "\033[92m"
- elif isnumber(tempword):
+ elif isnumber(tempword) or tempword == "true" or tempword == "false":
color = "\033[96m"
+ elif instr:
+ color = "\033[92m"
+ elif incom:
+ color = "\033[37m"
else:
color = "\033[91m"