コード例 #1
0
ファイル: MiniSQL.cpp プロジェクト: hzfGuardian/MiniSQL
int main(int argc, const char* argv[])
{
	m1.Init();
	mybuffer.Init();
    Interpreter inter;
    
    inter.exec();

    return 0;
}
コード例 #2
0
ファイル: repl.cpp プロジェクト: rip-off/rasp-lang
void repl(Interpreter &interpreter, const Settings &settings)
{
	std::cout << "Enter some code, or type \'exit\' when finished:\n";
	std::string line;
	int count = 0;
	while((std::cout << " > ") && std::getline(std::cin, line) && !(line == "quit" || line == "exit"))
	{
		++count;
		try
		{
			Token token = lex("repl(" + str(count) + ")", line);
			Declarations declarations = interpreter.declarations();
			InstructionList instructions = parse(token, declarations, settings);
			if (!instructions.empty())
			{
				Value result = interpreter.exec(instructions);
				std::cout << " < " << result << std::endl;
			}
		}
		catch(const LexError &e)
		{
			std::cerr << "Lex error at " << e.sourceLocation() << " " << e.what() << '\n';
			printStackTrace(std::cerr, e);
		}
		catch(const ParseError &e)
		{
			std::cerr << "Parse error at " << e.sourceLocation() << " " << e.what() << '\n';
			printStackTrace(std::cerr, e);
		}
		catch(const ExecutionError &e)
		{
			std::cerr << "Execution error at " << e.sourceLocation() << " " << e.what() << '\n';
			printStackTrace(std::cerr, e);
		}
		catch(const RaspError &e)
		{
			std::cerr << "General error: " << e.what() << '\n';
			printStackTrace(std::cerr, e);
		}
		catch(const std::exception &error)
		{
			std::cerr << "Internal Error: " << error.what() << std::endl;
		}
	}
	// If you use CTRL-D, nice to output a newline...
	std::cout << '\n';
}