Skip to content
Snippets Groups Projects
Commit f5bf93e5 authored by Paweł Kędzia's avatar Paweł Kędzia
Browse files

Added match conditions and match operator

parent 6f4e5b27
Branches
No related merge requests found
......@@ -72,6 +72,9 @@ header {
#include <libwccl/values/annotationmatch.h>
#include <libwccl/values/matchvector.h>
#include <libwccl/ops/match/applyoperator.h>
#include <libwccl/ops/match/conditions/optionalmatch.h>
#include <libwccl/ops/match/conditions/repeatedmatch.h>
#include <libwccl/ops/match/conditions/conjconditions.h>
// Unicode String
#include <unicode/uniset.h>
......@@ -236,6 +239,22 @@ parse_rule_sequence
: rule_seq = rules[tagset, vars]
;
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Rule for parsing the match rules
// Returns ????
parse_match_rule
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<Expression> ret_match]
{
Variables vars;
// TODO Dodac do vars pozycje $_ oraz wektor $m_M
// TODO
fprintf(stderr, "TODO: parse_match_rule -> return type\n");
}
: ret_match = match_rule_operator[tagset, vars]
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// VALUES
......@@ -1680,6 +1699,120 @@ action_unify
}
;
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Match rules
// Returns boost::shared_ptr<Expression>
match_rule_operator
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Expression> ret_op]
{
//
}
: ret_op = match_operator [tagset, vars]
;
// Match apply operator:
// apply(match(), conditions, actions)
// apply(match(), actions)
// Returns boost::shared_ptr<ApplyOperator>
match_apply_operator
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<ApplyOperator> ret_op]
{
// VariableAccessor<Match> matches;
// VariableAccessor<Position> cur_iter_pos;
// boost::shared_ptr<const MatchOperator> match_op;
// std::vector<boost::shared_ptr<const MatchAction> > actions;
// std::vector<boost::shared_ptr<const Function<Bool> > > conditions;
// TODO
}
: "apply" LPAREN RPAREN {
// TODO
}
;
// Match operator: match(match_conditions)
// Returns boost::shared_ptr<MatchOperator>
match_operator
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<MatchOperator> op]
{
boost::shared_ptr<ConjConditions> match_cond;
}
: "match" LPAREN match_cond = match_condition [tagset,vars] RPAREN {
op.reset(new MatchOperator(match_cond));
}
;
// Match conditions. Wrapper for vector of the match conditions
match_condition
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<ConjConditions> condition]
{
std::vector<boost::shared_ptr<const MatchCondition> > m_cond;
}
: m_cond = match_condition_in [tagset, vars] {
condition.reset(new ConjConditions(m_cond));
}
;
// Match conditions.
// Retutns std::vector< boost::shared_ptr<const MatchCondition> >
match_condition_in
[const Corpus2::Tagset& tagset, Variables& vars]
returns [std::vector< boost::shared_ptr<const MatchCondition> > ret]
{
boost::shared_ptr<const MatchCondition> r_cond;
}
: r_cond = match_cond_all[tagset, vars] {
ret.push_back(r_cond);
}
(
COMMA
r_cond = match_cond_all[tagset, vars] {
ret.push_back(r_cond);
}
)*
;
// One of the match condition
// Returns boost::shared_ptr<const MatchCondition>
match_cond_all
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<const MatchCondition> ret]
: ret = match_cond_optional [tagset, vars]
| ret = match_cond_repeate [tagset, vars]
;
// Match condition - optional
// Returns boost::shared_ptr<OptionalMatch>
match_cond_optional
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<OptionalMatch> mtch]
{
boost::shared_ptr<ConjConditions> m_cond;
}
: "optional" LPAREN m_cond = match_condition [tagset, vars] RPAREN {
mtch.reset(new OptionalMatch(m_cond));
}
;
// Match condition - repleace
// Returns boost::shared_ptr<OptionalMatch>
match_cond_repeate
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<OptionalMatch> mtch]
{
boost::shared_ptr<ConjConditions> m_cond;
}
: "repeate" LPAREN m_cond = match_condition [tagset, vars] RPAREN {
mtch.reset(new OptionalMatch(m_cond));
}
;
// ----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// ANTLR LEXER
......
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