use of org.antlr.runtime.tree.RewriteRuleSubtreeStream in project freud by LMAX-Exchange.
the class CssParser method importRule.
// $ANTLR start "importRule"
// /home/langera/dev/freud/src/grammar/Css.g:44:1: importRule : ( '@import' | '@include' ) IDENT -> ^( IMPORT IDENT ) ;
public final CssParser.importRule_return importRule() throws RecognitionException {
CssParser.importRule_return retval = new CssParser.importRule_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token string_literal4 = null;
Token string_literal5 = null;
Token IDENT6 = null;
CommonTree string_literal4_tree = null;
CommonTree string_literal5_tree = null;
CommonTree IDENT6_tree = null;
RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
RewriteRuleTokenStream stream_26 = new RewriteRuleTokenStream(adaptor, "token 26");
RewriteRuleTokenStream stream_27 = new RewriteRuleTokenStream(adaptor, "token 27");
try {
// /home/langera/dev/freud/src/grammar/Css.g:45:2: ( ( '@import' | '@include' ) IDENT -> ^( IMPORT IDENT ) )
// /home/langera/dev/freud/src/grammar/Css.g:45:4: ( '@import' | '@include' ) IDENT
{
// /home/langera/dev/freud/src/grammar/Css.g:45:4: ( '@import' | '@include' )
int alt3 = 2;
int LA3_0 = input.LA(1);
if ((LA3_0 == 26)) {
alt3 = 1;
} else if ((LA3_0 == 27)) {
alt3 = 2;
} else {
NoViableAltException nvae = new NoViableAltException("", 3, 0, input);
throw nvae;
}
switch(alt3) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:45:5: '@import'
{
string_literal4 = (Token) match(input, 26, FOLLOW_26_in_importRule153);
stream_26.add(string_literal4);
}
break;
case 2:
// /home/langera/dev/freud/src/grammar/Css.g:45:17: '@include'
{
string_literal5 = (Token) match(input, 27, FOLLOW_27_in_importRule157);
stream_27.add(string_literal5);
}
break;
}
IDENT6 = (Token) match(input, IDENT, FOLLOW_IDENT_in_importRule161);
stream_IDENT.add(IDENT6);
// AST REWRITE
// elements: 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();
// 45:36: -> ^( IMPORT IDENT )
{
// /home/langera/dev/freud/src/grammar/Css.g:45:39: ^( IMPORT IDENT )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(IMPORT, "IMPORT"), root_1);
adaptor.addChild(root_1, stream_IDENT.nextNode());
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.RewriteRuleSubtreeStream in project freud by LMAX-Exchange.
the class CssParser method selectorOperation.
// $ANTLR start "selectorOperation"
// /home/langera/dev/freud/src/grammar/Css.g:68:1: selectorOperation : ( selectop )? elem -> ( selectop )* elem ;
public final CssParser.selectorOperation_return selectorOperation() throws RecognitionException {
CssParser.selectorOperation_return retval = new CssParser.selectorOperation_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
CssParser.selectop_return selectop27 = null;
CssParser.elem_return elem28 = null;
RewriteRuleSubtreeStream stream_elem = new RewriteRuleSubtreeStream(adaptor, "rule elem");
RewriteRuleSubtreeStream stream_selectop = new RewriteRuleSubtreeStream(adaptor, "rule selectop");
try {
// /home/langera/dev/freud/src/grammar/Css.g:69:2: ( ( selectop )? elem -> ( selectop )* elem )
// /home/langera/dev/freud/src/grammar/Css.g:69:4: ( selectop )? elem
{
// /home/langera/dev/freud/src/grammar/Css.g:69:4: ( selectop )?
int alt13 = 2;
int LA13_0 = input.LA(1);
if (((LA13_0 >= 32 && LA13_0 <= 33))) {
alt13 = 1;
}
switch(alt13) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:69:4: selectop
{
pushFollow(FOLLOW_selectop_in_selectorOperation342);
selectop27 = selectop();
state._fsp--;
stream_selectop.add(selectop27.getTree());
}
break;
}
pushFollow(FOLLOW_elem_in_selectorOperation345);
elem28 = elem();
state._fsp--;
stream_elem.add(elem28.getTree());
// AST REWRITE
// elements: selectop, elem
// 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();
// 69:19: -> ( selectop )* elem
{
// /home/langera/dev/freud/src/grammar/Css.g:69:22: ( selectop )*
while (stream_selectop.hasNext()) {
adaptor.addChild(root_0, stream_selectop.nextTree());
}
stream_selectop.reset();
adaptor.addChild(root_0, stream_elem.nextTree());
}
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.RewriteRuleSubtreeStream 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.RewriteRuleSubtreeStream 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.RewriteRuleSubtreeStream 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;
}
Aggregations