X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=tool%2Ftool.cpp;h=36ee5c4abd6e760162934417a8d8ae4b1f355333;hb=52e6bd3e02522f68166c70f83d2ef3d7cf0c15ff;hp=ca415d30a0d9dc7d996d84b62021be90bc054f9e;hpb=db9c49893c2a9475cb5efa4a53bc481a5f66231f;p=libs%2Fdatafile.git diff --git a/tool/tool.cpp b/tool/tool.cpp index ca415d3..36ee5c4 100644 --- a/tool/tool.cpp +++ b/tool/tool.cpp @@ -12,6 +12,7 @@ Distributed under the LGPL #include #include #include +#include "compiler.h" #include "tool.h" using namespace std; @@ -19,11 +20,14 @@ using namespace Msp; 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 &args=getopt.get_args(); @@ -53,13 +57,21 @@ int DataTool::main() 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(); + } } } }