@@ -144,7 +144,7 @@ def current_scope(self):
144144 def global_scope (self ):
145145 return 0
146146
147- def get_entry (self , id_ , scope = None ):
147+ def get_entry (self , id_ : str , scope = None ):
148148 """ Returns the ID entry stored in self.table, starting
149149 by the first one. Returns None if not found.
150150 If scope is not None, only the given scope is searched.
@@ -162,7 +162,7 @@ def get_entry(self, id_, scope=None):
162162
163163 return None # Not found
164164
165- def declare (self , id_ , lineno , entry ):
165+ def declare (self , id_ : str , lineno : int , entry ):
166166 """ Check there is no 'id' already declared in the current scope, and
167167 creates and returns it. Otherwise, returns None,
168168 and the caller function raises the syntax/semantic error.
@@ -204,7 +204,7 @@ def declare(self, id_, lineno, entry):
204204 # -------------------------------------------------------------------------
205205 # Symbol Table Checks
206206 # -------------------------------------------------------------------------
207- def check_is_declared (self , id_ , lineno , classname = 'identifier' ,
207+ def check_is_declared (self , id_ : str , lineno : int , classname = 'identifier' ,
208208 scope = None , show_error = True ):
209209 """ Checks if the given id is already defined in any scope
210210 or raises a Syntax Error.
@@ -222,7 +222,7 @@ def check_is_declared(self, id_, lineno, classname='identifier',
222222 return False
223223 return True
224224
225- def check_is_undeclared (self , id_ , lineno , classname = 'identifier' ,
225+ def check_is_undeclared (self , id_ : str , lineno : int , classname = 'identifier' ,
226226 scope = None , show_error = False ):
227227 """ The reverse of the above.
228228
@@ -243,7 +243,7 @@ def check_is_undeclared(self, id_, lineno, classname='identifier',
243243 self .table [scope ][id_ ].lineno ))
244244 return False
245245
246- def check_class (self , id_ , class_ , lineno , scope = None , show_error = True ):
246+ def check_class (self , id_ : str , class_ , lineno : int , scope = None , show_error = True ):
247247 """ Check the id is either undefined or defined with
248248 the given class.
249249
@@ -345,7 +345,7 @@ def entry_size(entry):
345345 global_ .LOOPS = global_ .META_LOOPS .pop ()
346346 return offset
347347
348- def move_to_global_scope (self , id_ ):
348+ def move_to_global_scope (self , id_ : str ):
349349 """ If the given id is in the current scope, and there is more than
350350 1 scope, move the current id to the global scope and make it global.
351351 Labels need this.
@@ -362,7 +362,7 @@ def move_to_global_scope(self, id_):
362362 del self .table [self .current_scope ][id_ ] # Removes it from the current scope
363363 __DEBUG__ ("'{}' entry moved to global scope" .format (id_ ))
364364
365- def make_static (self , id_ ):
365+ def make_static (self , id_ : str ):
366366 """ The given ID in the current scope is changed to 'global', but the
367367 variable remains in the current scope, if it's a 'global private'
368368 variable: A variable private to a function scope, but whose contents
@@ -388,7 +388,7 @@ def update_aliases(entry):
388388 for symbol in entry .aliased_by :
389389 symbol .alias = entry
390390
391- def access_id (self , id_ , lineno , scope = None , default_type = None , default_class = CLASS .unknown ):
391+ def access_id (self , id_ : str , lineno : int , scope = None , default_type = None , default_class = CLASS .unknown ):
392392 """ Access a symbol by its identifier and checks if it exists.
393393 If not, it's supposed to be an implicit declared variable.
394394
@@ -420,7 +420,7 @@ def access_id(self, id_, lineno, scope=None, default_type=None, default_class=CL
420420
421421 return result
422422
423- def access_var (self , id_ , lineno , scope = None , default_type = None ):
423+ def access_var (self , id_ : str , lineno : int , scope = None , default_type = None ):
424424 """
425425 Since ZX BASIC allows access to undeclared variables, we must allow
426426 them, and *implicitly* declare them if they are not declared already.
@@ -444,7 +444,7 @@ def access_var(self, id_, lineno, scope=None, default_type=None):
444444
445445 return result
446446
447- def access_array (self , id_ , lineno , scope = None , default_type = None ):
447+ def access_array (self , id_ : str , lineno : int , scope = None , default_type = None ):
448448 """
449449 Called whenever an accessed variable is expected to be an array.
450450 ZX BASIC requires arrays to be declared before usage, so they're
@@ -460,7 +460,7 @@ def access_array(self, id_, lineno, scope=None, default_type=None):
460460
461461 return self .access_id (id_ , lineno , scope = scope , default_type = default_type )
462462
463- def access_func (self , id_ , lineno , scope = None , default_type = None ):
463+ def access_func (self , id_ : str , lineno : int , scope = None , default_type = None ):
464464 """
465465 Since ZX BASIC allows access to undeclared functions, we must allow
466466 and *implicitly* declare them if they are not declared already.
@@ -484,7 +484,7 @@ def access_func(self, id_, lineno, scope=None, default_type=None):
484484
485485 return result
486486
487- def access_call (self , id_ , lineno , scope = None , type_ = None ):
487+ def access_call (self , id_ : str , lineno : int , scope = None , type_ = None ):
488488 """ Creates a func/array/string call. Checks if id is callable or not.
489489 An identifier is "callable" if it can be followed by a list of para-
490490 meters.
@@ -613,7 +613,7 @@ def declare_type(self, type_):
613613 entry = self .declare (type_ .name , type_ .lineno , type_ )
614614 return entry
615615
616- def declare_const (self , id_ , lineno , type_ , default_value ):
616+ def declare_const (self , id_ : str , lineno : int , type_ , default_value ):
617617 """ Similar to the above. But declares a Constant.
618618 """
619619 if not self .check_is_undeclared (id_ , lineno , scope = self .current_scope , show_error = False ):
@@ -634,7 +634,7 @@ def declare_const(self, id_, lineno, type_, default_value):
634634 entry .class_ = CLASS .const
635635 return entry
636636
637- def declare_label (self , id_ , lineno ):
637+ def declare_label (self , id_ : str , lineno : int ):
638638 """ Declares a label (line numbers are also labels).
639639 Unlike variables, labels are always global.
640640 """
@@ -685,7 +685,7 @@ def declare_label(self, id_, lineno):
685685 entry .type_ = self .basic_types [global_ .PTR_TYPE ]
686686 return entry
687687
688- def declare_param (self , id_ , lineno , type_ = None , is_array = False ):
688+ def declare_param (self , id_ : str , lineno : int , type_ = None , is_array = False ):
689689 """ Declares a parameter
690690 Check if entry.declared is False. Otherwise raises an error.
691691 """
@@ -708,7 +708,7 @@ def declare_param(self, id_, lineno, type_=None, is_array=False):
708708 warning_implicit_type (lineno , id_ , type_ )
709709 return entry
710710
711- def declare_array (self , id_ , lineno , type_ , bounds , default_value = None , addr = None ):
711+ def declare_array (self , id_ : str , lineno : int , type_ , bounds , default_value = None , addr = None ):
712712 """ Declares an array in the symbol table (VARARRAY). Error if already
713713 exists.
714714 The optional parameter addr specifies if the array elements must be placed at an specific
@@ -768,7 +768,7 @@ def declare_array(self, id_, lineno, type_, bounds, default_value=None, addr=Non
768768 self .current_scope ))
769769 return entry
770770
771- def declare_func (self , id_ , lineno , type_ = None ):
771+ def declare_func (self , id_ : str , lineno : int , type_ = None ):
772772 """ Declares a function in the current scope.
773773 Checks whether the id exist or not (error if exists).
774774 And creates the entry at the symbol table.
0 commit comments