use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class CssParser method nested.
// $ANTLR start "nested"
// /home/langera/dev/freud/src/grammar/Css.g:48:1: nested : '@' nest '{' ( properties )? ( nested )* '}' -> ^( NESTED nest ( properties )* ( nested )* ) ;
public final CssParser.nested_return nested() throws RecognitionException {
CssParser.nested_return retval = new CssParser.nested_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal7 = null;
Token char_literal9 = null;
Token char_literal12 = null;
CssParser.nest_return nest8 = null;
CssParser.properties_return properties10 = null;
CssParser.nested_return nested11 = null;
CommonTree char_literal7_tree = null;
CommonTree char_literal9_tree = null;
CommonTree char_literal12_tree = null;
RewriteRuleTokenStream stream_30 = new RewriteRuleTokenStream(adaptor, "token 30");
RewriteRuleTokenStream stream_28 = new RewriteRuleTokenStream(adaptor, "token 28");
RewriteRuleTokenStream stream_29 = new RewriteRuleTokenStream(adaptor, "token 29");
RewriteRuleSubtreeStream stream_nested = new RewriteRuleSubtreeStream(adaptor, "rule nested");
RewriteRuleSubtreeStream stream_nest = new RewriteRuleSubtreeStream(adaptor, "rule nest");
RewriteRuleSubtreeStream stream_properties = new RewriteRuleSubtreeStream(adaptor, "rule properties");
try {
// /home/langera/dev/freud/src/grammar/Css.g:49:3: ( '@' nest '{' ( properties )? ( nested )* '}' -> ^( NESTED nest ( properties )* ( nested )* ) )
// /home/langera/dev/freud/src/grammar/Css.g:49:5: '@' nest '{' ( properties )? ( nested )* '}'
{
char_literal7 = (Token) match(input, 28, FOLLOW_28_in_nested183);
stream_28.add(char_literal7);
pushFollow(FOLLOW_nest_in_nested185);
nest8 = nest();
state._fsp--;
stream_nest.add(nest8.getTree());
char_literal9 = (Token) match(input, 29, FOLLOW_29_in_nested187);
stream_29.add(char_literal9);
// /home/langera/dev/freud/src/grammar/Css.g:49:18: ( properties )?
int alt4 = 2;
int LA4_0 = input.LA(1);
if ((LA4_0 == IDENT)) {
alt4 = 1;
}
switch(alt4) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:49:18: properties
{
pushFollow(FOLLOW_properties_in_nested189);
properties10 = properties();
state._fsp--;
stream_properties.add(properties10.getTree());
}
break;
}
// /home/langera/dev/freud/src/grammar/Css.g:49:30: ( nested )*
loop5: do {
int alt5 = 2;
int LA5_0 = input.LA(1);
if ((LA5_0 == 28)) {
alt5 = 1;
}
switch(alt5) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:49:30: nested
{
pushFollow(FOLLOW_nested_in_nested192);
nested11 = nested();
state._fsp--;
stream_nested.add(nested11.getTree());
}
break;
default:
break loop5;
}
} while (true);
char_literal12 = (Token) match(input, 30, FOLLOW_30_in_nested195);
stream_30.add(char_literal12);
// AST REWRITE
// elements: nested, nest, properties
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 49:42: -> ^( NESTED nest ( properties )* ( nested )* )
{
// /home/langera/dev/freud/src/grammar/Css.g:49:45: ^( NESTED nest ( properties )* ( nested )* )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(NESTED, "NESTED"), root_1);
adaptor.addChild(root_1, stream_nest.nextTree());
// /home/langera/dev/freud/src/grammar/Css.g:49:60: ( properties )*
while (stream_properties.hasNext()) {
adaptor.addChild(root_1, stream_properties.nextTree());
}
stream_properties.reset();
// /home/langera/dev/freud/src/grammar/Css.g:49:72: ( nested )*
while (stream_nested.hasNext()) {
adaptor.addChild(root_1, stream_nested.nextTree());
}
stream_nested.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class CssParser method ruleset.
// $ANTLR start "ruleset"
// /home/langera/dev/freud/src/grammar/Css.g:56:1: ruleset : selectors '{' ( properties )? '}' -> ^( RULE selectors ( properties )* ) ;
public final CssParser.ruleset_return ruleset() throws RecognitionException {
CssParser.ruleset_return retval = new CssParser.ruleset_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal17 = null;
Token char_literal19 = null;
CssParser.selectors_return selectors16 = null;
CssParser.properties_return properties18 = null;
CommonTree char_literal17_tree = null;
CommonTree char_literal19_tree = null;
RewriteRuleTokenStream stream_30 = new RewriteRuleTokenStream(adaptor, "token 30");
RewriteRuleTokenStream stream_29 = new RewriteRuleTokenStream(adaptor, "token 29");
RewriteRuleSubtreeStream stream_selectors = new RewriteRuleSubtreeStream(adaptor, "rule selectors");
RewriteRuleSubtreeStream stream_properties = new RewriteRuleSubtreeStream(adaptor, "rule properties");
try {
// /home/langera/dev/freud/src/grammar/Css.g:57:3: ( selectors '{' ( properties )? '}' -> ^( RULE selectors ( properties )* ) )
// /home/langera/dev/freud/src/grammar/Css.g:57:5: selectors '{' ( properties )? '}'
{
pushFollow(FOLLOW_selectors_in_ruleset257);
selectors16 = selectors();
state._fsp--;
stream_selectors.add(selectors16.getTree());
char_literal17 = (Token) match(input, 29, FOLLOW_29_in_ruleset259);
stream_29.add(char_literal17);
// /home/langera/dev/freud/src/grammar/Css.g:57:19: ( properties )?
int alt8 = 2;
int LA8_0 = input.LA(1);
if ((LA8_0 == IDENT)) {
alt8 = 1;
}
switch(alt8) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:57:19: properties
{
pushFollow(FOLLOW_properties_in_ruleset261);
properties18 = properties();
state._fsp--;
stream_properties.add(properties18.getTree());
}
break;
}
char_literal19 = (Token) match(input, 30, FOLLOW_30_in_ruleset264);
stream_30.add(char_literal19);
// AST REWRITE
// elements: selectors, properties
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 57:35: -> ^( RULE selectors ( properties )* )
{
// /home/langera/dev/freud/src/grammar/Css.g:57:38: ^( RULE selectors ( properties )* )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(RULE, "RULE"), root_1);
adaptor.addChild(root_1, stream_selectors.nextTree());
// /home/langera/dev/freud/src/grammar/Css.g:57:56: ( properties )*
while (stream_properties.hasNext()) {
adaptor.addChild(root_1, stream_properties.nextTree());
}
stream_properties.reset();
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class CssParser method expr.
// $ANTLR start "expr"
// /home/langera/dev/freud/src/grammar/Css.g:111:1: expr : ( ( IDENT unit ) | IDENT | '#' IDENT -> ^( COLOUR '#' IDENT ) | '.' IDENT | function );
public final CssParser.expr_return expr() throws RecognitionException {
CssParser.expr_return retval = new CssParser.expr_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token IDENT60 = null;
Token IDENT62 = null;
Token char_literal63 = null;
Token IDENT64 = null;
Token char_literal65 = null;
Token IDENT66 = null;
CssParser.unit_return unit61 = null;
CssParser.function_return function67 = null;
CommonTree IDENT60_tree = null;
CommonTree IDENT62_tree = null;
CommonTree char_literal63_tree = null;
CommonTree IDENT64_tree = null;
CommonTree char_literal65_tree = null;
CommonTree IDENT66_tree = null;
RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
RewriteRuleTokenStream stream_36 = new RewriteRuleTokenStream(adaptor, "token 36");
try {
// /home/langera/dev/freud/src/grammar/Css.g:112:2: ( ( IDENT unit ) | IDENT | '#' IDENT -> ^( COLOUR '#' IDENT ) | '.' IDENT | function )
int alt25 = 5;
alt25 = dfa25.predict(input);
switch(alt25) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:112:4: ( IDENT unit )
{
root_0 = (CommonTree) adaptor.nil();
// /home/langera/dev/freud/src/grammar/Css.g:112:4: ( IDENT unit )
// /home/langera/dev/freud/src/grammar/Css.g:112:5: IDENT unit
{
IDENT60 = (Token) match(input, IDENT, FOLLOW_IDENT_in_expr670);
IDENT60_tree = (CommonTree) adaptor.create(IDENT60);
adaptor.addChild(root_0, IDENT60_tree);
pushFollow(FOLLOW_unit_in_expr672);
unit61 = unit();
state._fsp--;
adaptor.addChild(root_0, unit61.getTree());
}
}
break;
case 2:
// /home/langera/dev/freud/src/grammar/Css.g:113:4: IDENT
{
root_0 = (CommonTree) adaptor.nil();
IDENT62 = (Token) match(input, IDENT, FOLLOW_IDENT_in_expr678);
IDENT62_tree = (CommonTree) adaptor.create(IDENT62);
adaptor.addChild(root_0, IDENT62_tree);
}
break;
case 3:
// /home/langera/dev/freud/src/grammar/Css.g:114:4: '#' IDENT
{
char_literal63 = (Token) match(input, 36, FOLLOW_36_in_expr683);
stream_36.add(char_literal63);
IDENT64 = (Token) match(input, IDENT, FOLLOW_IDENT_in_expr685);
stream_IDENT.add(IDENT64);
// AST REWRITE
// elements: 36, IDENT
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 114:14: -> ^( COLOUR '#' IDENT )
{
// /home/langera/dev/freud/src/grammar/Css.g:114:17: ^( COLOUR '#' IDENT )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(COLOUR, "COLOUR"), root_1);
adaptor.addChild(root_1, stream_36.nextNode());
adaptor.addChild(root_1, stream_IDENT.nextNode());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
break;
case 4:
// /home/langera/dev/freud/src/grammar/Css.g:115:4: '.' IDENT
{
root_0 = (CommonTree) adaptor.nil();
char_literal65 = (Token) match(input, 37, FOLLOW_37_in_expr702);
char_literal65_tree = (CommonTree) adaptor.create(char_literal65);
adaptor.addChild(root_0, char_literal65_tree);
IDENT66 = (Token) match(input, IDENT, FOLLOW_IDENT_in_expr704);
IDENT66_tree = (CommonTree) adaptor.create(IDENT66);
adaptor.addChild(root_0, IDENT66_tree);
}
break;
case 5:
// /home/langera/dev/freud/src/grammar/Css.g:116:4: function
{
root_0 = (CommonTree) adaptor.nil();
pushFollow(FOLLOW_function_in_expr709);
function67 = function();
state._fsp--;
adaptor.addChild(root_0, function67.getTree());
}
break;
}
retval.stop = input.LT(-1);
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class CssParser method selectop.
// $ANTLR start "selectop"
// /home/langera/dev/freud/src/grammar/Css.g:72:1: selectop : ( '>' -> CHILD | '+' -> ADJACENT_SIBLING );
public final CssParser.selectop_return selectop() throws RecognitionException {
CssParser.selectop_return retval = new CssParser.selectop_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal29 = null;
Token char_literal30 = null;
CommonTree char_literal29_tree = null;
CommonTree char_literal30_tree = null;
RewriteRuleTokenStream stream_32 = new RewriteRuleTokenStream(adaptor, "token 32");
RewriteRuleTokenStream stream_33 = new RewriteRuleTokenStream(adaptor, "token 33");
try {
// /home/langera/dev/freud/src/grammar/Css.g:73:2: ( '>' -> CHILD | '+' -> ADJACENT_SIBLING )
int alt14 = 2;
int LA14_0 = input.LA(1);
if ((LA14_0 == 32)) {
alt14 = 1;
} else if ((LA14_0 == 33)) {
alt14 = 2;
} else {
NoViableAltException nvae = new NoViableAltException("", 14, 0, input);
throw nvae;
}
switch(alt14) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:73:4: '>'
{
char_literal29 = (Token) match(input, 32, FOLLOW_32_in_selectop363);
stream_32.add(char_literal29);
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 73:8: -> CHILD
{
adaptor.addChild(root_0, (CommonTree) adaptor.create(CHILD, "CHILD"));
}
retval.tree = root_0;
}
break;
case 2:
// /home/langera/dev/freud/src/grammar/Css.g:74:11: '+'
{
char_literal30 = (Token) match(input, 33, FOLLOW_33_in_selectop379);
stream_33.add(char_literal30);
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 74:16: -> ADJACENT_SIBLING
{
adaptor.addChild(root_0, (CommonTree) adaptor.create(ADJACENT_SIBLING, "ADJACENT_SIBLING"));
}
retval.tree = root_0;
}
break;
}
retval.stop = input.LT(-1);
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
}
return retval;
}
use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.
the class CssParser method declaration.
// $ANTLR start "declaration"
// /home/langera/dev/freud/src/grammar/Css.g:103:1: declaration : IDENT ':' args -> ^( PROPERTY IDENT args ) ;
public final CssParser.declaration_return declaration() throws RecognitionException {
CssParser.declaration_return retval = new CssParser.declaration_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token IDENT54 = null;
Token char_literal55 = null;
CssParser.args_return args56 = null;
CommonTree IDENT54_tree = null;
CommonTree char_literal55_tree = null;
RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
RewriteRuleTokenStream stream_38 = new RewriteRuleTokenStream(adaptor, "token 38");
RewriteRuleSubtreeStream stream_args = new RewriteRuleSubtreeStream(adaptor, "rule args");
try {
// /home/langera/dev/freud/src/grammar/Css.g:104:2: ( IDENT ':' args -> ^( PROPERTY IDENT args ) )
// /home/langera/dev/freud/src/grammar/Css.g:104:4: IDENT ':' args
{
IDENT54 = (Token) match(input, IDENT, FOLLOW_IDENT_in_declaration618);
stream_IDENT.add(IDENT54);
char_literal55 = (Token) match(input, 38, FOLLOW_38_in_declaration620);
stream_38.add(char_literal55);
pushFollow(FOLLOW_args_in_declaration622);
args56 = args();
state._fsp--;
stream_args.add(args56.getTree());
// AST REWRITE
// elements: IDENT, args
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.tree = root_0;
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
root_0 = (CommonTree) adaptor.nil();
// 104:19: -> ^( PROPERTY IDENT args )
{
// /home/langera/dev/freud/src/grammar/Css.g:104:22: ^( PROPERTY IDENT args )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(PROPERTY, "PROPERTY"), root_1);
adaptor.addChild(root_1, stream_IDENT.nextNode());
adaptor.addChild(root_1, stream_args.nextTree());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
retval.stop = input.LT(-1);
retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
} catch (RecognitionException re) {
reportError(re);
recover(input, re);
retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
} finally {
}
return retval;
}
Aggregations