1414from .config import OPTIONS
1515
1616# Exports only these functions. Others
17- __all__ = ['syntax_error ' , 'warning' ]
17+ __all__ = ['error ' , 'warning' ]
1818
1919
2020def msg_output (msg ):
@@ -31,7 +31,7 @@ def info(msg):
3131 OPTIONS .stderr .value .write ("info: %s\n " % msg )
3232
3333
34- def syntax_error (lineno , msg , fname = None ):
34+ def error (lineno , msg , fname = None ):
3535 """ Generic syntax error routine
3636 """
3737 if fname is None :
@@ -40,7 +40,7 @@ def syntax_error(lineno, msg, fname=None):
4040 if global_ .has_errors > OPTIONS .max_syntax_errors .value :
4141 msg = 'Too many errors. Giving up!'
4242
43- msg = "%s:%i: %s" % (fname , lineno , msg )
43+ msg = "%s:%i: error: %s" % (fname , lineno , msg )
4444 msg_output (msg )
4545
4646 if global_ .has_errors > OPTIONS .max_syntax_errors .value :
@@ -108,96 +108,96 @@ def warning_not_used(lineno, id_, kind='Variable'):
108108# numeric expression.
109109# ----------------------------------------
110110def syntax_error_expected_string (lineno , _type ):
111- syntax_error (lineno , "Expected a 'string' type expression, got '%s' instead" % _type )
111+ error (lineno , "Expected a 'string' type expression, got '%s' instead" % _type )
112112
113113
114114# ----------------------------------------
115115# Syntax error: FOR variable should be X
116116# instead of Y
117117# ----------------------------------------
118118def syntax_error_wrong_for_var (lineno , x , y ):
119- syntax_error (lineno , "FOR variable should be '%s' instead of '%s'" %
120- (x , y ))
119+ error (lineno , "FOR variable should be '%s' instead of '%s'" %
120+ (x , y ))
121121
122122
123123# ----------------------------------------
124124# Syntax error: Initializer expression is
125125# not constant
126126# ----------------------------------------
127127def syntax_error_not_constant (lineno ):
128- syntax_error (lineno , "Initializer expression is not constant." )
128+ error (lineno , "Initializer expression is not constant." )
129129
130130
131131# ----------------------------------------
132132# Syntax error: Id is neither an array nor
133133# a function
134134# ----------------------------------------
135135def syntax_error_not_array_nor_func (lineno , varname ):
136- syntax_error (lineno , "'%s' is neither an array nor a function." % varname )
136+ error (lineno , "'%s' is neither an array nor a function." % varname )
137137
138138
139139# ----------------------------------------
140140# Syntax error: Id is neither an array nor
141141# a function
142142# ----------------------------------------
143143def syntax_error_not_an_array (lineno , varname ):
144- syntax_error (lineno , "'%s' is not an array (or has not been declared yet)" % varname )
144+ error (lineno , "'%s' is not an array (or has not been declared yet)" % varname )
145145
146146
147147# ----------------------------------------
148148# Syntax error: function redefinition type
149149# mismatch
150150# ----------------------------------------
151151def syntax_error_func_type_mismatch (lineno , entry ):
152- syntax_error (lineno , "Function '%s' (previously declared at %i) type mismatch" % (entry .name , entry .lineno ))
152+ error (lineno , "Function '%s' (previously declared at %i) type mismatch" % (entry .name , entry .lineno ))
153153
154154
155155# ----------------------------------------
156156# Syntax error: function redefinition parm.
157157# mismatch
158158# ----------------------------------------
159159def syntax_error_parameter_mismatch (lineno , entry ):
160- syntax_error (lineno , "Function '%s' (previously declared at %i) parameter mismatch" % (entry .name , entry .lineno ))
160+ error (lineno , "Function '%s' (previously declared at %i) parameter mismatch" % (entry .name , entry .lineno ))
161161
162162
163163# ----------------------------------------
164164# Syntax error: can't convert value to the
165165# given type.
166166# ----------------------------------------
167167def syntax_error_cant_convert_to_type (lineno , expr_str , type_ ):
168- syntax_error (lineno , "Cant convert '%s' to type %s" % (expr_str , type_ ))
168+ error (lineno , "Cant convert '%s' to type %s" % (expr_str , type_ ))
169169
170170
171171# ----------------------------------------
172172# Syntax error: is a SUB not a FUNCTION
173173# ----------------------------------------
174174def syntax_error_is_a_sub_not_a_func (lineno , name ):
175- syntax_error (lineno , "'%s' is SUBROUTINE not a FUNCTION" % name )
175+ error (lineno , "'%s' is SUBROUTINE not a FUNCTION" % name )
176176
177177
178178# ----------------------------------------
179179# Syntax error: strict mode: missing type declaration
180180# ----------------------------------------
181181def syntax_error_undeclared_type (lineno : int , id_ : str ):
182- syntax_error (lineno , "strict mode: missing type declaration for '%s'" % id_ )
182+ error (lineno , "strict mode: missing type declaration for '%s'" % id_ )
183183
184184
185185# ----------------------------------------
186186# Cannot assign a value to 'var'. It's not a variable
187187# ----------------------------------------
188188def syntax_error_cannot_assign_not_a_var (lineno , id_ ):
189- syntax_error (lineno , "Cannot assign a value to '%s'. It's not a variable" % id_ )
189+ error (lineno , "Cannot assign a value to '%s'. It's not a variable" % id_ )
190190
191191
192192# ----------------------------------------
193193# Cannot assign a value to 'var'. It's not a variable
194194# ----------------------------------------
195195def syntax_error_address_must_be_constant (lineno ):
196- syntax_error (lineno , 'Address must be a numeric constant expression' )
196+ error (lineno , 'Address must be a numeric constant expression' )
197197
198198
199199# ----------------------------------------
200200# Cannot pass an array by value
201201# ----------------------------------------
202202def syntax_error_cannot_pass_array_by_value (lineno , id_ ):
203- syntax_error (lineno , "Array parameter '%s' must be passed ByRef" % id_ )
203+ error (lineno , "Array parameter '%s' must be passed ByRef" % id_ )
0 commit comments