public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp) { this.label = label; this.element = element; // compute general case for label type if ( element.getFirstDescendantWithType(tokenTypeForTokens)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.TOKEN_LABEL; else type = LabelType.TOKEN_LIST_LABEL; } else if ( element.getFirstDescendantWithType(ANTLRParser.RULE_REF)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.RULE_LABEL; else type = LabelType.RULE_LIST_LABEL; } // now reset if lexer and string if ( g.isLexer() ) { if ( element.getFirstDescendantWithType(ANTLRParser.STRING_LITERAL)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.LEXER_STRING_LABEL; } } }
public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp) { this.label = label; this.element = element; // compute general case for label type if ( element.getFirstDescendantWithType(tokenTypeForTokens)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.TOKEN_LABEL; else type = LabelType.TOKEN_LIST_LABEL; } else if ( element.getFirstDescendantWithType(ANTLRParser.RULE_REF)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.RULE_LABEL; else type = LabelType.RULE_LIST_LABEL; } // now reset if lexer and string if ( g.isLexer() ) { if ( element.getFirstDescendantWithType(ANTLRParser.STRING_LITERAL)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.LEXER_STRING_LABEL; } } }
public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp) { this.label = label; this.element = element; // compute general case for label type if ( element.getFirstDescendantWithType(tokenTypeForTokens)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.TOKEN_LABEL; else type = LabelType.TOKEN_LIST_LABEL; } else if ( element.getFirstDescendantWithType(ANTLRParser.RULE_REF)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.RULE_LABEL; else type = LabelType.RULE_LIST_LABEL; } // now reset if lexer and string if ( g.isLexer() ) { if ( element.getFirstDescendantWithType(ANTLRParser.STRING_LITERAL)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.LEXER_STRING_LABEL; } } }
public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp) { this.label = label; this.element = element; // compute general case for label type if ( element.getFirstDescendantWithType(tokenTypeForTokens)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.TOKEN_LABEL; else type = LabelType.TOKEN_LIST_LABEL; } else if ( element.getFirstDescendantWithType(ANTLRParser.RULE_REF)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.RULE_LABEL; else type = LabelType.RULE_LIST_LABEL; } // now reset if lexer and string if ( g.isLexer() ) { if ( element.getFirstDescendantWithType(ANTLRParser.STRING_LITERAL)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.LEXER_STRING_LABEL; } } }
public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp) { this.label = label; this.element = element; // compute general case for label type if ( element.getFirstDescendantWithType(tokenTypeForTokens)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.TOKEN_LABEL; else type = LabelType.TOKEN_LIST_LABEL; } else if ( element.getFirstDescendantWithType(ANTLRParser.RULE_REF)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.RULE_LABEL; else type = LabelType.RULE_LIST_LABEL; } // now reset if lexer and string if ( g.isLexer() ) { if ( element.getFirstDescendantWithType(ANTLRParser.STRING_LITERAL)!=null ) { if ( labelOp==ANTLRParser.ASSIGN ) type = LabelType.LEXER_STRING_LABEL; } } }
public CommonTree getFirstDescendantWithType(int type) { if ( getType()==type ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( t.getType()==type ) return t; CommonTree d = t.getFirstDescendantWithType(type); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(int type) { if ( getType()==type ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( t.getType()==type ) return t; CommonTree d = t.getFirstDescendantWithType(type); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(int type) { if ( getType()==type ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( t.getType()==type ) return t; CommonTree d = t.getFirstDescendantWithType(type); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(int type) { if ( getType()==type ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( t.getType()==type ) return t; CommonTree d = t.getFirstDescendantWithType(type); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(int type) { if ( getType()==type ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( t.getType()==type ) return t; CommonTree d = t.getFirstDescendantWithType(type); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(org.antlr.runtime.BitSet types) { if ( types.member(getType()) ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( types.member(t.getType()) ) return t; CommonTree d = t.getFirstDescendantWithType(types); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(org.antlr.runtime.BitSet types) { if ( types.member(getType()) ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( types.member(t.getType()) ) return t; CommonTree d = t.getFirstDescendantWithType(types); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(org.antlr.runtime.BitSet types) { if ( types.member(getType()) ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( types.member(t.getType()) ) return t; CommonTree d = t.getFirstDescendantWithType(types); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(org.antlr.runtime.BitSet types) { if ( types.member(getType()) ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( types.member(t.getType()) ) return t; CommonTree d = t.getFirstDescendantWithType(types); if ( d!=null ) return d; } return null; }
public CommonTree getFirstDescendantWithType(org.antlr.runtime.BitSet types) { if ( types.member(getType()) ) return this; if ( children==null ) return null; for (Object c : children) { GrammarAST t = (GrammarAST)c; if ( types.member(t.getType()) ) return t; CommonTree d = t.getFirstDescendantWithType(types); if ( d!=null ) return d; } return null; }
boolean hasTypeOrMoreCommand(Rule r) { GrammarAST ast = r.ast; if (ast == null) { return false; } GrammarAST altActionAst = (GrammarAST)ast.getFirstDescendantWithType(ANTLRParser.LEXER_ALT_ACTION); if (altActionAst == null) { // the rule isn't followed by any commands return false; } // first child is the alt itself, subsequent are the actions for (int i = 1; i < altActionAst.getChildCount(); i++) { GrammarAST node = (GrammarAST)altActionAst.getChild(i); if (node.getType() == ANTLRParser.LEXER_ACTION_CALL) { if ("type".equals(node.getChild(0).getText())) { return true; } } else if ("more".equals(node.getText())) { return true; } } return false; }
boolean hasTypeOrMoreCommand(Rule r) { GrammarAST ast = r.ast; if (ast == null) { return false; } GrammarAST altActionAst = (GrammarAST)ast.getFirstDescendantWithType(ANTLRParser.LEXER_ALT_ACTION); if (altActionAst == null) { // the rule isn't followed by any commands return false; } // first child is the alt itself, subsequent are the actions for (int i = 1; i < altActionAst.getChildCount(); i++) { GrammarAST node = (GrammarAST)altActionAst.getChild(i); if (node.getType() == ANTLRParser.LEXER_ACTION_CALL) { if ("type".equals(node.getChild(0).getText())) { return true; } } else if ("more".equals(node.getText())) { return true; } } return false; }
boolean hasTypeOrMoreCommand(Rule r) { GrammarAST ast = r.ast; if (ast == null) { return false; } GrammarAST altActionAst = (GrammarAST)ast.getFirstDescendantWithType(ANTLRParser.LEXER_ALT_ACTION); if (altActionAst == null) { // the rule isn't followed by any commands return false; } // first child is the alt itself, subsequent are the actions for (int i = 1; i < altActionAst.getChildCount(); i++) { GrammarAST node = (GrammarAST)altActionAst.getChild(i); if (node.getType() == ANTLRParser.LEXER_ACTION_CALL) { if ("type".equals(node.getChild(0).getText())) { return true; } } else if ("more".equals(node.getText())) { return true; } } return false; }
boolean hasTypeOrMoreCommand(Rule r) { GrammarAST ast = r.ast; if (ast == null) { return false; } GrammarAST altActionAst = (GrammarAST)ast.getFirstDescendantWithType(ANTLRParser.LEXER_ALT_ACTION); if (altActionAst == null) { // the rule isn't followed by any commands return false; } // first child is the alt itself, subsequent are the actions for (int i = 1; i < altActionAst.getChildCount(); i++) { GrammarAST node = (GrammarAST)altActionAst.getChild(i); if (node.getType() == ANTLRParser.LEXER_ACTION_CALL) { if ("type".equals(node.getChild(0).getText())) { return true; } } else if ("more".equals(node.getText())) { return true; } } return false; }
boolean hasTypeOrMoreCommand(@NotNull Rule r) { GrammarAST ast = r.ast; if (ast == null) { return false; } GrammarAST altActionAst = (GrammarAST)ast.getFirstDescendantWithType(ANTLRParser.LEXER_ALT_ACTION); if (altActionAst == null) { // the rule isn't followed by any commands return false; } // first child is the alt itself, subsequent are the actions for (int i = 1; i < altActionAst.getChildCount(); i++) { GrammarAST node = (GrammarAST)altActionAst.getChild(i); if (node.getType() == ANTLRParser.LEXER_ACTION_CALL) { if ("type".equals(node.getChild(0).getText())) { return true; } } else if ("more".equals(node.getText())) { return true; } } return false; }