code: def check_pending_labels(ast):
      
      result = True
      visited = set()
      pending = [ast]
  
      while pending:
          node = pending.pop()
  
          if node is None or node in visited:  # Avoid recursive infinite-loop
              continue
  
          visited.add(node)
          for x in node.children:
              pending.append(x)
  
          if node.token != 'VAR' or (node.token == 'VAR' and node.class_ is not CLASS.unknown):
              continue
  
          tmp = global_.SYMBOL_TABLE.get_entry(node.name)
          if tmp is None or tmp.class_ is CLASS.unknown:
              syntax_error(node.lineno, 'Undeclared identifier "%s"'
                           % node.name)
          else:
              assert tmp.class_ == CLASS.label
              node.to_label(node)
  
          result = result and tmp is not None
  
      return result
docs: Iteratively traverses the node looking for ID with no class set,
      marks them as labels, and check they've been declared.
  
      This way we avoid stack overflow for high line-numbered listings.