Newer
Older
returns [boost::shared_ptr<Function<StrSet> > ret]
boost::shared_ptr<Function<Position> > pos;
: "base" LBRACKET pos = position_operator [scope] RBRACKET {
// ----------------------------------------------------------------------------
// Lower operator.
strset_lower
returns [boost::shared_ptr<Function<StrSet> > ret]
boost::shared_ptr<Function<StrSet> > o_ret;
: "lower" LPAREN o_ret = strset_operator [scope] RPAREN {
ret.reset(new ToLower(o_ret));
// ----------------------------------------------------------------------------
// Upper operator.
strset_upper
returns [boost::shared_ptr<Function<StrSet> > ret]
boost::shared_ptr<Function<StrSet> > o_ret;
: "upper" LPAREN o_ret = strset_operator [scope] RPAREN {
ret.reset(new ToUpper(o_ret));
// ----------------------------------------------------------------------------
// Affix operator.
strset_affix
returns [boost::shared_ptr<Function<StrSet> > ret]
boost::shared_ptr<Function<StrSet> > o_ret;
: "affix" LPAREN
o_ret = strset_operator [scope] COMMA offset = number
RPAREN {
ret.reset(new Affix(o_ret, offset));
}
// ----------------------------------------------------------------------------
// A wrapper for strset value and strset variable
strset_var_val
returns [boost::shared_ptr<Function<StrSet> > op]
: op = strset_value
| op = strset_variable [scope.variables()]
// ----------------------------------------------------------------------------
// Condition of the strset value
// if (Bool, StrSet, StrSet)
// ? StrSet ? Bool : []
strset_condition
returns [boost::shared_ptr<Function<StrSet> > op]
boost::shared_ptr<Function<Bool> > test;
boost::shared_ptr<Function<StrSet> > p_true, p_false;
: "if" LPAREN test = bool_operator [scope] COMMA
p_true = strset_operator [scope]
(COMMA p_false = strset_operator [scope])?
RPAREN {
Paweł Kędzia
committed
if (p_false) {
op.reset(new Conditional<StrSet>(test, p_true, p_false));
Paweł Kędzia
committed
}
else {
op.reset(new Conditional<StrSet>(test, p_true));
Paweł Kędzia
committed
}
Paweł Kędzia
committed
| Q_MARK
p_true = strset_operator [scope]
Paweł Kędzia
committed
Q_MARK
test = bool_operator [scope] {
op.reset(new Conditional<StrSet>(test, p_true));
Paweł Kędzia
committed
}
strset_lex
[ParsingScope& scope]
returns [boost::shared_ptr<Function<StrSet> > op]
{
boost::shared_ptr<Function<StrSet> > s;
}
: "lex" LPAREN s = strset_operator [scope] COMMA name : STRING RPAREN
{
op.reset(new LexTranslator(
s,
scope.lexicons().get_ptr(token_ref_to_std_string(name))));
}
exception catch [WcclError ex] {
throw ParserException(ex.what());
}
;
///////////////////////////////////////////////////////////////////////////////
// Returns boost::shared_ptr<Function<Bool> >
///////////////////////////////////////////////////////////////////////////////
bool_operator
returns [boost::shared_ptr<Function<Bool> > ret]
: ret = bool_and [scope]
| ret = bool_or [scope]
| ret = bool_nor [scope]
| ret = bool_var_val [scope]
| ret = bool_regex [scope]
| ret = bool_inout [scope]
| ret = bool_condition [scope]
// setvar:
| ret = setvar_operator [scope]
// empty
| ret = empty_operator [scope]
// equal/in/inter:
| ret = equal_operator [scope]
| ret = in_operator [scope]
| ret = inter_operator [scope]
| ret = bool_iteration [scope]
// agreement
| ret = bool_agreement [scope]
//
| ret = bool_ann [scope]
| ret = bool_annsub [scope]
ilor
committed
// debug operators
| ret = debug_print_operator [scope]
| LPAREN ret = bool_operator [scope] RPAREN
// ----------------------------------------------------------------------------
// comma-separated predicates (bool operators)
bool_operator_comma_sep
returns
[boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v]
boost::shared_ptr<Function<Bool> > pred;
new std::vector<boost::shared_ptr<Function<Bool> > >
: pred = bool_operator [scope] {
ret_v->push_back(pred);
}
(
COMMA pred = bool_operator [scope] {
ret_v->push_back(pred);
}
)*
// ----------------------------------------------------------------------------
// And operator.
bool_and
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v;
: "and" LPAREN ret_v = bool_operator_comma_sep [scope] RPAREN {
op.reset(new And(ret_v));
// ----------------------------------------------------------------------------
// Or operator
bool_or
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v;
: "or" LPAREN ret_v = bool_operator_comma_sep [scope] RPAREN {
op.reset(new Or(ret_v));
// ----------------------------------------------------------------------------
// Nor/Not operator
bool_nor
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > ret_v;
: "not" LPAREN ret_v = bool_operator_comma_sep [scope] RPAREN {
op.reset(new Nor(ret_v));
// ----------------------------------------------------------------------------
// Wrapper for bool value and bool variable
bool_var_val
returns [boost::shared_ptr<Function<Bool> > op]
: op = bool_value
| op = bool_variable [scope.variables()]
// ----------------------------------------------------------------------------
// Regex operator
bool_regex
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr<Function<StrSet> > expr;
}
: "regex"
LPAREN
expr = strset_operator [scope] COMMA reg: STRING
RPAREN {
op.reset(new Regex(expr, token_ref_to_ustring(reg)));
}
;
// ----------------------------------------------------------------------------
// Input/output operator
bool_inout
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr<Function<Position> > ret_pos;
}
: "inside" LPAREN ret_pos = position_operator [scope] RPAREN {
op.reset(new IsInside(ret_pos));
}
| "outside" LPAREN ret_pos = position_operator [scope] RPAREN {
op.reset(new IsOutside(ret_pos));
}
;
// ----------------------------------------------------------------------------
// if (Bool, Bool, Bool)
// ? Bool ? Bool : False
bool_condition
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr<Function<Bool> > test, p_true, p_false;
}
: "if" LPAREN test = bool_operator [scope] COMMA
p_true = bool_operator [scope]
(COMMA p_false = bool_operator [scope])?
RPAREN {
if (p_false) {
op.reset(new Conditional<Bool>(test, p_true, p_false));
}
else {
op.reset(new Conditional<Bool>(test, p_true));
}
}
| Q_MARK
p_true = bool_operator [scope]
Q_MARK
test = bool_operator [scope] {
op.reset(new Conditional<Bool>(test, p_true));
}
;
// ----------------------------------------------------------------------------
// Equal operator
equal_operator
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<Function<TSet> > t1, t2;
boost::shared_ptr<Function<Bool> > b1, b2;
boost::shared_ptr<Function<StrSet> > s1, s2;
boost::shared_ptr<Function<Position> > p1, p2;
: "equal" LPAREN
(position_operator [scope]) =>
p1 = position_operator [scope] COMMA
p2 = position_operator [scope] {
op.reset(new Equals<Position>(p1, p2));
(symset_operator [scope]) =>
t1 = symset_operator [scope] COMMA
t2 = symset_operator [scope] {
op.reset(new Equals<TSet>(t1, t2));
}
)
|
(strset_operator [scope]) =>
s1 = strset_operator [scope] COMMA
s2 = strset_operator [scope] {
op.reset(new Equals<StrSet>(s1, s2));
}
)
|
(
b1 = bool_operator [scope] COMMA
b2 = bool_operator [scope] {
op.reset(new Equals<Bool>(b1, b2));
// ----------------------------------------------------------------------------
// In operator
in_operator
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<Function<TSet> > t1, t2;
boost::shared_ptr<Function<StrSet> > s1, s2;
Paweł Kędzia
committed
}
:
"in" LPAREN
(symset_operator [scope]) =>
t1 = symset_operator [scope] COMMA
t2 = symset_operator [scope] {
op.reset(new IsSubsetOf<TSet>(t1, t2));
s1 = strset_operator [scope] COMMA
s2 = strset_operator [scope] {
op.reset(new IsSubsetOf<StrSet>(s1, s2));
;
// ----------------------------------------------------------------------------
// Inter operator
inter_operator
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<Function<TSet> > t1, t2;
boost::shared_ptr<Function<StrSet> > s1, s2;
:
"inter" LPAREN
(symset_operator [scope]) =>
t1 = symset_operator [scope] COMMA
t2 = symset_operator [scope] {
op.reset(new Intersects<TSet>(t1, t2));
s1 = strset_operator [scope] COMMA
s2 = strset_operator [scope] {
op.reset(new Intersects<StrSet>(s1, s2));
// ----------------------------------------------------------------------------
// Annotation operator.
bool_ann
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr< Function<Match> > match_from;
boost::shared_ptr< Function<Match> > match_to;
}
: "ann" LPAREN
match_from = match_operator [scope] COMMA
(match_to = match_operator [scope] COMMA)?
ilor
committed
channel : STRING
ilor
committed
op.reset(new Ann(match_from, match_to, token_ref_to_std_string(channel)));
ilor
committed
op.reset(new Ann(match_from, token_ref_to_std_string(channel)));
// ----------------------------------------------------------------------------
// Annotation-sub operator.
bool_annsub
returns [boost::shared_ptr<Function<Bool> > op]
{
boost::shared_ptr< Function<Match> > match_from;
boost::shared_ptr< Function<Match> > match_to;
}
: "annsub" LPAREN
match_from = match_operator [scope] COMMA
(match_to = match_operator [scope] COMMA)?
ilor
committed
channel : STRING
ilor
committed
op.reset(new AnnSub(match_from, match_to, token_ref_to_std_string(channel)));
ilor
committed
op.reset(new AnnSub(match_from, token_ref_to_std_string(channel)));
ilor
committed
// ----------------------------------------------------------------------------
// Debug printing:
debug_print_operator
ilor
committed
returns [boost::shared_ptr<Function<Bool> > ret]
{
boost::shared_ptr<FunctionBase> v;
}
: "debug" LPAREN
(
(position_operator [scope]) =>
ilor
committed
(
v = position_operator [scope] {
ilor
committed
ret.reset(new DebugPrint(v));
}
)
|
(symset_operator [scope]) =>
ilor
committed
(
v = symset_operator [scope] {
ilor
committed
ret.reset(new DebugPrint(v));
}
)
|
(strset_operator [scope]) =>
ilor
committed
(
v = strset_operator [scope] {
ilor
committed
ret.reset(new DebugPrint(v));
}
)
|
ilor
committed
(
ilor
committed
ret.reset(new DebugPrint(v));
}
)
v = match_operator [scope] {
ret.reset(new DebugPrint(v));
}
)
ilor
committed
)
RPAREN
;
// ----------------------------------------------------------------------------
// Iterations:
bool_iteration
returns [boost::shared_ptr<Function<Bool> > ret]
{
int min_match = 0;
boost::shared_ptr<Function<Bool> > expr;
boost::shared_ptr<Function<Position> > lpos, rpos;
boost::shared_ptr<VariableAccessor<Position> > pacc;
}
: "only" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA
pacc = position_variable_acc [scope.variables()] COMMA
expr = bool_operator [scope]
RPAREN {
ret.reset(new Only(lpos, rpos, *pacc, expr));
}
| "atleast" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA
pacc = position_variable_acc [scope.variables()] COMMA
expr = bool_operator [scope] COMMA
min_match = number
RPAREN {
ret.reset(new AtLeast(lpos, rpos, *pacc, expr, min_match));
}
| "llook" LPAREN //note inverted rpos/lpos order
rpos = position_operator [scope] COMMA
lpos = position_operator [scope] COMMA
pacc = position_variable_acc [scope.variables()] COMMA
expr = bool_operator [scope]
RPAREN {
ret.reset(new LeftLook(lpos, rpos, *pacc, expr));
}
| "rlook" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA
pacc = position_variable_acc [scope.variables()] COMMA
expr = bool_operator [scope]
RPAREN {
ret.reset(new RightLook(lpos, rpos, *pacc, expr));
}
;
// ----------------------------------------------------------------------------
// Agreement operator: agr, agrpp, wagr
bool_agreement
returns [boost::shared_ptr<Function<Bool> > ret]
{
boost::shared_ptr<Function<TSet> > expr;
boost::shared_ptr<Function<Position> > lpos, rpos;
}
: "agr" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA
expr = symset_operator [scope]
ret.reset(new StrongAgreement(lpos, rpos, expr, scope.tagset()));
}
| "agrpp" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA
expr = symset_operator [scope]
ret.reset(new PointAgreement(lpos, rpos, expr, scope.tagset()));
}
| "wagr" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA
expr = symset_operator [scope]
ret.reset(new WeakAgreement(lpos, rpos, expr, scope.tagset()));
}
;
// ----------------------------------------------------------------------------
// Parse operator on L1 level
bool_phrase
: ret = bool_phrase_annotation [scope]
| ret = bool_phrase_iteration [scope]
;
// ----------------------------------------------------------------------------
// Annotation operator: phrase, phrase_beg, phrase_end, phrase_whole, phrase_pp
bool_phrase_annotation
returns [boost::shared_ptr<Function<Bool> > ret]
{
boost::shared_ptr<Function<Position> > lpos, rpos;
}
: "phrase" LPAREN
lpos = position_operator [scope] COMMA n1: STRING
RPAREN {
// TODO
}
| "phrase_beg" LPAREN
lpos = position_operator [scope] COMMA n2: STRING
RPAREN {
// TODO
}
| "phrase_end" LPAREN
lpos = position_operator [scope] COMMA n3: STRING
RPAREN {
// TODO
}
| "phrase_whole" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA n4: STRING
RPAREN {
// TODO
}
| "phrase_pp" LPAREN
lpos = position_operator [scope] COMMA
rpos = position_operator [scope] COMMA n5: STRING
RPAREN {
// TODO
}
;
// ----------------------------------------------------------------------------
// Phrase iteration operator: lphrase, rphrase
bool_phrase_iteration
returns [boost::shared_ptr<Function<Bool> > ret]
{
boost::shared_ptr<Function<Position> > position;
boost::shared_ptr<VarGetter<Position> > var_position;
}
: "lphrase" LPAREN
position = position_operator [scope] COMMA
var_position = position_variable [scope.variables()] COMMA
n1: STRING
RPAREN {
// TODO
}
| "rphrase" LPAREN
position = position_operator [scope] COMMA
var_position = position_variable [scope.variables()] COMMA
n2: STRING
RPAREN {
// TODO
}
;
// ----------------------------------------------------------------------------
// Setvar operator
// Returns boost::shared_ptr<Function<Bool> >
// ----------------------------------------------------------------------------
setvar_operator
returns [boost::shared_ptr<Function<Bool> > ret]
: "setvar" LPAREN
(
ret = position_setvar [scope]
| ret = bool_setvar [scope]
| ret = strset_setvar [scope]
| ret = symset_setvar [scope]
)
RPAREN
;
// ----------------------------------------------------------------------------
// Setvar for position
position_setvar
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<Function<Position> > ret_op;
boost::shared_ptr<VariableAccessor<Position> > ret_acc;
: ret_acc = position_variable_acc [scope.variables()]
COMMA
ret_op = position_operator [scope] {
op.reset(new VarSetter<Position>(*ret_acc, ret_op));
// ----------------------------------------------------------------------------
// Setvar for bool
bool_setvar
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<Function<Bool> > ret_op;
boost::shared_ptr<VariableAccessor<Bool> > ret_acc;
: ret_acc = bool_variable_acc [scope.variables()]
COMMA
ret_op = bool_operator [scope] {
op.reset(new VarSetter<Bool>(*ret_acc, ret_op));
// ----------------------------------------------------------------------------
// Setvar for strset
strset_setvar
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<Function<StrSet> > ret_op;
boost::shared_ptr<VariableAccessor<StrSet> > ret_acc;
: ret_acc = strset_variable_acc [scope.variables()]
COMMA
ret_op = strset_operator [scope] {
op.reset(new VarSetter<StrSet>(*ret_acc, ret_op));
Paweł Kędzia
committed
}
// ----------------------------------------------------------------------------
// Setvar for symset
symset_setvar
returns [boost::shared_ptr<Function<Bool> > op]
boost::shared_ptr<Function<TSet> > ret_op;
boost::shared_ptr<VariableAccessor<TSet> > ret_acc;
: ret_acc = symset_variable_acc [scope.variables()]
COMMA
ret_op = symset_operator [scope] {
op.reset(new VarSetter<TSet>(*ret_acc, ret_op));
}
;
// ----------------------------------------------------------------------------
// empty() operator
// Returns boost::shared_ptr<Function<Bool> >
//----------------------------------------------------------------------------
empty_operator
returns [boost::shared_ptr<Function<Bool> > op]
: "empty" LPAREN
(
)
RPAREN
;
/*
empty_operator
returns [boost::shared_ptr<Function<Bool> > op]
: "empty" LPAREN
(
op = match_empty [scope]
| op = symset_empty [scope]
| op = strset_empty [scope]
)
RPAREN
;
*/
//----------------------------------------------------------------------------
// 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
// 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))); }
)*
;
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// WCCL FILE PARSING RULES
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
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.tagset()] {
wccl_file.add_untyped_section(untyped_seq);
}
| bool_seq = bool_operator_sequence [wccl_file.tagset()] {
wccl_file.add_section(bool_seq);
}
| symset_seq = symset_operator_sequence [wccl_file.tagset()] {
wccl_file.add_section(symset_seq);
}
| strset_seq = strset_operator_sequence [wccl_file.tagset()] {
wccl_file.add_section(strset_seq);
}
| pos_seq = position_operator_sequence [wccl_file.tagset()] {
wccl_file.add_section(pos_seq);
}
| m_seq = match_operator_sequence [wccl_file.tagset()] {
wccl_file.add_section(m_seq);
}
;
bool_operator_sequence
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<OpSequence<Bool> > seq]
{
boost::shared_ptr<Operator<Bool> > op;
}
: BOOL_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<Bool>(token_ref_to_std_string(name)));
}
LPAREN
(op = parse_bool_operator [tagset] { seq->append(op); })+
RPAREN
;
symset_operator_sequence
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<OpSequence<TSet> > seq]
{
boost::shared_ptr<Operator<TSet> > op;
}
: TST_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<TSet>(token_ref_to_std_string(name)));
}
LPAREN
(op = parse_symset_operator [tagset] { seq->append(op); })+
RPAREN
;
strset_operator_sequence
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<OpSequence<StrSet> > seq]
{
boost::shared_ptr<Operator<StrSet> > op;
}
: STR_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<StrSet>(token_ref_to_std_string(name)));
}
LPAREN
(op = parse_strset_operator [tagset] { seq->append(op); })+
RPAREN
;
position_operator_sequence
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<OpSequence<Position> > seq]
{
boost::shared_ptr<Operator<Position> > op;
}
: POS_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<Position>(token_ref_to_std_string(name)));
}
LPAREN
(op = parse_position_operator [tagset] { seq->append(op); })+
RPAREN
;
untyped_operator_sequence
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<UntypedOpSequence> seq]
{
boost::shared_ptr<FunctionalOperator> op;
}
: AT_MARK name: STRING {
seq.reset(new UntypedOpSequence(token_ref_to_std_string(name)));
}
LPAREN
(op = any_operator [tagset] { seq->append(op); })+
RPAREN
;
match_operator_sequence
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<OpSequence<Match> > seq]
{
boost::shared_ptr<Operator<Match> > op;
}
: MATCH_SECTION_PREFIX name: STRING {
seq.reset(new OpSequence<Match>(token_ref_to_std_string(name)));
}
LPAREN
(op = parse_match_operator [tagset] { seq->append(op); })+
RPAREN
;
any_operator
[const Corpus2::Tagset& tagset]
returns [boost::shared_ptr<FunctionalOperator> op]
{
static ParsingScope _s(tagset); // just a bogus scope for predicates
}
: (position_operator [_s]) => op = parse_position_operator [tagset]
| (symset_operator [_s]) => op = parse_symset_operator [tagset]
| (strset_operator [_s]) => op = parse_strset_operator [tagset]
| (match_operator [_s]) => op = parse_match_operator [tagset]
| op = parse_bool_operator [tagset]
;
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// 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