#include <msp/datafile/parser.h>
#include <msp/datafile/statement.h>
#include <msp/datafile/writer.h>
+#include "compiler.h"
#include "tool.h"
using namespace std;
DataTool::DataTool(int argc, char **argv):
in_fn("-"),
- out_fn("-")
+ out_fn("-"),
+ binary(false),
+ compile(false)
{
GetOpt getopt;
- getopt.add_option('o', "output", out_fn, GetOpt::REQUIRED_ARG);
getopt.add_option('b', "binary", binary, GetOpt::NO_ARG);
+ getopt.add_option('c', "compile", compile, GetOpt::NO_ARG);
+ getopt.add_option('o', "output", out_fn, GetOpt::REQUIRED_ARG);
getopt(argc, argv);
const vector<string> &args=getopt.get_args();
if(binary)
writer.set_binary(true);
- while(parser)
+ if(compile)
+ {
+ Compiler compiler(writer);
+ compiler.load(parser);
+ }
+ else
{
- DataFile::Statement st=parser.parse();
- if(st.valid)
+ while(parser)
{
- writer.write(st);
- out_buf.flush();
+ DataFile::Statement st=parser.parse();
+ if(st.valid)
+ {
+ writer.write(st);
+ out_buf.flush();
+ }
}
}
}