Newer
Older
boost::shared_ptr<VariableAccessor<Position> > ret_acc;
: ret_acc = position_variable_acc [vars]
COMMA
ret_op = position_operator [tagset, vars] {
op.reset(new VarSetter<Position>(*ret_acc.get(), ret_op));
}
// ----------------------------------------------------------------------------
// Setvar for bool
bool_setvar
[const Corpus2::Tagset& tagset, Variables& vars]
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 [vars]
COMMA
ret_op = bool_operator [tagset, vars] {
op.reset(new VarSetter<Bool>(*ret_acc.get(), ret_op));
}
// ----------------------------------------------------------------------------
// Setvar for strset
strset_setvar
[const Corpus2::Tagset& tagset, Variables& vars]
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 [vars]
COMMA
ret_op = string_operator [tagset, vars] {
op.reset(new VarSetter<StrSet>(*ret_acc.get(), ret_op));
Paweł Kędzia
committed
}
// ----------------------------------------------------------------------------
// Setvar for symset
symset_setvar
[const Corpus2::Tagset& tagset, Variables& vars]
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 [vars]
COMMA
ret_op = symset_operator [tagset, vars] {
op.reset(new VarSetter<TSet>(*ret_acc.get(), ret_op));
}
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class ANTLRLexer extends Lexer;
options {
exportVocab = ANTLRExpr;
charVocabulary = '\3'..'\377';
}
STRING
options {
paraphrase = "a string";
}
: ('-'|'+') (' '!|'\t'!)* ('0'..'9')+
UNSIGNED_INT
options {
paraphrase = "Unsigned integer";
}
: ('0'..'9')+
;
STR_PREFIX
options {
paraphrase = "String prefix";
}
Paweł Kędzia
committed
: "$s:"
;
TST_PREFIX
options {
Paweł Kędzia
committed
: "$t:"
;
BOOL_PREFIX
options {
paraphrase = "Bool prefix";
}
Paweł Kędzia
committed
: "$b:"
Paweł Kędzia
committed
paraphrase = "Position prefix";
Paweł Kędzia
committed
: '$'
RBRACKET
options {
paraphrase = "']'";
}
: ']'
LPAREN
options {
paraphrase = "'('";
}
: '('
RPAREN
options {
paraphrase = "')'";
}
: ')'
LCURLY
options {
paraphrase = "'{'";
}
: '{'
RCURLY
options {
paraphrase = "'}'";
}
: '}'
AT_MARK
options {
paraphrase = "'@'";
}
: '@'
: ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*
| '`' ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')* '`'
| '\t'
| '\f'
| ( "\r\n"
| '\r'
| '\n'
)
{ newline(); }
)
{ $setType(antlr::Token::SKIP); }
paraphrase = "Single line comment";
}
: "//" (~('\n'|'\r'))* { $setType(antlr::Token::SKIP); }
;
ML_COMMENT
options {
paraphrase = "Multi line comment";
( // TODO: test it and add reference to the site it's taken from!
/* This actually works OK despite the ambiguity that
'\r' '\n' can be matched in one alternative or by matching
'\r' in one iteration and '\n' in another.. But
this is really matched just by one rule per (...)*
loop iteration, so it's OK.
This is exactly how they do it all over the web - just
turn off the warning for this particular token.*/
options {
generateAmbigWarnings = false;
}
: { LA(2)!='/' }? '*'
| '\r' '\n' { newline(); }
| '\r' { newline(); }
| '\n' { newline(); }
)*
{ $setType(antlr::Token::SKIP); }
//DSEPARATOR
//options {
// paraphrase = "':-'";
//}
// : ":-"
//;