void InputConverterOPEquilibria::convert(std::istream& i, std::ostream& o)
{
  InputParser p;
  p.parse(i, pcd.mcs());
  
  writeProgram(o, pcd.mcs());
}
예제 #2
0
파일: Shell.cpp 프로젝트: kanbang/Colt
bool Shell::mainLoop(std::istream &in, Environment &env) const
{
	InputParser iParser;
	ShellCommand::Args args;
	
	const Shell *oldShell = env.shell();
	env.shell() = this;
	
	bool success = true;
	do {
		if(env.interactive()) cout << endl << "dbxml> ";
		env.lineNo() += iParser.parse(in, args);
		string command = args.empty() ? string("") : args.front();
		try {
			ShellCommand *cmd = findCommand(command);
			if (cmd)
				cmd->execute(args, env);
			else if(!args.empty()) {
				throw CommandException("Unknown command");
			}
		}
		//catches XmlException
		catch(exception &e) {
			cerr << env.streamName() << ":" << env.lineNo() <<
				": " << command << " failed, ";
			cerr << e.what() << endl;
			success = false;
			if(!env.interactive() && !env.ignoreErrors())
				env.quit() = true;
		}
		catch(...) {
			cerr << env.streamName() << ":" << env.lineNo() <<
				": " << command << " failed" << endl;
			success = false;
			if(!env.interactive() && !env.ignoreErrors())
				env.quit() = true;
		}
	} while(!env.quit() && !in.eof() && !env.sigBlock().isInterrupted());
	
	env.shell() = oldShell;
	return success;
}