Compare commits
	
		
			2 Commits
		
	
	
		
			76205a613d
			...
			074b473bb1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 074b473bb1 | |||
| a3b9cd2519 | 
							
								
								
									
										53
									
								
								docs/highlight.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								docs/highlight.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					def isnumber(num):
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        float(num)
 | 
				
			||||||
 | 
					        return True
 | 
				
			||||||
 | 
					    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 + " <br> "
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					lines = len(allstr.split("<br>"))-2
 | 
				
			||||||
 | 
					a = allstr.split()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for i in range(lines):
 | 
				
			||||||
 | 
					    words = len(allstr.split("<br>")[i].split())
 | 
				
			||||||
 | 
					    for j in range(words):
 | 
				
			||||||
 | 
					        tempword = allstr.split("<br>")[i].split()[j]
 | 
				
			||||||
 | 
					        if allstr.split("<br>")[i].split()[0][0] == "#":
 | 
				
			||||||
 | 
					            color = "\033[37m"
 | 
				
			||||||
 | 
					        elif allstr.split("<br>")[i].split()[0][0] == "@":
 | 
				
			||||||
 | 
					            color = "\033[32m"
 | 
				
			||||||
 | 
					        elif tempword in keywords:
 | 
				
			||||||
 | 
					            color = "\033[95m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "&":
 | 
				
			||||||
 | 
					            color = "\033[93m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "$":
 | 
				
			||||||
 | 
					            color = "\033[33m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "%":
 | 
				
			||||||
 | 
					            color = "\033[32m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "-":
 | 
				
			||||||
 | 
					            color = "\033[34m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "!":
 | 
				
			||||||
 | 
					            color = "\033[94m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "*":
 | 
				
			||||||
 | 
					            color = "\033[93m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "\"" and tempword[len(tempword)-1] == "\"":
 | 
				
			||||||
 | 
					            color = "\033[92m"
 | 
				
			||||||
 | 
					        elif tempword[0] == "\'" and tempword[len(tempword)-1] == "\'":
 | 
				
			||||||
 | 
					            color = "\033[92m"
 | 
				
			||||||
 | 
					        elif isnumber(tempword):
 | 
				
			||||||
 | 
					            color = "\033[96m"
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            color = "\033[91m"
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        print(f'{color}{tempword}', end=" ")
 | 
				
			||||||
 | 
					    print()
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					print("\033[00m", end="")
 | 
				
			||||||
		Reference in New Issue
	
	Block a user