Newer
Older
//don't try to add all the headers inside our namespace
#include <libwccl/parser/ParserException.h>
#include <cstdio>
#include <antlr/Token.hpp>
#include <boost/lexical_cast.hpp>
// values/variables
#include <libwccl/variables.h>
#include <libwccl/values/bool.h>
#include <libwccl/values/tset.h>
#include <libwccl/values/strset.h>
#include <libwccl/values/position.h>
// sentence context
#include <libwccl/sentencecontext.h>
// operators
#include <libwccl/ops/operator.h>
#include <libwccl/ops/functions/constant.h>
#include <libwccl/ops/functions/vargetter.h>
#include <libwccl/ops/functions/conditional.h>
#include <libwccl/ops/functions/bool/varsetter.h>
#include <libwccl/ops/functions/bool/predicates/or.h>
#include <libwccl/ops/functions/bool/predicates/nor.h>
#include <libwccl/ops/functions/bool/predicates/and.h>
#include <libwccl/ops/functions/bool/predicates/regex.h>
#include <libwccl/ops/functions/bool/predicates/intersects.h>
#include <libwccl/ops/functions/bool/predicates/issubsetof.h>
#include <libwccl/ops/functions/bool/predicates/isinside.h>
#include <libwccl/ops/functions/bool/predicates/isoutside.h>
#include <libwccl/ops/functions/bool/predicates/equals.h>
#include <libwccl/ops/functions/bool/predicates/weakagreement.h>
#include <libwccl/ops/functions/bool/predicates/pointagreement.h>
#include <libwccl/ops/functions/bool/predicates/strongagreement.h>
#include <libwccl/ops/functions/strset/affix.h>
#include <libwccl/ops/functions/strset/getorth.h>
#include <libwccl/ops/functions/strset/toupper.h>
#include <libwccl/ops/functions/strset/tolower.h>
#include <libwccl/ops/functions/strset/getlemmas.h>
#include <libwccl/ops/functions/tset/getsymbols.h>
#include <libwccl/ops/functions/tset/getwordclass.h>
#include <libwccl/ops/functions/tset/getsymbolsinrange.h>
#include <libwccl/ops/functions/position/relativeposition.h>
#include <libwccl/ops/functions/bool/iterations/only.h>
#include <libwccl/ops/functions/bool/iterations/atleast.h>
#include <libwccl/ops/functions/bool/iterations/leftlook.h>
#include <libwccl/ops/functions/bool/iterations/rightlook.h>
#include <libwccl/ops/rulesequence.h>
//
#include <libwccl/ops/tagactions/unify.h>
#include <libwccl/ops/tagactions/delete.h>
#include <libwccl/ops/tagactions/select.h>
#include <libwccl/ops/tagactions/relabel.h>
// Unicode String
#include <unicode/uniset.h>
#include <unicode/unistr.h>
ANTLR_BEGIN_NAMESPACE(Wccl)
Paweł Kędzia
committed
genHashLines = false;
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
Paweł Kędzia
committed
exportVocab = ANTLRExpr;
const UnicodeString token_ref_to_ustring(antlr::RefToken& rstr) const {
return UnicodeString::fromUTF8(((antlr::Token*)rstr)->getText()).unescape();
}
Paweł Kędzia
committed
const UnicodeString str_token_ref_to_ustring(antlr::RefToken& rstr) const {
UnicodeString ret_ustr, ustr = token_ref_to_ustring(rstr);
if (ustr.length() < 3) {
return "";
}
ustr.extract(1, ustr.length() - 2, ret_ustr);
return ret_ustr;
}
Paweł Kędzia
committed
//
const std::string str_token_rem_grav(antlr::RefToken& rstr) const {
size_t len = 0;
std::string ret = token_ref_to_std_string(rstr);
if ((len = ret.length()) < 2) {
return ret;
}
if (ret[0] == '`' && ret[len - 1] == '`') {
return ret.substr(1, len - 2);
}
return ret;
}
//
const std::string token_ref_to_std_string(antlr::RefToken& rstr) const {
return (((antlr::Token*)rstr)->getText());
//
int token_ref_to_int(antlr::RefToken& rstr) {
return atoi(((antlr::Token*)rstr)->getText().c_str());
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// Rule for parsing string set operator with scope.
// Returns boost::shared_ptr<Operator<StrSet> >
parse_strset_operator
Paweł Kędzia
committed
[const Corpus2::Tagset &tagset]
returns [boost::shared_ptr<Operator<StrSet> > res]
Variables vars;
boost::shared_ptr<Function<StrSet> > body;
: body = strset_operator [tagset, vars] {
res.reset(new Operator<StrSet>(body, vars));
// ----------------------------------------------------------------------------
// Rule for parsing bool operator with scope.
// Returns boost::shared_ptr<Operator<Bool> >
parse_bool_operator
Paweł Kędzia
committed
[const Corpus2::Tagset &tagset]
returns [boost::shared_ptr<Operator<Bool> > res]
Variables vars;
boost::shared_ptr<Function<Bool> > body;
: body = bool_operator [tagset, vars] {
res.reset(new Operator<Bool>(body, vars));
// ----------------------------------------------------------------------------
// Rule for parsing symbol set operator with scope.
// Returns boost::shared_ptr<Operator<TSet> >
parse_symset_operator
Paweł Kędzia
committed
[const Corpus2::Tagset &tagset]
returns [boost::shared_ptr<Operator<TSet> > res]
Variables vars;
boost::shared_ptr<Function<TSet> > body;
: body = symset_operator [tagset, vars] {
res.reset(new Operator<TSet>(body, vars));
// ----------------------------------------------------------------------------
// Rule for parsing position operator with scope.
// Returns boost::shared_ptr<Operator<Position> >
parse_position_operator
returns [boost::shared_ptr<Operator<Position> > res]
Loading full blame...