1919__all__ = ['error' , 'warning' ]
2020
2121
22- def msg_output (msg ) :
22+ def msg_output (msg : str ) -> None :
2323 if msg in global_ .error_msg_cache :
2424 return
2525
2626 OPTIONS .stderr .write ("%s\n " % msg )
2727 global_ .error_msg_cache .add (msg )
2828
2929
30- def info (msg ) :
30+ def info (msg : str ) -> None :
3131 if OPTIONS .Debug < 1 :
3232 return
3333 OPTIONS .stderr .write ("info: %s\n " % msg )
3434
3535
36- def error (lineno , msg , fname : Optional [str ] = None ):
36+ def error (lineno : int , msg : str , fname : Optional [str ] = None ) -> None :
3737 """ Generic syntax error routine
3838 """
3939 if fname is None :
@@ -51,7 +51,7 @@ def error(lineno, msg, fname: Optional[str] = None):
5151 global_ .has_errors += 1
5252
5353
54- def warning (lineno , msg , fname : Optional [str ] = None ):
54+ def warning (lineno : int , msg : str , fname : Optional [str ] = None ) -> None :
5555 """ Generic warning error routine
5656 """
5757 if fname is None :
@@ -62,7 +62,7 @@ def warning(lineno, msg, fname: Optional[str] = None):
6262 global_ .has_warnings += 1
6363
6464
65- def warning_implicit_type (lineno , id_ , type_ = None ):
65+ def warning_implicit_type (lineno : int , id_ : str , type_ : str = None ):
6666 """ Warning: Using default implicit type 'x'
6767 """
6868 if OPTIONS .strict :
@@ -75,19 +75,19 @@ def warning_implicit_type(lineno, id_, type_=None):
7575 warning (lineno , "Using default implicit type '%s' for '%s'" % (type_ , id_ ))
7676
7777
78- def warning_condition_is_always (lineno , cond = False ):
78+ def warning_condition_is_always (lineno : int , cond : bool = False ):
7979 """ Warning: Condition is always false/true
8080 """
8181 warning (lineno , "Condition is always %s" % cond )
8282
8383
84- def warning_conversion_lose_digits (lineno ):
84+ def warning_conversion_lose_digits (lineno : int ):
8585 """ Warning: Conversion may lose significant digits
8686 """
8787 warning (lineno , 'Conversion may lose significant digits' )
8888
8989
90- def warning_empty_loop (lineno ):
90+ def warning_empty_loop (lineno : int ):
9191 """ Warning: Empty loop
9292 """
9393 warning (lineno , 'Empty loop' )
@@ -99,7 +99,7 @@ def warning_empty_if(lineno):
9999 warning (lineno , 'Useless empty IF ignored' )
100100
101101
102- # Emmits an optimization warning
102+ # Emits an optimization warning
103103def warning_not_used (lineno , id_ , kind = 'Variable' ):
104104 if OPTIONS .optimization > 0 :
105105 warning (lineno , "%s '%s' is never used" % (kind , id_ ))
@@ -109,71 +109,70 @@ def warning_not_used(lineno, id_, kind='Variable'):
109109# Syntax error: Expected string instead of
110110# numeric expression.
111111# ----------------------------------------
112- def syntax_error_expected_string (lineno , _type ):
112+ def syntax_error_expected_string (lineno : str , _type : str ):
113113 error (lineno , "Expected a 'string' type expression, got '%s' instead" % _type )
114114
115115
116116# ----------------------------------------
117117# Syntax error: FOR variable should be X
118118# instead of Y
119119# ----------------------------------------
120- def syntax_error_wrong_for_var (lineno , x , y ):
121- error (lineno , "FOR variable should be '%s' instead of '%s'" %
122- (x , y ))
120+ def syntax_error_wrong_for_var (lineno : str , x : str , y : str ):
121+ error (lineno , "FOR variable should be '%s' instead of '%s'" % (x , y ))
123122
124123
125124# ----------------------------------------
126125# Syntax error: Initializer expression is
127126# not constant
128127# ----------------------------------------
129- def syntax_error_not_constant (lineno ):
128+ def syntax_error_not_constant (lineno : int ):
130129 error (lineno , "Initializer expression is not constant." )
131130
132131
133132# ----------------------------------------
134133# Syntax error: Id is neither an array nor
135134# a function
136135# ----------------------------------------
137- def syntax_error_not_array_nor_func (lineno , varname ):
136+ def syntax_error_not_array_nor_func (lineno : int , varname : str ):
138137 error (lineno , "'%s' is neither an array nor a function." % varname )
139138
140139
141140# ----------------------------------------
142141# Syntax error: Id is neither an array nor
143142# a function
144143# ----------------------------------------
145- def syntax_error_not_an_array (lineno , varname ):
144+ def syntax_error_not_an_array (lineno : int , varname : str ):
146145 error (lineno , "'%s' is not an array (or has not been declared yet)" % varname )
147146
148147
149148# ----------------------------------------
150149# Syntax error: function redefinition type
151150# mismatch
152151# ----------------------------------------
153- def syntax_error_func_type_mismatch (lineno , entry ):
152+ def syntax_error_func_type_mismatch (lineno : int , entry ):
154153 error (lineno , "Function '%s' (previously declared at %i) type mismatch" % (entry .name , entry .lineno ))
155154
156155
157156# ----------------------------------------
158157# Syntax error: function redefinition parm.
159158# mismatch
160159# ----------------------------------------
161- def syntax_error_parameter_mismatch (lineno , entry ):
160+ def syntax_error_parameter_mismatch (lineno : int , entry ):
162161 error (lineno , "Function '%s' (previously declared at %i) parameter mismatch" % (entry .name , entry .lineno ))
163162
164163
165164# ----------------------------------------
166165# Syntax error: can't convert value to the
167166# given type.
168167# ----------------------------------------
169- def syntax_error_cant_convert_to_type (lineno , expr_str , type_ ):
168+ def syntax_error_cant_convert_to_type (lineno : int , expr_str : str , type_ : str ):
170169 error (lineno , "Cant convert '%s' to type %s" % (expr_str , type_ ))
171170
172171
173172# ----------------------------------------
174173# Syntax error: is a SUB not a FUNCTION
175174# ----------------------------------------
176- def syntax_error_is_a_sub_not_a_func (lineno , name ):
175+ def syntax_error_is_a_sub_not_a_func (lineno : int , name : str ):
177176 error (lineno , "'%s' is SUBROUTINE not a FUNCTION" % name )
178177
179178
@@ -187,19 +186,19 @@ def syntax_error_undeclared_type(lineno: int, id_: str):
187186# ----------------------------------------
188187# Cannot assign a value to 'var'. It's not a variable
189188# ----------------------------------------
190- def syntax_error_cannot_assign_not_a_var (lineno , id_ ):
189+ def syntax_error_cannot_assign_not_a_var (lineno : int , id_ : str ):
191190 error (lineno , "Cannot assign a value to '%s'. It's not a variable" % id_ )
192191
193192
194193# ----------------------------------------
195194# Cannot assign a value to 'var'. It's not a variable
196195# ----------------------------------------
197- def syntax_error_address_must_be_constant (lineno ):
196+ def syntax_error_address_must_be_constant (lineno : int ):
198197 error (lineno , 'Address must be a numeric constant expression' )
199198
200199
201200# ----------------------------------------
202201# Cannot pass an array by value
203202# ----------------------------------------
204- def syntax_error_cannot_pass_array_by_value (lineno , id_ ):
203+ def syntax_error_cannot_pass_array_by_value (lineno : int , id_ : str ):
205204 error (lineno , "Array parameter '%s' must be passed ByRef" % id_ )
0 commit comments