2013-09-13 03:04:10 +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
|
|
|
|
*/
|
2013-07-17 05:10:18 +00:00
|
|
|
#include <iostream>
|
2013-08-18 23:23:29 +00:00
|
|
|
#include <fstream>
|
2013-08-24 23:11:35 +00:00
|
|
|
#include <signal.h>
|
2013-11-13 05:42:22 +00:00
|
|
|
#include "util/interrupt.h"
|
2013-10-01 01:16:13 +00:00
|
|
|
#include "kernel/printer.h"
|
2013-09-13 03:09:35 +00:00
|
|
|
#include "frontends/lean/parser.h"
|
2013-11-07 21:56:04 +00:00
|
|
|
#include "bindings/lua/leanlua_state.h"
|
2013-07-17 05:10:18 +00:00
|
|
|
#include "version.h"
|
2013-09-13 23:14:24 +00:00
|
|
|
|
|
|
|
using lean::shell;
|
|
|
|
using lean::frontend;
|
|
|
|
using lean::parser;
|
2013-11-07 21:56:04 +00:00
|
|
|
using lean::leanlua_state;
|
2013-07-17 21:24:35 +00:00
|
|
|
|
2013-09-20 04:26:01 +00:00
|
|
|
static void on_ctrl_c(int ) {
|
2013-11-13 05:42:22 +00:00
|
|
|
lean::request_interrupt();
|
2013-08-24 23:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool lean_shell() {
|
2013-07-17 05:10:18 +00:00
|
|
|
std::cout << "Lean (version " << LEAN_VERSION_MAJOR << "." << LEAN_VERSION_MINOR << ")\n";
|
2013-08-21 23:43:59 +00:00
|
|
|
std::cout << "Type Ctrl-D to exit or 'Help.' for help."<< std::endl;
|
2013-08-18 17:37:00 +00:00
|
|
|
frontend f;
|
2013-11-07 21:56:04 +00:00
|
|
|
leanlua_state S;
|
|
|
|
shell sh(f, &S);
|
2013-08-24 23:11:35 +00:00
|
|
|
signal(SIGINT, on_ctrl_c);
|
2013-08-25 17:34:19 +00:00
|
|
|
return sh();
|
2013-08-24 23:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
2013-08-18 23:23:29 +00:00
|
|
|
if (argc == 1) {
|
2013-08-24 23:11:35 +00:00
|
|
|
return lean_shell() ? 0 : 1;
|
2013-08-18 23:23:29 +00:00
|
|
|
} else {
|
|
|
|
bool ok = true;
|
2013-08-24 23:11:35 +00:00
|
|
|
frontend f;
|
2013-11-07 21:56:04 +00:00
|
|
|
leanlua_state S;
|
2013-08-18 23:23:29 +00:00
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
std::ifstream in(argv[i]);
|
2013-11-07 21:56:04 +00:00
|
|
|
parser p(f, in, &S, false, false);
|
2013-08-25 17:34:19 +00:00
|
|
|
if (!p())
|
2013-08-18 23:23:29 +00:00
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
return ok ? 0 : 1;
|
|
|
|
}
|
2013-07-17 05:10:18 +00:00
|
|
|
}
|