# The lazyNut processing cycles

## Main loop

The main loop just gets lines from the files/std::cin and sends them to the object manager to be dealt with.

pseudocode:

    int main(argv,argc)
    {
      om=object_manager::instance();

      for (file in {argv[1], ..., argv[argc-1], std::cin})
      {
        while (read line from file)
        {
           om->dispatch(line);
        }
      }
    }

## Dispatch

The object manager can be asked to dispatch not only by the main loop, which generates BEGIN:/END: pairs, but also by keywords and object methods, which generate BEGIN(n):/END(n) pairs; the n is shown when the object_manager's nesting variable is non-zero.

pseudocode:

    object_handle object_manager::dispatch(line)
    {
      if(nesting==0) bailout=false;
      if(bailout) return 0;
      nesting++;
      cout<<BEGIN_string();
      stack_up();
      line>>object;
      if(object in keywords) { do_keyword(object,line); return 0; }
      if(object in objects) { return do_method(object,line); }

      stack_down();
      if(Rbuffer.size()>0)
      {
        cout<<Rbuffer;
        Rbuffer.clear();
      }
      if(OOB would_not_block)
      {
        OOB>>oobline;
        if(oobline=="stop")
        {
          cout<<"OOB stop heeded.\n";
          bailout=true;
        }
      }
      cout<<END_string();
      nesting--;
    }

## ERRORS

When an ERROR string is sent, this automatically sets the bailout flag.

## Include and OOB stop

The include keyword simply opens the specified file, and sends its lines through object_manager::dispatch(). Since at the point a keyword is processed, nesting is greater than 0, lines read after an OOB stop will fail to get through the bailout test (but lazyNut will suprisingly enough still reads every line of the file, it just declines to execute them).

## Model stage and OOB

Model stage's primary operation is to generate a series of include commands. Since inside the stage method, nesting must already be greater than 0, an OOB stop will both halt the current include and stop future includes from starting.