Skip to content
Snippets Groups Projects
Commit c70537dd authored by Paweł Kędzia's avatar Paweł Kędzia
Browse files

Base oeprator has been added.

parent d8b86835
No related merge requests found
......@@ -25,6 +25,7 @@ header {
#include <libwccl/ops/functions/bool/varsetter.h>
#include <libwccl/ops/functions/strset/affix.h>
#include <libwccl/ops/functions/strset/getorth.h>
#include <libwccl/ops/functions/strset/toupper.h>
#include <libwccl/ops/functions/strset/tolower.h>
......@@ -37,6 +38,8 @@ header {
#include <libwccl/ops/functions/bool/predicates/isinside.h>
#include <libwccl/ops/functions/bool/predicates/isoutside.h>
#include <libwccl/ops/functions/position/relativeposition.h>
#include <libwccl/ops/functions/conditional.h>
// Unicode String
......@@ -50,6 +53,8 @@ header {
options {
language = "Cpp";
genHashLines = false;
// namespace = "Wccl";
// genHashLines = true;
}
// ----------------------------------------------------------------------------
......@@ -252,7 +257,7 @@ boolean_value
// returns boost::shared_ptr<Wccl::Position>
position_literal
returns [boost::shared_ptr<Wccl::Position> val]
: i: INT {
: i: UNSIGNED_INT {
val.reset(new Wccl::Position(Wccl::Position(token_ref_to_int(i))));
}
| "begin" {
......@@ -277,6 +282,16 @@ position_value
}
;
// ----------------------------------------------------------------------------
// Number may be unsigned or signed
number returns [int ret]
{
ret = 0;
}
: s: SIGNED_INT { ret = token_ref_to_int(s); }
| u: UNSIGNED_INT { ret = token_ref_to_int(u); }
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// VARIABLES
......@@ -310,6 +325,25 @@ position_variable
}
;
// realtive position
relpos
[Wccl::Variables& vars]
returns [boost::shared_ptr<Wccl::Function<Wccl::Position> > ret]
{
boost::shared_ptr<Wccl::Function<Wccl::Position> > pos;
}
: "relpos"
LPAREN
pos = op_position [vars] ("+" | "-") ofst: UNSIGNED_INT
RPAREN {
ret.reset(new Wccl::RelativePosition(
pos,
token_ref_to_int(ofst)
)
);
}
;
// ----------------------------------------------------------------------------
// String set, $s:name
// This expression gets variable of the type StrSet from string-named variable
......@@ -537,6 +571,7 @@ position_operators
returns [boost::shared_ptr<Wccl::Function<Wccl::Position> > ret]
: ret = op_position [vars]
;
// Implementations of symbol set operators:
// ----------------------------------------------------------------------------
op_position
......@@ -544,6 +579,7 @@ op_position
returns [boost::shared_ptr<Wccl::Function<Wccl::Position> > op]
: op = position_variable [vars]
| op = position_value
| op = relpos [vars]
;
// ----------------------------------------------------------------------------
......@@ -568,10 +604,10 @@ op_orth
[const Corpus2::Tagset& tagset, Wccl::Variables& vars]
returns [boost::shared_ptr<Wccl::Function<Wccl::StrSet> > ret]
{
boost::shared_ptr<Wccl::VarGetter<Wccl::Position> > pos;
boost::shared_ptr<Wccl::Function<Wccl::Position> > pos;
}
: "orth" LBRACKET pos = position_variable [vars] RBRACKET {
// ret = TODO
: "orth" LBRACKET pos = op_position [vars] RBRACKET {
ret.reset(new Wccl::GetOrth(pos));
}
;
// ----------------------------------------------------------------------------
......@@ -612,12 +648,13 @@ op_affix
[const Corpus2::Tagset& tagset, Wccl::Variables& vars]
returns [boost::shared_ptr<Wccl::Function<Wccl::StrSet> > ret]
{
int offset = 0;
boost::shared_ptr<Wccl::Function<Wccl::StrSet> > o_ret;
}
: "affix" LPAREN
o_ret = string_operators[tagset, vars] COMMA
offset: INT RPAREN {
ret.reset(new Wccl::Affix(o_ret, token_ref_to_int(offset)));
o_ret = string_operators[tagset, vars] COMMA offset = number
RPAREN {
ret.reset(new Wccl::Affix(o_ret, offset));
}
;
// ----------------------------------------------------------------------------
......@@ -922,13 +959,21 @@ options {
| '\'' (~'\'')* '\''
;
INT
SIGNED_INT
options {
paraphrase = "Integer";
paraphrase = "Signed integer";
}
: ('-'|'+')? ('0'..'9')+
: ('-'|'+') ('0'..'9')+
;
UNSIGNED_INT
options {
paraphrase = "Unsigned integer";
}
: ('0'..'9')+
;
QUOT_MARK
options {
paraphrase = "Quota mark";
......
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