Skip to content
Snippets Groups Projects
Commit 0b8578f7 authored by ilor's avatar ilor
Browse files

add -f - featur to wcclparser to parse a mulitline query from stdin

parent 8ed162cd
Branches
No related merge requests found
......@@ -185,7 +185,7 @@ int main(int argc, char** argv)
("position,p", value(&position),
"Position in the sentence to use, 'all' iterates through the sentence\n")
("query-file,f", value(&query_load),
"Run query from file (disables interactive mode)\n")
"Run query from file (disables interohaiactive mode) (- is stdin)\n")
("query,Q", value(&query),
"Query to run (disables interactive mode)\n")
("quiet,q", value(&quiet)->zero_tokens(),
......@@ -237,15 +237,19 @@ int main(int argc, char** argv)
process_line(query, parser, sc, position == "all", dump_variables);
return 0;
} else if (!query_load.empty()) {
std::ifstream qf(query_load.c_str());
if (qf.good()) {
std::stringstream ss;
ss << qf.rdbuf();
process_line(ss.str(), parser, sc, position == "all", dump_variables);
return 0;
std::stringstream ss;
if (query_load == "-") {
ss << std::cin.rdbuf();
} else {
throw Wccl::FileNotFound(sentence_load, "", "Query file");
std::ifstream qf(query_load.c_str());
if (qf.good()) {
ss << qf.rdbuf();
} else {
throw Wccl::FileNotFound(sentence_load, "", "Query file");
}
}
process_line(ss.str(), parser, sc, position == "all", dump_variables);
return 0;
}
boost::function<bool (const std::string&)> f;
f = boost::bind(&process_line, _1, boost::ref(parser), boost::ref(sc),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment