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

How to use
GrammarRootAST
in
org.antlr.v4.tool.ast

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

origin: com.github.julianthome/inmemantlr-api

  root.fileName = root.getGrammarName();
  String grammarName = root.getChild(0).getText();
for (String grammarName : sortedGrammarNames) {
  for (GrammarRootAST root : roots) {
    if (root.getGrammarName().equals(grammarName)) {
      LOGGER.debug("add to ast buffer {}", grammarName);
      ast.put(grammarName, root);
origin: org.antlr/antlr4

public void process() {
  GrammarRootAST root = g.ast;
  if ( root==null ) return;
  tool.log("grammar", "before: "+root.toStringTree());
  integrateImportedGrammars(g);
  reduceBlocksToSets(root);
  expandParameterizedLoops(root);
  tool.log("grammar", "after: "+root.toStringTree());
}
origin: com.tunnelvisionlabs/antlr4

  @Override
  public GrammarRootAST dupNode() { return new GrammarRootAST(this); }
}
origin: uk.co.nichesolutions/antlr4

GrammarAST[] elements = combinedAST.getChildren().toArray(new GrammarAST[0]);
String lexerName = combinedAST.getChild(0).getText()+"Lexer";
GrammarRootAST lexerAST =
  new GrammarRootAST(new CommonToken(ANTLRParser.GRAMMAR, "LEXER_GRAMMAR"), combinedGrammar.ast.tokenStream);
lexerAST.grammarType = ANTLRParser.LEXER;
lexerAST.token.setInputStream(combinedAST.token.getInputStream());
lexerAST.addChild((GrammarAST)adaptor.create(ANTLRParser.ID, lexerName));
  (GrammarAST)combinedAST.getFirstChildWithType(ANTLRParser.OPTIONS);
if ( optionsRoot!=null && optionsRoot.getChildCount()!=0 ) {
  GrammarAST lexerOptionsRoot = (GrammarAST)adaptor.dupNode(optionsRoot);
  lexerAST.addChild(lexerOptionsRoot);
  GrammarAST[] options = optionsRoot.getChildren().toArray(new GrammarAST[0]);
  for (GrammarAST o : options) {
      lexerAST.setOption(optionName, (GrammarAST)optionTree.getChild(1));
for (GrammarAST e : elements) {
  if ( e.getType()==ANTLRParser.AT ) {
    lexerAST.addChild((Tree)adaptor.dupTree(e));
    if ( e.getChild(0).getText().equals("lexer") ) {
      actionsWeMoved.add(e);
  combinedAST.deleteChild( r );
  (GrammarAST)combinedAST.getFirstChildWithType(ANTLRParser.RULES);
if ( combinedRulesRoot==null ) return lexerAST;
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

  GrammarAST imp_tokensRoot = (GrammarAST)imp.ast.getFirstChildWithType(ANTLRParser.TOKENS_SPEC);
  if ( imp_tokensRoot!=null ) {
    rootGrammar.tool.log("grammar", "imported tokens: "+imp_tokensRoot.getChildren());
  List<GrammarAST> imp_actionRoots = imp.ast.getAllChildrenWithType(ANTLRParser.AT);
  if ( actionRoots!=null ) all_actionRoots.addAll(actionRoots);
  all_actionRoots.addAll(imp_actionRoots);
  List<GrammarAST> rules = imp.ast.getNodesWithType(ANTLRParser.RULE);
  if ( rules!=null ) {
    for (GrammarAST r : rules) {
  GrammarAST optionsRoot = (GrammarAST)imp.ast.getFirstChildWithType(ANTLRParser.OPTIONS);
  if ( optionsRoot!=null ) {
    for (Map.Entry<String, GrammarAST> option : imp.ast.getOptions().entrySet()) {
      String importOption = imp.ast.getOptionString(option.getKey());
      if (importOption == null) {
        continue;
      String rootOption = rootGrammar.ast.getOptionString(option.getKey());
      if (!importOption.equals(rootOption)) {
        hasNewOption = true;
rootGrammar.tool.log("grammar", "Grammar: "+rootGrammar.ast.toStringTree());
origin: com.impetus.fabric/fabric-jdbc-driver-shaded

  new ArrayList<Pair<GrammarAST,GrammarAST>>();
List<GrammarAST> ruleNodes = ast.getNodesWithType(ANTLRParser.RULE);
if ( ruleNodes==null || ruleNodes.isEmpty() ) return null;
origin: org.antlr/antlr4

GrammarAST RULES = (GrammarAST)g.ast.getFirstChildWithType(ANTLRParser.RULES);
List<GrammarAST> rules = new ArrayList<GrammarAST>(RULES.getAllChildrenWithType(ANTLRParser.RULE));
for (GrammarAST mode : g.ast.getAllChildrenWithType(ANTLRParser.MODE)) {
  rules.addAll(mode.getAllChildrenWithType(ANTLRParser.RULE));
origin: uk.co.nichesolutions/antlr4

/** Manually get option node from tree; return null if no defined. */
public static GrammarAST findOptionValueAST(GrammarRootAST root, String option) {
  GrammarAST options = (GrammarAST)root.getFirstChildWithType(ANTLRParser.OPTIONS);
  if ( options!=null && options.getChildCount() > 0 ) {
    for (Object o : options.getChildren()) {
      GrammarAST c = (GrammarAST)o;
      if ( c.getType() == ANTLRParser.ASSIGN &&
         c.getChild(0).getText().equals(option) )
      {
        return (GrammarAST)c.getChild(1);
      }
    }
  }
  return null;
}
origin: org.antlr/antlr4

public String getGrammarName() {
  Tree t = getChild(0);
  if ( t!=null ) return t.getText();
  return null;
}
origin: com.github.julianthome/inmemantlr-api

/**
 * create code generation pipeline from grammar ast
 *
 * @param ast grammar ast
 * @return string code generation pipeline
 */
public StringCodeGenPipeline createPipeline(GrammarRootAST ast) {
  if (pip.containsKey(ast.getGrammarName()))
    pip.get(ast.getGrammarName());
  LOGGER.debug("create grammar {}", ast.getGrammarName());
  final Grammar g = createGrammar(ast);
  g.fileName = g.name;
  g.loadImportedGrammars();
  StringCodeGenPipeline spip = new StringCodeGenPipeline(g);
  LOGGER.debug("put grammar {}", g.name);
  pip.put(g.name, spip);
  return spip;
}
origin: org.antlr/antlr4-maven-plugin

  return;
for (GrammarAST importDecl : grammar.getAllChildrenWithType(ANTLRParser.IMPORT)) {
  for (Tree id: importDecl.getAllChildrenWithType(ANTLRParser.ID)) {
for (GrammarAST options : grammar.getAllChildrenWithType(ANTLRParser.OPTIONS)) {
  for (int i = 0, count = options.getChildCount(); i < count; i++) {
    Tree option = options.getChild(i);
origin: org.antlr/antlr4

GrammarAST[] elements = combinedAST.getChildren().toArray(new GrammarAST[0]);
String lexerName = combinedAST.getChild(0).getText()+"Lexer";
GrammarRootAST lexerAST =
  new GrammarRootAST(new CommonToken(ANTLRParser.GRAMMAR, "LEXER_GRAMMAR"), combinedGrammar.ast.tokenStream);
lexerAST.grammarType = ANTLRParser.LEXER;
lexerAST.token.setInputStream(combinedAST.token.getInputStream());
lexerAST.addChild((GrammarAST)adaptor.create(ANTLRParser.ID, lexerName));
  (GrammarAST)combinedAST.getFirstChildWithType(ANTLRParser.OPTIONS);
if ( optionsRoot!=null && optionsRoot.getChildCount()!=0 ) {
  GrammarAST lexerOptionsRoot = (GrammarAST)adaptor.dupNode(optionsRoot);
  lexerAST.addChild(lexerOptionsRoot);
  GrammarAST[] options = optionsRoot.getChildren().toArray(new GrammarAST[0]);
  for (GrammarAST o : options) {
      lexerAST.setOption(optionName, (GrammarAST)optionTree.getChild(1));
for (GrammarAST e : elements) {
  if ( e.getType()==ANTLRParser.AT ) {
    lexerAST.addChild((Tree)adaptor.dupTree(e));
    if ( e.getChild(0).getText().equals("lexer") ) {
      actionsWeMoved.add(e);
  combinedAST.deleteChild( r );
  (GrammarAST)combinedAST.getFirstChildWithType(ANTLRParser.RULES);
if ( combinedRulesRoot==null ) return lexerAST;
origin: uk.co.nichesolutions/antlr4

  GrammarAST imp_tokensRoot = (GrammarAST)imp.ast.getFirstChildWithType(ANTLRParser.TOKENS_SPEC);
  if ( imp_tokensRoot!=null ) {
    rootGrammar.tool.log("grammar", "imported tokens: "+imp_tokensRoot.getChildren());
  List<GrammarAST> imp_actionRoots = imp.ast.getAllChildrenWithType(ANTLRParser.AT);
  if ( actionRoots!=null ) all_actionRoots.addAll(actionRoots);
  all_actionRoots.addAll(imp_actionRoots);
  List<GrammarAST> rules = imp.ast.getNodesWithType(ANTLRParser.RULE);
  if ( rules!=null ) {
    for (GrammarAST r : rules) {
  GrammarAST optionsRoot = (GrammarAST)imp.ast.getFirstChildWithType(ANTLRParser.OPTIONS);
  if ( optionsRoot!=null ) {
    for (Map.Entry<String, GrammarAST> option : imp.ast.getOptions().entrySet()) {
      String importOption = imp.ast.getOptionString(option.getKey());
      if (importOption == null) {
        continue;
      String rootOption = rootGrammar.ast.getOptionString(option.getKey());
      if (!importOption.equals(rootOption)) {
        hasNewOption = true;
rootGrammar.tool.log("grammar", "Grammar: "+rootGrammar.ast.toStringTree());
origin: org.antlr/antlr4

  new ArrayList<Pair<GrammarAST,GrammarAST>>();
List<GrammarAST> ruleNodes = ast.getNodesWithType(ANTLRParser.RULE);
if ( ruleNodes==null || ruleNodes.isEmpty() ) return null;
origin: com.tunnelvisionlabs/antlr4

GrammarAST RULES = (GrammarAST)g.ast.getFirstChildWithType(ANTLRParser.RULES);
List<GrammarAST> rules = new ArrayList<GrammarAST>(RULES.getAllChildrenWithType(ANTLRParser.RULE));
for (GrammarAST mode : g.ast.getAllChildrenWithType(ANTLRParser.MODE)) {
  rules.addAll(mode.getAllChildrenWithType(ANTLRParser.RULE));
origin: org.antlr/antlr4

/** Manually get option node from tree; return null if no defined. */
public static GrammarAST findOptionValueAST(GrammarRootAST root, String option) {
  GrammarAST options = (GrammarAST)root.getFirstChildWithType(ANTLRParser.OPTIONS);
  if ( options!=null && options.getChildCount() > 0 ) {
    for (Object o : options.getChildren()) {
      GrammarAST c = (GrammarAST)o;
      if ( c.getType() == ANTLRParser.ASSIGN &&
         c.getChild(0).getText().equals(option) )
      {
        return (GrammarAST)c.getChild(1);
      }
    }
  }
  return null;
}
origin: io.virtdata/virtdata-lib-realer

public String getGrammarName() {
  Tree t = getChild(0);
  if ( t!=null ) return t.getText();
  return null;
}
origin: com.github.julianthome/inmemantlr-api

@Override
public Grammar createGrammar(GrammarRootAST ast) {
  final Grammar g;
  LOGGER.debug("ast " + ast.getGrammarName());
  if (ast.grammarType == ANTLRParser.LEXER) {
    g = new InmemantlrLexerGrammar(this, ast);
  } else {
    g = new InmemantlrGrammar(this, ast);
  }
  // ensure each node has pointer to surrounding grammar
  GrammarTransformPipeline.setGrammarPtr(g, ast);
  return g;
}
origin: io.virtdata/virtdata-lib-realer

GrammarAST[] elements = combinedAST.getChildren().toArray(new GrammarAST[0]);
String lexerName = combinedAST.getChild(0).getText()+"Lexer";
GrammarRootAST lexerAST =
  new GrammarRootAST(new CommonToken(ANTLRParser.GRAMMAR, "LEXER_GRAMMAR"), combinedGrammar.ast.tokenStream);
lexerAST.grammarType = ANTLRParser.LEXER;
lexerAST.token.setInputStream(combinedAST.token.getInputStream());
lexerAST.addChild((GrammarAST)adaptor.create(ANTLRParser.ID, lexerName));
  (GrammarAST)combinedAST.getFirstChildWithType(ANTLRParser.OPTIONS);
if ( optionsRoot!=null && optionsRoot.getChildCount()!=0 ) {
  GrammarAST lexerOptionsRoot = (GrammarAST)adaptor.dupNode(optionsRoot);
  lexerAST.addChild(lexerOptionsRoot);
  GrammarAST[] options = optionsRoot.getChildren().toArray(new GrammarAST[0]);
  for (GrammarAST o : options) {
      lexerAST.setOption(optionName, (GrammarAST)optionTree.getChild(1));
for (GrammarAST e : elements) {
  if ( e.getType()==ANTLRParser.AT ) {
    lexerAST.addChild((Tree)adaptor.dupTree(e));
    if ( e.getChild(0).getText().equals("lexer") ) {
      actionsWeMoved.add(e);
  combinedAST.deleteChild( r );
  (GrammarAST)combinedAST.getFirstChildWithType(ANTLRParser.RULES);
if ( combinedRulesRoot==null ) return lexerAST;
origin: com.tunnelvisionlabs/antlr4

GrammarAST imp_channelRoot = (GrammarAST)imp.ast.getFirstChildWithType(ANTLRParser.CHANNELS);
if ( imp_channelRoot != null) {
  rootGrammar.tool.log("grammar", "imported channels: "+imp_channelRoot.getChildren());
GrammarAST imp_tokensRoot = (GrammarAST)imp.ast.getFirstChildWithType(ANTLRParser.TOKENS_SPEC);
if ( imp_tokensRoot!=null ) {
  rootGrammar.tool.log("grammar", "imported tokens: "+imp_tokensRoot.getChildren());
List<GrammarAST> imp_actionRoots = imp.ast.getAllChildrenWithType(ANTLRParser.AT);
if ( actionRoots!=null ) all_actionRoots.addAll(actionRoots);
all_actionRoots.addAll(imp_actionRoots);
List<GrammarAST> modes = imp.ast.getNodesWithType(ANTLRParser.MODE);
if (modes != null) {
  for (GrammarAST m : modes) {
      rootGrammar.ast.addChild(destinationAST);
      rootModeNames.add(name);
      rootModes.add(destinationAST);
List<GrammarAST> rules = imp.ast.getNodesWithType(ANTLRParser.RULE);
if ( rules!=null ) {
  for (GrammarAST r : rules) {
GrammarAST optionsRoot = (GrammarAST)imp.ast.getFirstChildWithType(ANTLRParser.OPTIONS);
if ( optionsRoot!=null ) {
  for (Map.Entry<String, GrammarAST> option : imp.ast.getOptions().entrySet()) {
    String importOption = imp.ast.getOptionString(option.getKey());
org.antlr.v4.tool.astGrammarRootAST

Most used methods

  • getAllChildrenWithType
  • getChild
  • getGrammarName
  • getNodesWithType
  • toStringTree
  • <init>
  • addChild
  • deleteChild
  • getChildren
  • getFirstChildWithType
  • getNodeWithTokenIndex
  • getOptionAST
  • getNodeWithTokenIndex,
  • getOptionAST,
  • getOptionString,
  • getOptions,
  • sanityCheckParentAndChildIndexes,
  • setOption,
  • getNodesWithTypePreorderDFS

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • getApplicationContext (Context)
  • getResourceAsStream (ClassLoader)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • BoxLayout (javax.swing)
  • JCheckBox (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • 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