use of org.antlr.runtime.tree.CommonTree in project freud by LMAX-Exchange.
the class CssParser method elem.
// $ANTLR start "elem"
// /home/langera/dev/freud/src/grammar/Css.g:81:1: elem : ( '*' -> ^( UNIVERSAL ) | '#' IDENT -> ^( ID IDENT ) | '.' IDENT -> ^( CLASS IDENT ) | IDENT -> ^( TAG IDENT ) );
public final CssParser.elem_return elem() throws RecognitionException {
CssParser.elem_return retval = new CssParser.elem_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal34 = null;
Token char_literal35 = null;
Token IDENT36 = null;
Token char_literal37 = null;
Token IDENT38 = null;
Token IDENT39 = null;
CommonTree char_literal34_tree = null;
CommonTree char_literal35_tree = null;
CommonTree IDENT36_tree = null;
CommonTree char_literal37_tree = null;
CommonTree IDENT38_tree = null;
CommonTree IDENT39_tree = null;
RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
RewriteRuleTokenStream stream_35 = new RewriteRuleTokenStream(adaptor, "token 35");
RewriteRuleTokenStream stream_36 = new RewriteRuleTokenStream(adaptor, "token 36");
RewriteRuleTokenStream stream_37 = new RewriteRuleTokenStream(adaptor, "token 37");
try {
// /home/langera/dev/freud/src/grammar/Css.g:82:2: ( '*' -> ^( UNIVERSAL ) | '#' IDENT -> ^( ID IDENT ) | '.' IDENT -> ^( CLASS IDENT ) | IDENT -> ^( TAG IDENT ) )
int alt17 = 4;
switch(input.LA(1)) {
case 35:
{
alt17 = 1;
}
break;
case 36:
{
alt17 = 2;
}
break;
case 37:
{
alt17 = 3;
}
break;
case IDENT:
{
alt17 = 4;
}
break;
default:
NoViableAltException nvae = new NoViableAltException("", 17, 0, input);
throw nvae;
}
switch(alt17) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:82:4: '*'
{
char_literal34 = (Token) match(input, 35, FOLLOW_35_in_elem421);
stream_35.add(char_literal34);
// 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();
// 82:8: -> ^( UNIVERSAL )
{
// /home/langera/dev/freud/src/grammar/Css.g:82:11: ^( UNIVERSAL )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(UNIVERSAL, "UNIVERSAL"), root_1);
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
break;
case 2:
// /home/langera/dev/freud/src/grammar/Css.g:83:4: '#' IDENT
{
char_literal35 = (Token) match(input, 36, FOLLOW_36_in_elem434);
stream_36.add(char_literal35);
IDENT36 = (Token) match(input, IDENT, FOLLOW_IDENT_in_elem436);
stream_IDENT.add(IDENT36);
// 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();
// 83:14: -> ^( ID IDENT )
{
// /home/langera/dev/freud/src/grammar/Css.g:83:17: ^( ID IDENT )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ID, "ID"), root_1);
adaptor.addChild(root_1, stream_IDENT.nextNode());
adaptor.addChild(root_0, root_1);
}
}
retval.tree = root_0;
}
break;
case 3:
// /home/langera/dev/freud/src/grammar/Css.g:84:4: '.' IDENT
{
char_literal37 = (Token) match(input, 37, FOLLOW_37_in_elem451);
stream_37.add(char_literal37);
IDENT38 = (Token) match(input, IDENT, FOLLOW_IDENT_in_elem453);
stream_IDENT.add(IDENT38);
// 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();
// 84:14: -> ^( CLASS IDENT )
{
// /home/langera/dev/freud/src/grammar/Css.g:84:17: ^( CLASS IDENT )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(CLASS, "CLASS"), root_1);
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:85:4: IDENT
{
IDENT39 = (Token) match(input, IDENT, FOLLOW_IDENT_in_elem471);
stream_IDENT.add(IDENT39);
// 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();
// 85:10: -> ^( TAG IDENT )
{
// /home/langera/dev/freud/src/grammar/Css.g:85:13: ^( TAG IDENT )
{
CommonTree root_1 = (CommonTree) adaptor.nil();
root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(TAG, "TAG"), root_1);
adaptor.addChild(root_1, stream_IDENT.nextNode());
adaptor.addChild(root_0, root_1);
}
}
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.CommonTree in project freud by LMAX-Exchange.
the class CssParser method selectors.
// $ANTLR start "selectors"
// /home/langera/dev/freud/src/grammar/Css.g:60:1: selectors : selector ( ',' selector )* ;
public final CssParser.selectors_return selectors() throws RecognitionException {
CssParser.selectors_return retval = new CssParser.selectors_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal21 = null;
CssParser.selector_return selector20 = null;
CssParser.selector_return selector22 = null;
CommonTree char_literal21_tree = null;
try {
// /home/langera/dev/freud/src/grammar/Css.g:61:2: ( selector ( ',' selector )* )
// /home/langera/dev/freud/src/grammar/Css.g:61:4: selector ( ',' selector )*
{
root_0 = (CommonTree) adaptor.nil();
pushFollow(FOLLOW_selector_in_selectors289);
selector20 = selector();
state._fsp--;
adaptor.addChild(root_0, selector20.getTree());
// /home/langera/dev/freud/src/grammar/Css.g:61:13: ( ',' selector )*
loop9: do {
int alt9 = 2;
int LA9_0 = input.LA(1);
if ((LA9_0 == 31)) {
alt9 = 1;
}
switch(alt9) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:61:14: ',' selector
{
char_literal21 = (Token) match(input, 31, FOLLOW_31_in_selectors292);
char_literal21_tree = (CommonTree) adaptor.create(char_literal21);
adaptor.addChild(root_0, char_literal21_tree);
pushFollow(FOLLOW_selector_in_selectors294);
selector22 = selector();
state._fsp--;
adaptor.addChild(root_0, selector22.getTree());
}
break;
default:
break loop9;
}
} while (true);
}
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.CommonTree in project freud by LMAX-Exchange.
the class CssParser method selector.
// $ANTLR start "selector"
// /home/langera/dev/freud/src/grammar/Css.g:64:1: selector : elem ( selectorOperation )* ( attrib )* ( pseudo )? -> elem ( selectorOperation )* ( attrib )* ( pseudo )* ;
public final CssParser.selector_return selector() throws RecognitionException {
CssParser.selector_return retval = new CssParser.selector_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
CssParser.elem_return elem23 = null;
CssParser.selectorOperation_return selectorOperation24 = null;
CssParser.attrib_return attrib25 = null;
CssParser.pseudo_return pseudo26 = null;
RewriteRuleSubtreeStream stream_elem = new RewriteRuleSubtreeStream(adaptor, "rule elem");
RewriteRuleSubtreeStream stream_pseudo = new RewriteRuleSubtreeStream(adaptor, "rule pseudo");
RewriteRuleSubtreeStream stream_selectorOperation = new RewriteRuleSubtreeStream(adaptor, "rule selectorOperation");
RewriteRuleSubtreeStream stream_attrib = new RewriteRuleSubtreeStream(adaptor, "rule attrib");
try {
// /home/langera/dev/freud/src/grammar/Css.g:65:2: ( elem ( selectorOperation )* ( attrib )* ( pseudo )? -> elem ( selectorOperation )* ( attrib )* ( pseudo )* )
// /home/langera/dev/freud/src/grammar/Css.g:65:4: elem ( selectorOperation )* ( attrib )* ( pseudo )?
{
pushFollow(FOLLOW_elem_in_selector308);
elem23 = elem();
state._fsp--;
stream_elem.add(elem23.getTree());
// /home/langera/dev/freud/src/grammar/Css.g:65:9: ( selectorOperation )*
loop10: do {
int alt10 = 2;
alt10 = dfa10.predict(input);
switch(alt10) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:65:9: selectorOperation
{
pushFollow(FOLLOW_selectorOperation_in_selector310);
selectorOperation24 = selectorOperation();
state._fsp--;
stream_selectorOperation.add(selectorOperation24.getTree());
}
break;
default:
break loop10;
}
} while (true);
// /home/langera/dev/freud/src/grammar/Css.g:65:28: ( attrib )*
loop11: do {
int alt11 = 2;
int LA11_0 = input.LA(1);
if ((LA11_0 == 40)) {
alt11 = 1;
}
switch(alt11) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:65:28: attrib
{
pushFollow(FOLLOW_attrib_in_selector313);
attrib25 = attrib();
state._fsp--;
stream_attrib.add(attrib25.getTree());
}
break;
default:
break loop11;
}
} while (true);
// /home/langera/dev/freud/src/grammar/Css.g:65:36: ( pseudo )?
int alt12 = 2;
int LA12_0 = input.LA(1);
if (((LA12_0 >= 38 && LA12_0 <= 39))) {
alt12 = 1;
}
switch(alt12) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:65:36: pseudo
{
pushFollow(FOLLOW_pseudo_in_selector316);
pseudo26 = pseudo();
state._fsp--;
stream_pseudo.add(pseudo26.getTree());
}
break;
}
// AST REWRITE
// elements: elem, pseudo, attrib, selectorOperation
// 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();
// 65:44: -> elem ( selectorOperation )* ( attrib )* ( pseudo )*
{
adaptor.addChild(root_0, stream_elem.nextTree());
// /home/langera/dev/freud/src/grammar/Css.g:65:53: ( selectorOperation )*
while (stream_selectorOperation.hasNext()) {
adaptor.addChild(root_0, stream_selectorOperation.nextTree());
}
stream_selectorOperation.reset();
// /home/langera/dev/freud/src/grammar/Css.g:65:72: ( attrib )*
while (stream_attrib.hasNext()) {
adaptor.addChild(root_0, stream_attrib.nextTree());
}
stream_attrib.reset();
// /home/langera/dev/freud/src/grammar/Css.g:65:80: ( pseudo )*
while (stream_pseudo.hasNext()) {
adaptor.addChild(root_0, stream_pseudo.nextTree());
}
stream_pseudo.reset();
}
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.CommonTree in project freud by LMAX-Exchange.
the class CssParser method properties.
// $ANTLR start "properties"
// /home/langera/dev/freud/src/grammar/Css.g:77:1: properties : declaration ( ';' ( declaration )? )* -> ( declaration )+ ;
public final CssParser.properties_return properties() throws RecognitionException {
CssParser.properties_return retval = new CssParser.properties_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal32 = null;
CssParser.declaration_return declaration31 = null;
CssParser.declaration_return declaration33 = null;
CommonTree char_literal32_tree = null;
RewriteRuleTokenStream stream_34 = new RewriteRuleTokenStream(adaptor, "token 34");
RewriteRuleSubtreeStream stream_declaration = new RewriteRuleSubtreeStream(adaptor, "rule declaration");
try {
// /home/langera/dev/freud/src/grammar/Css.g:78:2: ( declaration ( ';' ( declaration )? )* -> ( declaration )+ )
// /home/langera/dev/freud/src/grammar/Css.g:78:4: declaration ( ';' ( declaration )? )*
{
pushFollow(FOLLOW_declaration_in_properties395);
declaration31 = declaration();
state._fsp--;
stream_declaration.add(declaration31.getTree());
// /home/langera/dev/freud/src/grammar/Css.g:78:16: ( ';' ( declaration )? )*
loop16: do {
int alt16 = 2;
int LA16_0 = input.LA(1);
if ((LA16_0 == 34)) {
alt16 = 1;
}
switch(alt16) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:78:17: ';' ( declaration )?
{
char_literal32 = (Token) match(input, 34, FOLLOW_34_in_properties398);
stream_34.add(char_literal32);
// /home/langera/dev/freud/src/grammar/Css.g:78:21: ( declaration )?
int alt15 = 2;
int LA15_0 = input.LA(1);
if ((LA15_0 == IDENT)) {
alt15 = 1;
}
switch(alt15) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:78:21: declaration
{
pushFollow(FOLLOW_declaration_in_properties400);
declaration33 = declaration();
state._fsp--;
stream_declaration.add(declaration33.getTree());
}
break;
}
}
break;
default:
break loop16;
}
} while (true);
// AST REWRITE
// elements: declaration
// 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();
// 78:36: -> ( declaration )+
{
if (!(stream_declaration.hasNext())) {
throw new RewriteEarlyExitException();
}
while (stream_declaration.hasNext()) {
adaptor.addChild(root_0, stream_declaration.nextTree());
}
stream_declaration.reset();
}
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.CommonTree in project freud by LMAX-Exchange.
the class CssParser method args.
// $ANTLR start "args"
// /home/langera/dev/freud/src/grammar/Css.g:107:1: args : expr ( ( ',' )? expr )* -> ( expr )* ;
public final CssParser.args_return args() throws RecognitionException {
CssParser.args_return retval = new CssParser.args_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token char_literal58 = null;
CssParser.expr_return expr57 = null;
CssParser.expr_return expr59 = null;
CommonTree char_literal58_tree = null;
RewriteRuleTokenStream stream_31 = new RewriteRuleTokenStream(adaptor, "token 31");
RewriteRuleSubtreeStream stream_expr = new RewriteRuleSubtreeStream(adaptor, "rule expr");
try {
// /home/langera/dev/freud/src/grammar/Css.g:108:2: ( expr ( ( ',' )? expr )* -> ( expr )* )
// /home/langera/dev/freud/src/grammar/Css.g:108:4: expr ( ( ',' )? expr )*
{
pushFollow(FOLLOW_expr_in_args645);
expr57 = expr();
state._fsp--;
stream_expr.add(expr57.getTree());
// /home/langera/dev/freud/src/grammar/Css.g:108:9: ( ( ',' )? expr )*
loop24: do {
int alt24 = 2;
int LA24_0 = input.LA(1);
if ((LA24_0 == IDENT || LA24_0 == 31 || (LA24_0 >= 36 && LA24_0 <= 37))) {
alt24 = 1;
}
switch(alt24) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:108:10: ( ',' )? expr
{
// /home/langera/dev/freud/src/grammar/Css.g:108:10: ( ',' )?
int alt23 = 2;
int LA23_0 = input.LA(1);
if ((LA23_0 == 31)) {
alt23 = 1;
}
switch(alt23) {
case 1:
// /home/langera/dev/freud/src/grammar/Css.g:108:10: ','
{
char_literal58 = (Token) match(input, 31, FOLLOW_31_in_args648);
stream_31.add(char_literal58);
}
break;
}
pushFollow(FOLLOW_expr_in_args651);
expr59 = expr();
state._fsp--;
stream_expr.add(expr59.getTree());
}
break;
default:
break loop24;
}
} while (true);
// AST REWRITE
// elements: expr
// 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();
// 108:22: -> ( expr )*
{
// /home/langera/dev/freud/src/grammar/Css.g:108:25: ( expr )*
while (stream_expr.hasNext()) {
adaptor.addChild(root_0, stream_expr.nextTree());
}
stream_expr.reset();
}
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