congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GrammarAST.getFirstDescendantWithType
Code IndexAdd Tabnine to your IDE (free)

How to use
getFirstDescendantWithType
method
in
org.antlr.v4.tool.ast.GrammarAST

Best Java code snippets using org.antlr.v4.tool.ast.GrammarAST.getFirstDescendantWithType (Showing top 20 results out of 315)

origin: com.tunnelvisionlabs/antlr4

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;
    }
  }
}
origin: org.antlr/antlr4

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;
    }
  }
}
origin: uk.co.nichesolutions/antlr4

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;
    }
  }
}
origin: io.virtdata/virtdata-lib-realer

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;
    }
  }
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

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;
    }
  }
}
origin: uk.co.nichesolutions/antlr4

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;
}
origin: org.antlr/antlr4

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;
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

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;
}
origin: io.virtdata/virtdata-lib-realer

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;
}
origin: com.tunnelvisionlabs/antlr4

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;
}
origin: org.antlr/antlr4

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;
}
origin: io.virtdata/virtdata-lib-realer

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;
}
origin: uk.co.nichesolutions/antlr4

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;
}
origin: com.tunnelvisionlabs/antlr4

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;
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

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;
}
origin: org.antlr/antlr4

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;
}
origin: io.virtdata/virtdata-lib-realer

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;
}
origin: uk.co.nichesolutions/antlr4

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;
}
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

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;
}
origin: com.tunnelvisionlabs/antlr4

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;
}
org.antlr.v4.tool.astGrammarASTgetFirstDescendantWithType

Popular methods of GrammarAST

  • getText
  • getToken
  • getAllChildrenWithType
  • getChild
  • getChildCount
  • getParent
  • <init>
  • addChild
  • addChildren
  • deleteChild
  • dupNode
  • freshenParentAndChildIndexes
  • dupNode,
  • freshenParentAndChildIndexes,
  • getAltLabel,
  • getAncestor,
  • getAncestors,
  • getCharPositionInLine,
  • getChildIndex,
  • getChildren,
  • getChildrenAsArray,
  • getFirstChildWithType

Popular in Java

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now