Skip to content
Snippets Groups Projects
Commit 5eb5a56e authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Rename match_fit rule to match_operator rule for consistency with other types.

parent 41957b20
Branches
No related merge requests found
...@@ -898,7 +898,7 @@ position_first_token [const Corpus2::Tagset& tagset, Variables& vars] ...@@ -898,7 +898,7 @@ position_first_token [const Corpus2::Tagset& tagset, Variables& vars]
{ {
boost::shared_ptr<Function<Match> > m; boost::shared_ptr<Function<Match> > m;
} }
: "first" LPAREN m = match_fit [tagset, vars] RPAREN { : "first" LPAREN m = match_operator [tagset, vars] RPAREN {
ret.reset(new FirstToken(m)); ret.reset(new FirstToken(m));
} }
; ;
...@@ -911,7 +911,7 @@ position_last_token [const Corpus2::Tagset& tagset, Variables& vars] ...@@ -911,7 +911,7 @@ position_last_token [const Corpus2::Tagset& tagset, Variables& vars]
{ {
boost::shared_ptr<Function<Match> > m; boost::shared_ptr<Function<Match> > m;
} }
: "last" LPAREN m = match_fit [tagset, vars] RPAREN { : "last" LPAREN m = match_operator [tagset, vars] RPAREN {
ret.reset(new LastToken(m)); ret.reset(new LastToken(m));
} }
; ;
...@@ -1324,8 +1324,8 @@ bool_ann ...@@ -1324,8 +1324,8 @@ bool_ann
std::string chan_name; std::string chan_name;
} }
: "ann" LPAREN : "ann" LPAREN
match_from = match_fit [tagset, vars] COMMA match_from = match_operator [tagset, vars] COMMA
(match_to = match_fit [tagset, vars] COMMA)? (match_to = match_operator [tagset, vars] COMMA)?
name : STRING name : STRING
RPAREN { RPAREN {
if (match_to) { if (match_to) {
...@@ -1350,8 +1350,8 @@ bool_annsub ...@@ -1350,8 +1350,8 @@ bool_annsub
std::string chan_name; std::string chan_name;
} }
: "annsub" LPAREN : "annsub" LPAREN
match_from = match_fit [tagset, vars] COMMA match_from = match_operator [tagset, vars] COMMA
(match_to = match_fit [tagset, vars] COMMA)? (match_to = match_operator [tagset, vars] COMMA)?
name : STRING name : STRING
RPAREN RPAREN
{ {
...@@ -1402,7 +1402,7 @@ debug_print_operator ...@@ -1402,7 +1402,7 @@ debug_print_operator
) )
| |
( (
v = match_fit [tagset, vars] { v = match_operator [tagset, vars] {
ret.reset(new DebugPrint(v)); ret.reset(new DebugPrint(v));
} }
) )
...@@ -1687,7 +1687,7 @@ match_empty ...@@ -1687,7 +1687,7 @@ match_empty
{ {
boost::shared_ptr<Function<Match> > arg; boost::shared_ptr<Function<Match> > arg;
} }
: arg = match_fit [tagset, vars] { : arg = match_operator [tagset, vars] {
op.reset(new IsEmpty<Match>(arg)); op.reset(new IsEmpty<Match>(arg));
} }
; ;
...@@ -1720,6 +1720,46 @@ strset_empty ...@@ -1720,6 +1720,46 @@ strset_empty
} }
; ;
///////////////////////////////////////////////////////////////////////////////
// Match functional operators,
// which return boost::shared_ptr<Function<Match> >
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// A wrapper for match variable and match value.
match_var_val [const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Match> > ret]
: ret = match_vector_variable [vars]
| ret = match_value_const
;
///////////////////////////////////////////////////////////////////////////////
// Match operators.
// Returns boost::shared_ptr<Function<Match> >
///////////////////////////////////////////////////////////////////////////////
match_operator
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Match> > ret]
{
//
}
:
( ret = match_var_val [tagset, vars]
| {LA(1)==LITERAL_M || LA(1)==COLON}? ("M")? {
ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M")));
ret.reset(new Submatch(ret, 1));
}
| "MA" {
ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M")));
ret.reset(new Submatch(ret, 2));
}
| LPAREN ret = match_operator [tagset, vars] RPAREN
)
( // if there's an arrow after the match, we have a submatch reference
COLON i: UNSIGNED_INT { ret.reset(new Submatch(ret, token_ref_to_int(i))); }
)*
;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Tagging actions and rules: // Tagging actions and rules:
...@@ -2203,9 +2243,9 @@ match_mark_action ...@@ -2203,9 +2243,9 @@ match_mark_action
boost::shared_ptr<Function<Match> > head_match; boost::shared_ptr<Function<Match> > head_match;
} }
: "mark" LPAREN : "mark" LPAREN
match_from = match_fit[tagset, vars] COMMA match_from = match_operator[tagset, vars] COMMA
( match_to = match_fit[tagset, vars] COMMA ( match_to = match_operator[tagset, vars] COMMA
( head_match = match_fit[tagset, vars] COMMA )? ( head_match = match_operator[tagset, vars] COMMA )?
)? )?
annotation_name : STRING annotation_name : STRING
RPAREN { RPAREN {
...@@ -2242,7 +2282,7 @@ match_unmark_action ...@@ -2242,7 +2282,7 @@ match_unmark_action
boost::shared_ptr<Function<Match> > match_at; boost::shared_ptr<Function<Match> > match_at;
} }
: "unmark" LPAREN : "unmark" LPAREN
match_at = match_fit[tagset, vars] COMMA match_at = match_operator[tagset, vars] COMMA
annotation_name : STRING annotation_name : STRING
RPAREN { RPAREN {
m_act.reset( m_act.reset(
...@@ -2274,39 +2314,6 @@ match_action_comma_sep ...@@ -2274,39 +2314,6 @@ match_action_comma_sep
)* )*
; ;
// Function<Match> is wrapper for Constant<Match> and Function<Match>
// Returns boost::shared_ptr<Function<Match> >
match_fit
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Match> > ret]
{
//
}
:
( ret = match_var_val [tagset, vars]
| {LA(1)==LITERAL_M || LA(1)==COLON}? ("M")? {
ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M")));
ret.reset(new Submatch(ret, 1));
}
| "MA" {
ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M")));
ret.reset(new Submatch(ret, 2));
}
| LPAREN ret = match_fit [tagset, vars] RPAREN
)
( // if there's an arrow after the match, we have a submatch reference
COLON i: UNSIGNED_INT { ret.reset(new Submatch(ret, token_ref_to_int(i))); }
)*
;
match_var_val
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Match> > ret]
: ret = match_vector_variable [vars]
| ret = match_value_const
;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ANTLR LEXER // 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