2013-11-03 03:49:42 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstdlib>
|
2013-11-03 18:25:33 +00:00
|
|
|
|
|
|
|
#ifdef LEAN_USE_LUA
|
|
|
|
#include <lua.hpp>
|
2013-11-03 21:46:15 +00:00
|
|
|
#include "util/exception.h"
|
2013-11-03 03:49:42 +00:00
|
|
|
#include "bindings/lua/name.h"
|
2013-11-03 20:02:57 +00:00
|
|
|
#include "bindings/lua/numerics.h"
|
2013-11-03 03:49:42 +00:00
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
int status, result;
|
|
|
|
lua_State *L;
|
|
|
|
|
|
|
|
L = luaL_newstate();
|
|
|
|
luaL_openlibs(L);
|
|
|
|
lean::init_name(L);
|
2013-11-03 20:02:57 +00:00
|
|
|
lean::init_mpz(L);
|
|
|
|
lean::init_mpq(L);
|
2013-11-03 03:49:42 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
status = luaL_loadfile(L, argv[i]);
|
|
|
|
if (status) {
|
|
|
|
std::cerr << "Couldn't load file: " << lua_tostring(L, -1) << "\n";
|
|
|
|
return 1;
|
|
|
|
}
|
2013-11-03 21:46:15 +00:00
|
|
|
try {
|
|
|
|
result = lua_pcall(L, 0, LUA_MULTRET, 0);
|
|
|
|
if (result) {
|
|
|
|
std::cerr << "Failed to run script: " << lua_tostring(L, -1) << "\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} catch (lean::exception & ex) {
|
|
|
|
std::cerr << "Lean exception when running: " << argv[i] << "\n";
|
|
|
|
std::cerr << ex.what() << "\n";
|
2013-11-03 03:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lua_close(L);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int main() {
|
|
|
|
std::cerr << "Lean was compiled without Lua support\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|