diff --git a/libwccl/ops/match/applyoperator.h b/libwccl/ops/match/applyoperator.h index 65db7e946d6cbdb2df2c4456e9e6dbef86109163..d90aadc20dbc981bda82ba878f65acc7ebef6443 100644 --- a/libwccl/ops/match/applyoperator.h +++ b/libwccl/ops/match/applyoperator.h @@ -41,6 +41,13 @@ public: */ std::string to_string(const Corpus2::Tagset& tagset) const; + /** + * Executes the apply operator on given context. + * It iterates current sentence position applying match operator + * and if match is found and conditions are met, executes actions. + */ + virtual void execute(const ActionExecContext &context) const; + protected: /** * Writes string representation of the operator to @@ -50,13 +57,6 @@ protected: */ std::ostream& write_to(std::ostream& ostream) const; - /** - * Executes the apply operator on given context. - * It iterates current sentence position applying match operator - * and if match is found and conditions are met, executes actions. - */ - virtual void execute(const ActionExecContext &context) const; - private: const VariableAccessor<Match> _matches; const boost::shared_ptr<const MatchOperator> _match_op; diff --git a/libwccl/parser/Parser.cpp b/libwccl/parser/Parser.cpp index 8a08f26678461ebc0ec5b844f712428e274002bd..161959d12a9d5e1d18b05f84d547ed267933a92c 100644 --- a/libwccl/parser/Parser.cpp +++ b/libwccl/parser/Parser.cpp @@ -508,7 +508,7 @@ boost::shared_ptr<TagRule> Parser::parseSingleRule( * @arg istr input stream with writed rule * @return the parsed rule via a shared pointer */ -boost::shared_ptr<Expression> Parser::parseMatchRule( +boost::shared_ptr<ApplyOperator> Parser::parseMatchRule( const std::string& str) const { std::stringstream ss (std::stringstream::in | std::stringstream::out); @@ -527,11 +527,11 @@ boost::shared_ptr<Expression> Parser::parseMatchRule( * @arg istr input stream with writed rule * @return the parsed rule via a shared pointer */ -boost::shared_ptr<Expression> Parser::parseMatchRule(std::istream& istr) const +boost::shared_ptr<ApplyOperator> Parser::parseMatchRule(std::istream& istr) const { ANTLRLexer lexer(istr); ANTLRParser parser(lexer); - boost::shared_ptr<Expression> res; + boost::shared_ptr<ApplyOperator> res; try { res = parser.parse_match_rule(tagset_); diff --git a/libwccl/parser/Parser.h b/libwccl/parser/Parser.h index 7e5b00c25e9f1f339a403fe6cf97207f069091d9..d323f077dca216aeb19f5e1a6b2f91f40dba76fc 100644 --- a/libwccl/parser/Parser.h +++ b/libwccl/parser/Parser.h @@ -83,9 +83,9 @@ public: // --------------------------------------------------------------------------- // Parsing match rule from input string - boost::shared_ptr<Expression> + boost::shared_ptr<ApplyOperator> parseMatchRule(const std::string& rule_string) const; - boost::shared_ptr<Expression> + boost::shared_ptr<ApplyOperator> parseMatchRule(std::istream& is) const; // --------------------------------------------------------------------------- diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index f6c5c4d2c9a19e0701791fa97a1dcc47cadbd410..4326f696ce7c1d85aaa348209121b29417ad6c9c 100644 --- a/libwccl/parser/grammar.g +++ b/libwccl/parser/grammar.g @@ -245,10 +245,10 @@ parse_rule_sequence // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Rule for parsing the match rules -// Returns boost::shared_ptr<Expression> +// Returns boost::shared_ptr<ApplyOperator> parse_match_rule [const Corpus2::Tagset& tagset] - returns [boost::shared_ptr<Expression> ret_match] + returns [boost::shared_ptr<ApplyOperator> ret_match] { Variables vars; vars.get_put<Match>("_M"); @@ -1794,10 +1794,10 @@ action_unmark // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Match rules -// Returns boost::shared_ptr<Expression> +// Returns boost::shared_ptr<ApplyOperator> match_rule_operator [const Corpus2::Tagset& tagset, Variables& vars] - returns [boost::shared_ptr<Expression> ret_op] + returns [boost::shared_ptr<ApplyOperator> ret_op] { // }