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
592ba564
Commit
592ba564
authored
13 years ago
by
Adam Wardynski
Browse files
Options
Downloads
Patches
Plain Diff
Adding first() & last() ops to the grammar.
parent
d2878523
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
+32
-2
32 additions, 2 deletions
libwccl/parser/grammar.g
with
32 additions
and
2 deletions
libwccl/parser/grammar.g
+
32
−
2
View file @
592ba564
...
...
@@ -53,6 +53,8 @@ header {
#include <libwccl/ops/functions/tset/getsymbolsinrange.h>
#include <libwccl/ops/functions/position/relativeposition.h>
#include <libwccl/ops/functions/position/lasttoken.h>
#include <libwccl/ops/functions/position/firsttoken.h>
#include <libwccl/ops/functions/bool/iterations/only.h>
#include <libwccl/ops/functions/bool/iterations/atleast.h>
...
...
@@ -830,8 +832,10 @@ position_operator
[const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Position> > ret]
:
( ret = position_var_val [vars]
| ret = position_condition [tagset, vars]
( ret = position_var_val [vars]
| ret = position_condition [tagset, vars]
| ret = position_first_token [tagset, vars]
| ret = position_last_token [tagset, vars]
| LPAREN ret = position_operator [tagset, vars] RPAREN
)
( // if there is SIGNED_INT after the position, it is actually a relative position
...
...
@@ -880,6 +884,32 @@ position_condition
}
;
// ----------------------------------------------------------------------------
// Taking position of a first token in a match
// first(Match)
position_first_token [const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Position> > ret]
{
boost::shared_ptr<Function<Match> > m;
}
: "first" LPAREN m = match_fit [tagset, vars] RPAREN {
ret.reset(new FirstToken(m));
}
;
// ----------------------------------------------------------------------------
// Taking position of a first token in a match
// last(Match)
position_last_token [const Corpus2::Tagset& tagset, Variables& vars]
returns [boost::shared_ptr<Function<Position> > ret]
{
boost::shared_ptr<Function<Match> > m;
}
: "last" LPAREN m = match_fit [tagset, vars] RPAREN {
ret.reset(new LastToken(m));
}
;
///////////////////////////////////////////////////////////////////////////////
// Stiring operator
// Returns boost::shared_ptr<Function<StrSet> >
...
...
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