11__version__ = "1.0.0"
22
3- import asyncio
43import ollama
54import logging
65import sys
@@ -34,6 +33,12 @@ def warning(message):
3433 )
3534
3635
36+ def info (message ):
37+ print (
38+ f"{ colorama .Fore .GREEN } { colorama .Style .BRIGHT } [INFO]{ colorama .Style .RESET_ALL } { message } "
39+ )
40+
41+
3742# Set up logging
3843logging .basicConfig (level = logging .WARNING )
3944
@@ -54,6 +59,11 @@ def tokenize(self, text):
5459 ("COMMA" , r"," ), # Comma
5560 ("NEWLINE" , r"\n" ), # Line endings
5661 ("SKIP" , r"[ \t]+" ), # Skip over spaces and tabs
62+ ("SLC" , r"//.*" ), # Single-line comment e.g., // This is a comment
63+ (
64+ "MLC" ,
65+ r"/\*(.|\n)*?\*/" ,
66+ ), # Multi-line comment e.g., /* This is a comment */
5767 ("MISMATCH" , r"." ), # Any other character
5868 ]
5969 tok_regex = "|" .join ("(?P<%s>%s)" % pair for pair in token_specification )
@@ -69,6 +79,8 @@ def tokenize(self, text):
6979 self .tokens .append (("NEWLINE" , value ))
7080 elif kind == "SKIP" :
7181 continue
82+ elif kind == ("SLC" or "MLC" ):
83+ continue
7284 elif kind == "MISMATCH" :
7385 error (f"Invalid character: { value } " )
7486 sys .exit (1 )
@@ -121,7 +133,10 @@ def arguments(self):
121133 self .current < len (self .tokens ) and self .tokens [self .current ][0 ] != "RPAREN"
122134 ):
123135 token = self .tokens [self .current ]
124- if token [0 ] in {"STRING" , "NUMBER" }:
136+ if token [0 ] == "STRING" :
137+ args .append (token [1 ][1 :- 1 ]) # Strip surrounding quotes
138+ self .current += 1
139+ elif token [0 ] == "NUMBER" :
125140 args .append (token [1 ])
126141 self .current += 1
127142 elif token [0 ] == "COMMA" :
@@ -249,7 +264,7 @@ def create_model(self, filename, parameters, attributes):
249264 stderr = subprocess .DEVNULL ,
250265 )
251266 stdout , stderr = process .communicate ()
252- print ("Model created." )
267+ info ("Model created." )
253268
254269 if process .returncode != 0 :
255270 if stderr :
0 commit comments