Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
f5bf93e5
Commit
f5bf93e5
authored
14 years ago
by
Paweł Kędzia
Browse files
Options
Downloads
Patches
Plain Diff
Added match conditions and match operator
parent
6f4e5b27
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libwccl/parser/grammar.g
+133
-0
133 additions, 0 deletions
libwccl/parser/grammar.g
with
133 additions
and
0 deletions
libwccl/parser/grammar.g
+
133
−
0
View file @
f5bf93e5
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment