Ejemplo n.º 1
0
void		Chipset::parse_debug()
{
  char buffer[BUFF_SIZE];
  int exited = 0;
  size_t line = 0;
  while (_is->getline(buffer, BUFF_SIZE)) {
    line++;
    if (_is == &std::cin && std::string(buffer).find(";;") == 0)
      break;
    try {
      exited |= executeLine(buffer);
    }
    catch (VMException &e) {
      e.setLine(line);
      e.setFile(_filename);
      std::cout << e.what() << std::endl;
    }
  }
  try {
    if (!exited)
      throw NoExitException("Missing exit instruction");
  }
  catch (VMException &e) {
    e.setFile(_filename);
    std::cout << e.what() << std::endl;
  }
}
Ejemplo n.º 2
0
void InstructionStack::process(void)
{
	for (auto & instruction : m_instructions)
	{
		instruction->m_function();
		if (m_exitProperly)
			break;
	}
	if (!m_exitProperly)
		throw NoExitException();
}
Ejemplo n.º 3
0
void		Chipset::parse()
{
  char buffer[BUFF_SIZE];
  int exited = 0;
  size_t line = 0;
  std::vector<std::string> exceptions;
  std::vector<std::string> lines;
  while (_is->getline(buffer, BUFF_SIZE)) {
    line++;
    lines.push_back(buffer);
    if (_is == &std::cin && std::string(buffer).find(";;") == 0)
      break;
    try {
      exited |= executeLine(buffer, true);
    }
    catch (VMException &e) {
      e.setLine(line);
      e.setFile(_filename);
      exceptions.push_back(e.what());
    }
  }
  try {
    if (!exited)
      throw NoExitException("Missing exit instruction");
  }
  catch (VMException &e) {
    e.setFile(_filename);
    exceptions.push_back(e.what());
  }

  std::vector<std::string>::iterator it;
  std::vector<std::string>::iterator itend;
  if (not exceptions.empty()) {
      it = exceptions.begin();
      itend = exceptions.end();
      for (; it != itend; it++)
	std::cerr << std::string(*it) << std::endl;
    }
  else {
      it = lines.begin();
      itend = lines.end();
      for (; it != itend; it++)
	executeLine((*it));
    }
}