Newer
Older
*/
//----------------------------------------------------------------------------
// match empty() operator
// Returns boost::shared_ptr<Function<Bool> >
match_empty
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr<Function<Match> > arg;
}
: arg = match_operator [scope] {
op.reset(new IsEmpty<Match>(arg));
}
;
//----------------------------------------------------------------------------
// SymSet empty() operator
// Returns boost::shared_ptr<Function<Bool> >
symset_empty
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr<Function<TSet> > arg;
}
: arg = symset_operator [scope] {
op.reset(new IsEmpty<TSet>(arg));
}
;
//----------------------------------------------------------------------------
// Strset empty() operator
ilor
committed
// Returns boost::shared_ptr<Function<Bool> >
strset_empty
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr<Function<StrSet> > arg;
}
: arg = strset_operator [scope] {
op.reset(new IsEmpty<StrSet>(arg));
}
;
Adam Wardynski
committed
///////////////////////////////////////////////////////////////////////////////
// Match functional operators,
// which return boost::shared_ptr<Function<Match> >
///////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------
// A wrapper for match variable and match value.
match_var_val [ParsingScope& scope]
Adam Wardynski
committed
returns [boost::shared_ptr<Function<Match> > ret]
: ret = match_vector_variable [scope.variables()]
Adam Wardynski
committed
| ret = match_value_const
;
///////////////////////////////////////////////////////////////////////////////
// Match operators.
// Returns boost::shared_ptr<Function<Match> >
///////////////////////////////////////////////////////////////////////////////
match_operator
Adam Wardynski
committed
returns [boost::shared_ptr<Function<Match> > ret]
{
//
}
:
( ret = match_var_val [scope]
Adam Wardynski
committed
| {LA(1)==LITERAL_M || LA(1)==COLON}? ("M")? {
ret.reset(new VarGetter<Match>(scope.variables().create_accessor<Match>("_M")));
Adam Wardynski
committed
ret.reset(new Submatch(ret, 1));
}
| "MA" {
ret.reset(new VarGetter<Match>(scope.variables().create_accessor<Match>("_M")));
Adam Wardynski
committed
ret.reset(new Submatch(ret, 2));
}
| LPAREN ret = match_operator [scope] RPAREN
Adam Wardynski
committed
)
( // if there's a colon after the match, we have a submatch reference
Adam Wardynski
committed
COLON i: UNSIGNED_INT { ret.reset(new Submatch(ret, token_ref_to_int(i))); }
)*
;
// ----------------------------------------------------------------------------
// Wrapper from Function<Match> to Operator<Match>
functional_operator_match
[ParsingScope& scope]
returns [boost::shared_ptr<Operator<Match> > op]
{
boost::shared_ptr<Function<Match> > body;
}
: body = match_operator [scope] {
op.reset(new Operator<Match>(body, scope.variables()));
}
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// WCCL FILE PARSING RULES
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
imports_section [WcclFile& wccl_file]
: (import [wccl_file])+
;
import [WcclFile& wccl_file]
: "import" LPAREN file_path : STRING COMMA lexicon_name : STRING RPAREN {
wccl_file.import_lexicon(
LexiconParser::parse_lexicon(
wccl_file.path(),
token_ref_to_std_string(lexicon_name),
token_ref_to_std_string(file_path)));
}
;
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
wccl_file_section [WcclFile& wccl_file]
: any_operator_section [wccl_file]
| tag_rules_section [wccl_file]
| match_rules_section [wccl_file]
;
tag_rules_section [WcclFile& wccl_file]
{
boost::shared_ptr<TagRuleSequence> rule_seq;
}
: rule_seq = parse_tag_rule_sequence [wccl_file.tagset()] {
if (wccl_file.has_tag_rules()) {
throw ParserException("Only one tag_rules section allowed in a WCCL file.");
}
wccl_file.set_tag_rules(rule_seq);
}
;
match_rules_section [WcclFile& wccl_file]
{
ParsingScope scope(wccl_file);
ilor
committed
boost::shared_ptr<Matching::MatchRule> match_rule;
boost::shared_ptr<Matching::MatchRuleSequence> rule_seq = boost::make_shared<Matching::MatchRuleSequence>();
}
: "match_rules" {
if (wccl_file.has_match_rules()) {
throw ParserException("Only one match_rules section allowed in a WCCL file.");
}
}
LPAREN
match_rule = match_rule_operator [scope] {
rule_seq->push_back(*match_rule);
scope.reset_variables();
}
(
SEMI match_rule = match_rule_operator [scope] {
rule_seq->push_back(*match_rule);
)*
RPAREN { wccl_file.set_match_rules(rule_seq); }
any_operator_section
[WcclFile& wccl_file]
{
boost::shared_ptr<UntypedOpSequence> untyped_seq;
boost::shared_ptr<OpSequence<Bool> > bool_seq;
boost::shared_ptr<OpSequence<TSet> > symset_seq;
boost::shared_ptr<OpSequence<StrSet> > strset_seq;
boost::shared_ptr<OpSequence<Position> > pos_seq;
boost::shared_ptr<OpSequence<Match> > m_seq;
}
: untyped_seq = untyped_operator_sequence [wccl_file] {
| bool_seq = bool_operator_sequence [wccl_file] {
| symset_seq = symset_operator_sequence [wccl_file] {
| strset_seq = strset_operator_sequence [wccl_file] {
| pos_seq = position_operator_sequence [wccl_file] {
| m_seq = match_operator_sequence [wccl_file] {
wccl_file.add_section(m_seq);
}
;
bool_operator_sequence
[const WcclFile& wccl_file]
returns [boost::shared_ptr<OpSequence<Bool> > seq]
{
ParsingScope scope(wccl_file);
boost::shared_ptr<Operator<Bool> > op;
}
: BOOL_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<Bool>(token_ref_to_std_string(name)));
}
LPAREN
op = functional_operator_bool [scope] { seq->append(op); scope.reset_variables(); }
(SEMI op = functional_operator_bool [scope] { seq->append(op); scope.reset_variables(); })*
[const WcclFile& wccl_file]
returns [boost::shared_ptr<OpSequence<TSet> > seq]
{
ParsingScope scope(wccl_file);
boost::shared_ptr<Operator<TSet> > op;
}
: TST_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<TSet>(token_ref_to_std_string(name)));
}
LPAREN
op = functional_operator_symset [scope] { seq->append(op); scope.reset_variables(); }
(SEMI op = functional_operator_symset [scope] { seq->append(op); scope.reset_variables(); })*
[const WcclFile& wccl_file]
returns [boost::shared_ptr<OpSequence<StrSet> > seq]
{
ParsingScope scope(wccl_file);
boost::shared_ptr<Operator<StrSet> > op;
}
: STR_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<StrSet>(token_ref_to_std_string(name)));
}
LPAREN
op = functional_operator_strset [scope] { seq->append(op); scope.reset_variables(); }
(SEMI op = functional_operator_strset [scope] { seq->append(op); scope.reset_variables(); })*
[const WcclFile& wccl_file]
returns [boost::shared_ptr<OpSequence<Position> > seq]
{
ParsingScope scope(wccl_file);
boost::shared_ptr<Operator<Position> > op;
}
: POS_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<Position>(token_ref_to_std_string(name)));
}
LPAREN
op = functional_operator_position [scope] { seq->append(op); scope.reset_variables(); }
(SEMI op = functional_operator_position [scope] { seq->append(op); scope.reset_variables(); })*
[const WcclFile& wccl_file]
returns [boost::shared_ptr<UntypedOpSequence> seq]
{
ParsingScope scope(wccl_file);
boost::shared_ptr<FunctionalOperator> op;
}
: AT_MARK name: STRING {
seq.reset(new UntypedOpSequence(token_ref_to_std_string(name)));
}
LPAREN
op = functional_operator_any [scope] { seq->append(op); scope.reset_variables(); }
(SEMI op = functional_operator_any [scope] { seq->append(op); scope.reset_variables(); })*
[const WcclFile& wccl_file]
returns [boost::shared_ptr<OpSequence<Match> > seq]
{
ParsingScope scope(wccl_file);
boost::shared_ptr<Operator<Match> > op;
}
: MATCH_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<Match>(token_ref_to_std_string(name)));
}
LPAREN
op = functional_operator_match [scope] { seq->append(op); scope.reset_variables(); }
(SEMI op = functional_operator_match [scope] { seq->append(op); scope.reset_variables(); })*
functional_operator_any
[ParsingScope& scope]
returns [boost::shared_ptr<FunctionalOperator> op]
{
}
: (position_operator [scope]) => op = functional_operator_position [scope]
| (symset_operator [scope]) => op = functional_operator_symset [scope]
| (strset_operator [scope]) => op = functional_operator_strset [scope]
| (match_operator [scope]) => op = functional_operator_match [scope]
| op = functional_operator_bool [scope]
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Tagging actions and rules:
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Single action such as select, delete, relabel or unify
action
returns [boost::shared_ptr<TagAction> act]
: act = action_select [scope]
| act = action_delete [scope]
| act = action_relabel [scope]
| act = action_unify [scope]
| act = action_mark [scope]
| act = action_unmark [scope]
// Action sequence - the actions are separated with commas:
// select(...), select(...), delete(...)
action_sequence
returns [boost::shared_ptr<std::vector<boost::shared_ptr<TagAction> > > v_act]
boost::shared_ptr<TagAction> act;
v_act.reset(new std::vector<boost::shared_ptr<TagAction> >);
v_act->push_back(act);
}
(
v_act->push_back(act);
}
)*
;
// ----------------------------------------------------------------------------
// Single rule:
// rule(NAME, ACTIONS) or rule(NAME, COND, ACTIONS)
Adam Radziszewski
committed
tag_rule
{
boost::shared_ptr<Function<Bool> > condition;
boost::shared_ptr<std::vector<boost::shared_ptr<TagAction> > > actions;
: "rule" LPAREN name: STRING COMMA
(condition = bool_operator [scope] COMMA)?
actions = action_sequence [scope]
RPAREN {
if (condition) {
rle.reset(
new TagRule(token_ref_to_std_string(name), scope.variables(), actions, condition));
}
else {
rle.reset(
new TagRule(token_ref_to_std_string(name), scope.variables(), actions));
;
// Rule sequence
Adam Radziszewski
committed
tag_rule_sequence
[ParsingScope& scope]
returns [boost::shared_ptr<TagRuleSequence> rule_seq]
rule_seq.reset(new TagRuleSequence());
: rle = tag_rule [scope] {
scope.reset_variables();
SEMI rle = tag_rule [scope] {
}
)*
;
// ----------------------------------------------------------------------------
Adam Radziszewski
committed
// This is wrapper for tag_rule_sequence in rules section in the wccl file
tag_rules
[ParsingScope& scope]
returns [boost::shared_ptr<TagRuleSequence> rule_seq]
Adam Radziszewski
committed
: "tag_rules" LPAREN rule_seq = tag_rule_sequence [scope] RPAREN {
//
}
;
// ----------------------------------------------------------------------------
// Select action:
// select(position, predicate) or select(predicate);
action_select
returns [boost::shared_ptr<Select> action]
{
boost::shared_ptr<Function<Position> > pos;
boost::shared_ptr<Function<Bool> > condition;
}
: "select" LPAREN
(
(position_operator [scope]) =>
pos = position_operator [scope] COMMA
condition = bool_operator [scope] {
// select(positon, condition);
action.reset(new Select(condition, pos));
}
)
|
(
condition = bool_operator [scope] {
// select(condition);
action.reset(new Select(condition));
}
)
)
RPAREN
;
// ----------------------------------------------------------------------------
// Delete action
// delete(position, predicate) or delete(predicate);
action_delete
returns [boost::shared_ptr<Delete> action]
{
boost::shared_ptr<Function<Position> > pos;
boost::shared_ptr<Function<Bool> > condition;
}
: "delete" LPAREN
(
(position_operator [scope]) =>
pos = position_operator [scope] COMMA
condition = bool_operator [scope] {
// delete(positon, condition);
}
)
|
(
condition = bool_operator [scope] {
// delete(condition);
}
)
)
RPAREN
;
// ----------------------------------------------------------------------------
// Relabel action
// relabel(pos, symset, predicate) or relabel(symset, predicate)
action_relabel
returns [boost::shared_ptr<Relabel> action]
{
boost::shared_ptr<Function<Position> > pos;
boost::shared_ptr<Function<Bool> > condition;
boost::shared_ptr<Function<TSet> > replace_with;
}
: "relabel" LPAREN
(
(position_operator [scope]) =>
pos = position_operator [scope] COMMA
replace_with = symset_operator [scope] COMMA
condition = bool_operator [scope] {
// relabel(pos, symset, predicate)
action.reset(new Relabel(replace_with, condition, pos));
}
)
|
(
replace_with = symset_operator [scope] COMMA
condition = bool_operator [scope] {
// relabel(symset, predicate)
action.reset(new Relabel(replace_with, condition));
}
)
)
RPAREN
;
// ----------------------------------------------------------------------------
// Unify action
action_unify
returns [boost::shared_ptr<Unify> action]
{
boost::shared_ptr<Function<TSet> > attribs_expr;
boost::shared_ptr<Function<Position> > pos_begin, pos_end;
}
: "unify" LPAREN
pos_begin = position_operator [scope] COMMA
pos_end = position_operator [scope] COMMA
attribs_expr = symset_operator [scope]
RPAREN {
action.reset(new Unify(pos_begin, pos_end, attribs_expr));
}
;
// ----------------------------------------------------------------------------
// Mark action
action_mark
returns [boost::shared_ptr<Mark> action]
{
boost::shared_ptr<Function<Position> > pos_begin, pos_end, pos_head;
}
: "mark" LPAREN
pos_begin = position_operator [scope] COMMA
pos_end = position_operator [scope] COMMA
(pos_head = position_operator [scope] COMMA)?
chan_name: STRING
RPAREN {
action.reset(new Mark(pos_begin, pos_end, pos_head, ((antlr::Token*)chan_name)->getText()));
}
;
// ----------------------------------------------------------------------------
// Unmark action
action_unmark
returns [boost::shared_ptr<Unmark> action]
{
boost::shared_ptr<Function<Position> > pos;
}
: "unmark" LPAREN
pos = position_operator [scope] COMMA
chan_name: STRING
RPAREN {
action.reset(new Unmark(pos, ((antlr::Token*)chan_name)->getText()));
}
;
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Match rules
ilor
committed
// Returns boost::shared_ptr<Matching::MatchRule>
ilor
committed
returns [boost::shared_ptr<Matching::MatchRule> ret_op]
ilor
committed
boost::shared_ptr<Matching::ApplyOperator> apply;
scope.variables().get_put<Match>("_M");
: apply = match_apply_operator [scope] {
ilor
committed
ret_op = boost::make_shared<Matching::MatchRule>(scope.variables(), apply);
ilor
committed
}
;
// Match apply operator:
// apply(match(), cond(conditions), actions(actions))
// apply(match(), actions(actions))
ilor
committed
// Returns boost::shared_ptr<Matching::ApplyOperator>
ilor
committed
returns [boost::shared_ptr<Matching::ApplyOperator> ret_op]
VariableAccessor<Match> matches = scope.variables().create_accessor<Match>("_M");;
ilor
committed
boost::shared_ptr<Matching::ConjConditions> match_cond;
boost::shared_ptr<std::vector<boost::shared_ptr<Matching::MatchAction> > > actions;
boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > conditions;
: "apply" LPAREN
"match" LPAREN match_cond = match_condition [scope] RPAREN COMMA
("cond" LPAREN conditions = bool_operator_comma_sep [scope] RPAREN COMMA)?
"actions" LPAREN actions = match_action_comma_sep [scope] RPAREN
RPAREN {
if (conditions) {
ret_op.reset(
ilor
committed
new Matching::ApplyOperator(matches, match_cond, actions, conditions)
);
}
else {
ret_op.reset(
ilor
committed
new Matching::ApplyOperator(matches, match_cond, actions)
);
}
}
;
// Match conditions. Wrapper for vector of the match conditions
match_condition
ilor
committed
returns [boost::shared_ptr<Matching::ConjConditions> condition]
ilor
committed
std::vector<boost::shared_ptr<const Matching::MatchCondition> > m_cond;
: m_cond = match_condition_in [scope] {
ilor
committed
condition.reset(new Matching::ConjConditions(m_cond));
}
;
// Match conditions.
ilor
committed
// Retutns std::vector< boost::shared_ptr<const Matching::MatchCondition> >
ilor
committed
returns [std::vector< boost::shared_ptr<const Matching::MatchCondition> > ret]
ilor
committed
boost::shared_ptr<const Matching::MatchCondition> r_cond;
: r_cond = match_cond_all[scope] {
ret.push_back(r_cond);
}
(
COMMA
r_cond = match_cond_all[scope] {
ret.push_back(r_cond);
}
)*
;
// Match variants variant(v1), variant(v2), ...
ilor
committed
// Retutns boost::shared_ptr<std::vector<Matching::ConjConditions> >
match_variants
ilor
committed
returns [boost::shared_ptr<std::vector<boost::shared_ptr<Matching::ConjConditions> > > variants]
ilor
committed
variants.reset(new std::vector<boost::shared_ptr<Matching::ConjConditions> >());
ilor
committed
boost::shared_ptr<Matching::ConjConditions> variant;
: "variant" LPAREN variant = match_condition [scope] RPAREN {
}
(
COMMA "variant" LPAREN variant = match_condition [scope] RPAREN {
}
)*
;
ilor
committed
// Returns boost::shared_ptr<const Matching::MatchCondition>
ilor
committed
returns [boost::shared_ptr<const Matching::MatchCondition> ret]
: ret = match_cond_optional [scope]
| ret = match_cond_repeate [scope]
| ret = match_cond_token [scope]
| ret = match_cond_oneof [scope]
| ret = match_cond_longest [scope]
// Match condition - token (wraps a L0 predicate)
ilor
committed
// Returns boost::shared_ptr<const Matching::MatchCondition>
ilor
committed
returns [boost::shared_ptr<const Matching::TokenCondition> ret]
{
boost::shared_ptr<Function<Bool> > bool_op;
}
: bool_op = bool_operator [scope] {
ilor
committed
ret = boost::make_shared<Matching::TokenCondition>(bool_op);
// Match condition - optional
ilor
committed
// Returns boost::shared_ptr<Matching::OptionalMatch>
ilor
committed
returns [boost::shared_ptr<Matching::OptionalMatch> mtch]
ilor
committed
boost::shared_ptr<Matching::ConjConditions> m_cond;
: "optional" LPAREN m_cond = match_condition [scope] RPAREN {
ilor
committed
mtch.reset(new Matching::OptionalMatch(m_cond));
ilor
committed
// Returns boost::shared_ptr<Matching::RepeatedMatch>
ilor
committed
returns [boost::shared_ptr<Matching::RepeatedMatch> mtch]
ilor
committed
boost::shared_ptr<Matching::ConjConditions> m_cond;
: "repeat" LPAREN m_cond = match_condition [scope] RPAREN {
ilor
committed
mtch.reset(new Matching::RepeatedMatch(m_cond));
ilor
committed
// Returns boost::shared_ptr<Matching::IsAnnotatedAs>
ilor
committed
returns [boost::shared_ptr<Matching::IsAnnotatedAs> mtch]
: "is" LPAREN annotation_name: STRING RPAREN {
ilor
committed
mtch.reset(new Matching::IsAnnotatedAs(token_ref_to_std_string(annotation_name)));
ilor
committed
// Returns boost::shared_ptr<Matching::MatchText>
ilor
committed
returns [boost::shared_ptr<Matching::MatchText> mtch]
: "text" LPAREN txt: STRING RPAREN {
ilor
committed
mtch.reset(new Matching::MatchText(token_ref_to_ustring(txt)));
// Match condition - oneof(variant1(v1), variant(v2), ...)
ilor
committed
// Returns boost::shared_ptr<Matching::OneOf>
ilor
committed
returns [boost::shared_ptr<Matching::OneOf> onf]
ilor
committed
boost::shared_ptr<std::vector<boost::shared_ptr<Matching::ConjConditions> > > variants;
: "oneof" LPAREN variants = match_variants [scope] RPAREN {
ilor
committed
onf.reset(new Matching::OneOf(variants));
// Match condition - longest(variant1(v1), variant(v2), ...)
ilor
committed
// Returns boost::shared_ptr<Matching::Longest>
ilor
committed
returns [boost::shared_ptr<Matching::Longest> lng]
ilor
committed
boost::shared_ptr<std::vector<boost::shared_ptr<Matching::ConjConditions> > > variants;
: "longest" LPAREN variants = match_variants [scope] RPAREN {
ilor
committed
lng.reset(new Matching::Longest(variants));
// ----------------------------------------------------------------------------
// Match actions. Match action can be mark or unmark
ilor
committed
// Returns boost::shared_ptr<Matching::MatchAction>
match_action
ilor
committed
returns [boost::shared_ptr<Matching::MatchAction> m_act]
: m_act = match_mark_action [scope]
| m_act = match_unmark_action [scope]
| m_act = match_remark_action [scope]
| m_act = match_setprop_action [scope]
;
// Match mark action
match_mark_action
ilor
committed
returns [boost::shared_ptr<Matching::MarkMatch> m_act]
{
boost::shared_ptr<Function<Match> > match_to;
boost::shared_ptr<Function<Match> > match_from;
boost::shared_ptr<Function<Match> > head_match;
match_from = match_operator[scope] COMMA
( match_to = match_operator[scope] COMMA
( head_match = match_operator[scope] COMMA )?
if (!match_to) {
m_act.reset(
ilor
committed
new Matching::MarkMatch(
match_from,
((antlr::Token*)annotation_name)->getText()));
} else {
if (!head_match) {
m_act.reset(
ilor
committed
new Matching::MarkMatch(
match_from,
match_to,
((antlr::Token*)annotation_name)->getText()));
} else {
m_act.reset(
ilor
committed
new Matching::MarkMatch(
match_from,
match_to,
head_match,
((antlr::Token*)annotation_name)->getText()));
}
;
// Match unmark action
ilor
committed
// Returns boost::shared_ptr<Matching::UnmarkMatch>
match_unmark_action
ilor
committed
returns [boost::shared_ptr<Matching::UnmarkMatch> m_act]
{
boost::shared_ptr<Function<Match> > match_at;
}
: "unmark" LPAREN
match_at = match_operator[scope] COMMA
annotation_name : STRING
RPAREN {
m_act.reset(
ilor
committed
new Matching::UnmarkMatch(
match_at,
((antlr::Token*)annotation_name)->getText()));
}
;
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
// Overwrite-match mark action ("remark")
// Returns
match_remark_action
[ParsingScope& scope]
returns [boost::shared_ptr<Matching::OverwriteMatch> m_act]
{
boost::shared_ptr<Function<Match> > match_to;
boost::shared_ptr<Function<Match> > match_from;
boost::shared_ptr<Function<Match> > head_match;
}
: "remark" LPAREN
match_from = match_operator[scope] COMMA
( match_to = match_operator[scope] COMMA
( head_match = match_operator[scope] COMMA )?
)?
annotation_name : STRING
RPAREN {
if (!match_to) {
m_act.reset(
new Matching::OverwriteMatch(
match_from,
((antlr::Token*)annotation_name)->getText()));
} else {
if (!head_match) {
m_act.reset(
new Matching::OverwriteMatch(
match_from,
match_to,
((antlr::Token*)annotation_name)->getText()));
} else {
m_act.reset(
new Matching::OverwriteMatch(
match_from,
match_to,
head_match,
((antlr::Token*)annotation_name)->getText()));
}
}
}
;
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
// Match prop action
// Returns boost::shared_ptr<Matching::PropMatch>
match_setprop_action
[ParsingScope& scope]
returns [boost::shared_ptr<Matching::PropMatch> m_act]
{
boost::shared_ptr<Function<Match> > match_at;
}
: "setprop" LPAREN
match_at = match_operator[scope] COMMA
key_name : STRING COMMA
value_name : STRING
RPAREN {
m_act.reset(
new Matching::PropMatch(
match_at,
((antlr::Token*)key_name)->getText(),
((antlr::Token*)value_name)->getText()));
}
;
// Match action separated by comma
ilor
committed
// Returns boost::shared_ptr<std::vector<boost::shared_ptr<Matching::MatchAction> > >
match_action_comma_sep
ilor
committed
returns [boost::shared_ptr<std::vector<boost::shared_ptr<Matching::MatchAction> > > r_vec]
ilor
committed
boost::shared_ptr<Matching::MatchAction> act;
r_vec.reset(
ilor
committed
new std::vector<boost::shared_ptr<Matching::MatchAction> >
);
}
: act = match_action [scope] {
r_vec->push_back(act);
}
(
COMMA act = match_action [scope] {
r_vec->push_back(act);
}
)*
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class ANTLRLexer extends Lexer;
options {
exportVocab = ANTLRExpr;
charVocabulary = '\3'..'\377';
: '"'! (~('"' | '\n' | '\r'))* '"'!
| '\''! (~('\'' | '\n' | '\r'))* '\''!
: ('-'|'+') (' '!|'\t'!)* ('0'..'9')+
UNSIGNED_INT
options {
paraphrase = "Unsigned integer";
}
: ('0'..'9')+
;
STR_PREFIX
options {
paraphrase = "String prefix";
}
Paweł Kędzia
committed
: "$s:"
;
TST_PREFIX
options {
Paweł Kędzia
committed
: "$t:"
;
BOOL_PREFIX
options {
paraphrase = "Bool prefix";
}
Paweł Kędzia
committed
: "$b:"
Paweł Kędzia
committed
paraphrase = "Position prefix";
Paweł Kędzia
committed
: '$'
MATCH_VECTOR_PREFIX
options {
paraphrase = "Match vector prefix";
}
: "$m:"
;
STR_SECTION_PREFIX
options {
paraphrase = "Wccl file string operators section prefix";
}
: "@s:"
;