def visitNext(self, next_stmt):
     logging.debug("NEXT statement = %s", next_stmt)
     #logging.debug("NEXT identifiers = %s", next_stmt.identifiers[0].identifier)
     while True:
         if len(self.loops) == 0:
             errors.fatalError("Not in a FOR loop at line %d." % next_stmt.lineNum)
         peek = self.loops[-1]
         if not isinstance(peek, ForToStep):
             errors.fatalError("Not in a FOR loop at line %d; currently in %s loop opened at line %d" % (next_stmt.lineNum, peek.description, peek.lineNum))
         
         for_stmt = self.loops.pop()
         # If the next_stmt has no attached identifiers, it applies to the
         # top FOR statement on the stack
         if len(next_stmt.identifiers) == 0:
              next_stmt.identifiers.append(for_stmt.identifier)
         id1 = for_stmt.identifier.identifier
         print next_stmt.identifiers
         id2 = next_stmt.identifiers[0].identifier
         print "self.loops = ", self.loops
         print "id1 = ", id1
         print "id2 = ", id2
         # TODO: Check that the symbols are equal, not just the names
         if for_stmt.identifier.identifier == next_stmt.identifiers[0].identifier:
             connectLoop(next_stmt, for_stmt)
             break    
 def visitEndwhile(self, endwhile_stmt):
     if len(self.loops) == 0:
         errors.fatalError("Not in a WHILE loop at line %d." % endwhile_stmt.lineNum)
     peek = self.loops[-1]
     if not isinstance(peek, While):
         errors.fatalError("Not in a WHILE loop at line %d; currently in %s loop opened at line %d" % (endwhile_stmt.lineNum, peek.description, peek.lineNum))
     while_stmt = self.loops.pop()
     connectLoop(endwhile_stmt, while_stmt)
 def visitUntil(self, until_stmt):
     if len(self.loops) == 0:
         errors.fatalError("Not in a REPEAT loop at line %d." % until_stmt.lineNum)
     peek = self.loops[-1]
     if not isinstance(peek, Repeat):
         errors.fatalError("Not in a REPEAT loop at line %d; currently in %s loop opened at line %d" % (until_stmt.lineNum, peek.description, peek.lineNum))
     repeat_stmt = self.loops.pop()
     connectLoop(until_stmt, repeat_stmt)