/* progn.c - Control block.
 *  Copyright (C) 2022 by Jed Marti
 *   This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see https://www.gnu.org/licenses/.
 */


#include <C8051F380.h>
#include <stdint.h>

#include "lfxmit.h"
#include "storage.h"
#include "serial.h"

extern __xdata uint16_t PC;
extern __bit errorThrown;
extern __bit stopBit;

void runProgn(void)
{
  //  putstring("PROGN start at "); puthex16(PC); terpri();
 loop:
  incPC();

  if (getPByte() == RCBRACKET)
  {
    incPC();
    // putstring("  } at "); puthex16(PC); terpri();
    return;
  }

  // Ignore exctra semicolons.
  if (getPByte() == SEMICOLON) goto loop;

  runStatement();
  if (errorThrown || stopBit) return;
  goto loop;
}




// EOF
