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
No related merge requests found
...@@ -185,7 +185,7 @@ int main(int argc, char** argv) ...@@ -185,7 +185,7 @@ int main(int argc, char** argv)
("position,p", value(&position), ("position,p", value(&position),
"Position in the sentence to use, 'all' iterates through the sentence\n") "Position in the sentence to use, 'all' iterates through the sentence\n")
("query-file,f", value(&query_load), ("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,Q", value(&query),
"Query to run (disables interactive mode)\n") "Query to run (disables interactive mode)\n")
("quiet,q", value(&quiet)->zero_tokens(), ("quiet,q", value(&quiet)->zero_tokens(),
...@@ -237,15 +237,19 @@ int main(int argc, char** argv) ...@@ -237,15 +237,19 @@ int main(int argc, char** argv)
process_line(query, parser, sc, position == "all", dump_variables); process_line(query, parser, sc, position == "all", dump_variables);
return 0; return 0;
} else if (!query_load.empty()) { } else if (!query_load.empty()) {
std::ifstream qf(query_load.c_str()); std::stringstream ss;
if (qf.good()) { if (query_load == "-") {
std::stringstream ss; ss << std::cin.rdbuf();
ss << qf.rdbuf();
process_line(ss.str(), parser, sc, position == "all", dump_variables);
return 0;
} else { } 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; boost::function<bool (const std::string&)> f;
f = boost::bind(&process_line, _1, boost::ref(parser), boost::ref(sc), 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