List of usage examples for org.antlr.v4.runtime RuleContext getChildCount
@Override
public int getChildCount()
From source file:com.twosigma.beaker.groovy.autocomplete.GroovyNodeCompletion.java
License:Apache License
private ParseTree findLeftSibling(RuleContext ctx) { RuleContext p = ctx.getParent(); if (p != null) { for (int i = 0; i < p.getChildCount(); i++) { if (p.getChild(i).equals(ctx)) { if (i > 0) return p.getChild(i - 1); break; }// w ww . j a v a 2s . co m } } return null; }
From source file:compile.compilersource.ASTPrinter.java
public static String explore(RuleContext context, int indentation) { System.out.println(MessageFormat.format("explore context nullcheck: {0}", context == null)); String output = ""; String RuleName = myGrammarParser.ruleNames[context.getRuleIndex()]; for (int c = 0; c < indentation; c++) { System.out.print(" "); output += " "; }//www . java2s .co m System.out.println(RuleName); output += RuleName; for (int c = 0; c < context.getChildCount(); c++) { ParseTree element = context.getChild(c); if (element instanceof RuleContext) { output += explore((RuleContext) element, indentation + 1); } } return output; }
From source file:compile.compilersource.CompilerHelper.java
public static String explore(RuleContext context, int indentation) { String output = ""; String RuleName = myGrammarParser.ruleNames[context.getRuleIndex()]; for (int c = 0; c < indentation; c++) { System.out.print(" "); output += " "; }/*from www. ja va 2 s . co m*/ System.out.println(RuleName); output += RuleName + "\n"; for (int c = 0; c < context.getChildCount(); c++) { ParseTree element = context.getChild(c); if (element instanceof RuleContext) { output += explore((RuleContext) element, indentation + 1); } } return output; }