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

Values and variables for the MatchVector type

parent 17c65289
Branches
No related merge requests found
......@@ -67,6 +67,10 @@ header {
#include <libwccl/ops/tagactions/select.h>
#include <libwccl/ops/tagactions/relabel.h>
// Match operators
#include <libwccl/values/tokenmatch.h>
#include <libwccl/values/annotationmatch.h>
#include <libwccl/ops/match/applyoperator.h>
// Unicode String
#include <unicode/uniset.h>
......@@ -379,6 +383,67 @@ position_value
}
;
// ----------------------------------------------------------------------------
// Value used into match operator such as TOK[position] and ANN[position, name]
// Returns boost::shared_ptr<Match>
match_value
returns [boost::shared_ptr<Match> val]
: val = token_match_value
| val = ann_match_value
| val = match_vector_value
;
// token match value
// Returns boost::shared_ptr<TokenMatch>
token_match_value
returns [boost::shared_ptr<TokenMatch> val]
{
boost::shared_ptr<Position> p;
}
: "TOK"LBRACKET p = position_literal RBRACKET {
val.reset(new TokenMatch(*p));
}
;
// annotation match value
// Returns boost::shared_ptr<AnnotationMatch>
ann_match_value
returns [boost::shared_ptr<AnnotationMatch> val]
{
boost::shared_ptr<Position> p;
}
: "ANN" LBRACKET p = position_literal COMMA channel : STRING RBRACKET {
val.reset(new AnnotationMatch(*p, token_ref_to_std_string(channel)));
}
;
// annotation match vector: MATCH() or MATCH(token, ann, MATCH())
// Returns boost::shared_ptr<MatchVector>
match_vector_value
returns [boost::shared_ptr<MatchVector> val]
{
val.reset(new MatchVector());
}
: "MATCH" LPAREN (match_vector_value_item[val])? RPAREN
;
// Body of the MATCH value. It only adds vector items to the MatchVector
// Item may be single or multiple
match_vector_value_item [boost::shared_ptr<MatchVector>& mvector]
{
boost::shared_ptr<Match> m_val;
}
: m_val = match_value {
mvector->append(m_val);
}
(
COMMA
m_val = match_value {
mvector->append(m_val);
}
)*
;
// ----------------------------------------------------------------------------
// Number may be unsigned or signed: 1, +1, -1
number
......@@ -517,6 +582,36 @@ bool_variable
}
;
// ----------------------------------------------------------------------------
// Match: $m:name
// Get mach vector variable from variavles (before put into variables)
// Returns boost::shared_ptr<VariableAccessor<Match> >
match_vector_variable_acc
[Variables& vars]
returns [boost::shared_ptr<VariableAccessor<Match> > mvv_acc]
: MATCH_VECTOR_PREFIX n: SYMBOL {
vars.get_put<Match>(str_token_rem_grav(n));
VariableAccessor<Match> acc =
vars.create_accessor<Match>(str_token_rem_grav(n));
mvv_acc.reset(new VariableAccessor<Match>(acc));
}
;
// Vargetter for the match vector variavle. Wrapper for match_vector_variable_acc
// Returns boost::shared_ptr<VarGetter<Match> >
match_vector_variable
[Variables& vars]
returns [boost::shared_ptr<VarGetter<Match> > mvv]
{
boost::shared_ptr<VariableAccessor<Match> > mvv_acc;
}
: mvv_acc = match_vector_variable_acc [vars] {
mvv.reset(new VarGetter<Match>(*mvv_acc));
}
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// OPERATORS
......@@ -1678,6 +1773,13 @@ options {
: '$'
;
MATCH_VECTOR_PREFIX
options {
paraphrase = "Match vector prefix";
}
: "$m:"
;
LBRACKET
options {
paraphrase = "'['";
......
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