Skip to content
Snippets Groups Projects
Commit 6517316f authored by Adam Radziszewski's avatar Adam Radziszewski
Browse files

add parse file from path

parent bcf19f79
Branches
No related tags found
No related merge requests found
......@@ -615,4 +615,19 @@ boost::shared_ptr<WcclFile> Parser::parseWcclFile(std::istream& istr,
return res;
}
boost::shared_ptr<WcclFile> Parser::parseWcclFileFromPath(const std::string&
filename, const std::string& search_path /*= "."*/) const
{
std::ifstream is(filename.c_str());
if (!is.good()) {
throw Wccl::FileNotFound(filename, "", __FUNCTION__);
}
try {
return this->parseWcclFile(is, search_path);
}
catch (ParserException&) {
throw;
}
}
} // end Wccl ns
......@@ -5,7 +5,7 @@
// ----------------------------------------------------------------------------
#include <sstream>
#include <fstream>
// ----------------------------------------------------------------------------
#include <libcorpus2/tagset.h>
......@@ -93,13 +93,22 @@ public:
parseMatchRule(std::istream& is) const;
// ---------------------------------------------------------------------------
// WCCL file parsing
// Routines for parsing a whole WCCL file -- the RECOMMENDED way of parser
// usage. The standard whole file syntax is used (see WCCL language specs).
// This way different WCCL expressions (any-type functional operators as well
// as tag/match rules) may be parsed in a uniform fashion.
// This also allows to parse WCCL expressions that reference external
// resources (lexicon files). Those resources are sought in the given
// search_path.
boost::shared_ptr<WcclFile>
parseWcclFile(const std::string& file_contents_string,
const std::string& search_path = ".") const;
boost::shared_ptr<WcclFile>
parseWcclFile(std::istream& is,
const std::string& search_path = ".") const;
boost::shared_ptr<WcclFile>
parseWcclFileFromPath(const std::string& filename,
const std::string& search_path = ".") const;
// ---------------------------------------------------------------------------
const Corpus2::Tagset& tagset() const {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment