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,8 @@ 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+ ("MLC" , r"/\*(.|\n)*?\*/" ), # Multi-line comment e.g., /* This is a comment */
5764 ("MISMATCH" , r"." ), # Any other character
5865 ]
5966 tok_regex = "|" .join ("(?P<%s>%s)" % pair for pair in token_specification )
@@ -69,6 +76,8 @@ def tokenize(self, text):
6976 self .tokens .append (("NEWLINE" , value ))
7077 elif kind == "SKIP" :
7178 continue
79+ elif kind == ("SLC" or "MLC" ):
80+ continue
7281 elif kind == "MISMATCH" :
7382 error (f"Invalid character: { value } " )
7483 sys .exit (1 )
@@ -121,7 +130,10 @@ def arguments(self):
121130 self .current < len (self .tokens ) and self .tokens [self .current ][0 ] != "RPAREN"
122131 ):
123132 token = self .tokens [self .current ]
124- if token [0 ] in {"STRING" , "NUMBER" }:
133+ if token [0 ] == "STRING" :
134+ args .append (token [1 ][1 :- 1 ]) # Strip surrounding quotes
135+ self .current += 1
136+ elif token [0 ] == "NUMBER" :
125137 args .append (token [1 ])
126138 self .current += 1
127139 elif token [0 ] == "COMMA" :
@@ -249,7 +261,7 @@ def create_model(self, filename, parameters, attributes):
249261 stderr = subprocess .DEVNULL ,
250262 )
251263 stdout , stderr = process .communicate ()
252- print ("Model created." )
264+ info ("Model created." )
253265
254266 if process .returncode != 0 :
255267 if stderr :
0 commit comments