2010-06-27 12:29:08 +00:00
|
|
|
// Stand-alone MW-script compiler
|
|
|
|
|
2010-06-27 17:20:21 +00:00
|
|
|
#include <exception>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
2010-06-27 12:29:08 +00:00
|
|
|
|
2010-06-27 17:20:21 +00:00
|
|
|
#include <components/compiler/streamerrorhandler.hpp>
|
|
|
|
#include <components/compiler/scanner.hpp>
|
|
|
|
#include <components/compiler/fileparser.hpp>
|
|
|
|
#include <components/compiler/context.hpp>
|
2010-06-27 12:29:08 +00:00
|
|
|
|
2010-06-27 17:20:21 +00:00
|
|
|
int main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Compiler::Context context;
|
|
|
|
Compiler::StreamErrorHandler errorHandler (std::cout);
|
|
|
|
Compiler::FileParser parser (errorHandler, context);
|
|
|
|
|
2010-06-27 22:21:45 +00:00
|
|
|
std::ifstream file (argc>1 ? argv[1] : "test.mwscript");
|
2010-06-27 17:20:21 +00:00
|
|
|
Compiler::Scanner scanner (errorHandler, file);
|
|
|
|
|
|
|
|
scanner.scan (parser);
|
|
|
|
}
|
|
|
|
catch (const std::exception &e)
|
|
|
|
{
|
|
|
|
std::cout << "\nERROR: " << e.what() << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
2010-06-27 12:29:08 +00:00
|
|
|
}
|
|
|
|
|