public List<GrammarAST> getNodesWithType(int ttype) { return getNodesWithType(IntervalSet.of(ttype)); }
public List<GrammarAST> getNodesWithType(int ttype) { return getNodesWithType(IntervalSet.of(ttype)); }
public List<GrammarAST> getNodesWithType(int ttype) { return getNodesWithType(IntervalSet.of(ttype)); }
public List<GrammarAST> getNodesWithType(int ttype) { return getNodesWithType(IntervalSet.of(ttype)); }
public List<GrammarAST> getNodesWithType(int ttype) { return getNodesWithType(IntervalSet.of(ttype)); }
List<GrammarAST> optionsSubTrees = t.getNodesWithType(ELEMENT_OPTIONS); for (GrammarAST sub : optionsSubTrees) { ignore.add(sub.getTokenStartIndex(), sub.getTokenStopIndex()); List<GrammarAST> labeledSubTrees = t.getNodesWithType(new IntervalSet(ASSIGN,PLUS_ASSIGN)); for (GrammarAST sub : labeledSubTrees) { noOptions.add(sub.getChild(0).getTokenStartIndex());
List<GrammarAST> optionsSubTrees = t.getNodesWithType(ELEMENT_OPTIONS); for (GrammarAST sub : optionsSubTrees) { ignore.add(sub.getTokenStartIndex(), sub.getTokenStopIndex()); List<GrammarAST> labeledSubTrees = t.getNodesWithType(new IntervalSet(ASSIGN,PLUS_ASSIGN)); for (GrammarAST sub : labeledSubTrees) { noOptions.add(sub.getChild(0).getTokenStartIndex());
List<GrammarAST> optionsSubTrees = t.getNodesWithType(ELEMENT_OPTIONS); for (GrammarAST sub : optionsSubTrees) { ignore.add(sub.getTokenStartIndex(), sub.getTokenStopIndex()); List<GrammarAST> labeledSubTrees = t.getNodesWithType(new IntervalSet(ASSIGN,PLUS_ASSIGN)); for (GrammarAST sub : labeledSubTrees) { noOptions.add(sub.getChild(0).getTokenStartIndex());
List<GrammarAST> optionsSubTrees = t.getNodesWithType(ELEMENT_OPTIONS); for (GrammarAST sub : optionsSubTrees) { ignore.add(sub.getTokenStartIndex(), sub.getTokenStopIndex()); List<GrammarAST> labeledSubTrees = t.getNodesWithType(new IntervalSet(ASSIGN,PLUS_ASSIGN)); for (GrammarAST sub : labeledSubTrees) { noOptions.add(sub.getChild(0).getTokenStartIndex());
List<GrammarAST> optionsSubTrees = t.getNodesWithType(ELEMENT_OPTIONS); for (GrammarAST sub : optionsSubTrees) { ignore.add(sub.getTokenStartIndex(), sub.getTokenStopIndex()); List<GrammarAST> labeledSubTrees = t.getNodesWithType(new IntervalSet(ASSIGN,PLUS_ASSIGN)); for (GrammarAST sub : labeledSubTrees) { noOptions.add(sub.getChild(0).getTokenStartIndex());
public static void augmentTokensWithOriginalPosition(final Grammar g, GrammarAST tree) { if ( tree==null ) return; List<GrammarAST> optionsSubTrees = tree.getNodesWithType(ANTLRParser.ELEMENT_OPTIONS); for (int i = 0; i < optionsSubTrees.size(); i++) { GrammarAST t = optionsSubTrees.get(i); CommonTree elWithOpt = t.parent; if ( elWithOpt instanceof GrammarASTWithOptions ) { Map<String, GrammarAST> options = ((GrammarASTWithOptions) elWithOpt).getOptions(); if ( options.containsKey(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME) ) { GrammarToken newTok = new GrammarToken(g, elWithOpt.getToken()); newTok.originalTokenIndex = Integer.valueOf(options.get(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME).getText()); elWithOpt.token = newTok; GrammarAST originalNode = g.ast.getNodeWithTokenIndex(newTok.getTokenIndex()); if (originalNode != null) { // update the AST node start/stop index to match the values // of the corresponding node in the original parse tree. elWithOpt.setTokenStartIndex(originalNode.getTokenStartIndex()); elWithOpt.setTokenStopIndex(originalNode.getTokenStopIndex()); } else { // the original AST node could not be located by index; // make sure to assign valid values for the start/stop // index so toTokenString will not throw exceptions. elWithOpt.setTokenStartIndex(newTok.getTokenIndex()); elWithOpt.setTokenStopIndex(newTok.getTokenIndex()); } } } } }
public static void augmentTokensWithOriginalPosition(final Grammar g, GrammarAST tree) { if ( tree==null ) return; List<GrammarAST> optionsSubTrees = tree.getNodesWithType(ANTLRParser.ELEMENT_OPTIONS); for (int i = 0; i < optionsSubTrees.size(); i++) { GrammarAST t = optionsSubTrees.get(i); CommonTree elWithOpt = t.parent; if ( elWithOpt instanceof GrammarASTWithOptions ) { Map<String, GrammarAST> options = ((GrammarASTWithOptions) elWithOpt).getOptions(); if ( options.containsKey(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME) ) { GrammarToken newTok = new GrammarToken(g, elWithOpt.getToken()); newTok.originalTokenIndex = Integer.valueOf(options.get(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME).getText()); elWithOpt.token = newTok; GrammarAST originalNode = g.ast.getNodeWithTokenIndex(newTok.getTokenIndex()); if (originalNode != null) { // update the AST node start/stop index to match the values // of the corresponding node in the original parse tree. elWithOpt.setTokenStartIndex(originalNode.getTokenStartIndex()); elWithOpt.setTokenStopIndex(originalNode.getTokenStopIndex()); } else { // the original AST node could not be located by index; // make sure to assign valid values for the start/stop // index so toTokenString will not throw exceptions. elWithOpt.setTokenStartIndex(newTok.getTokenIndex()); elWithOpt.setTokenStopIndex(newTok.getTokenIndex()); } } } } }
public static void augmentTokensWithOriginalPosition(final Grammar g, GrammarAST tree) { if ( tree==null ) return; List<GrammarAST> optionsSubTrees = tree.getNodesWithType(ANTLRParser.ELEMENT_OPTIONS); for (int i = 0; i < optionsSubTrees.size(); i++) { GrammarAST t = optionsSubTrees.get(i); CommonTree elWithOpt = t.parent; if ( elWithOpt instanceof GrammarASTWithOptions ) { Map<String, GrammarAST> options = ((GrammarASTWithOptions) elWithOpt).getOptions(); if ( options.containsKey(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME) ) { GrammarToken newTok = new GrammarToken(g, elWithOpt.getToken()); newTok.originalTokenIndex = Integer.valueOf(options.get(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME).getText()); elWithOpt.token = newTok; GrammarAST originalNode = g.ast.getNodeWithTokenIndex(newTok.getTokenIndex()); if (originalNode != null) { // update the AST node start/stop index to match the values // of the corresponding node in the original parse tree. elWithOpt.setTokenStartIndex(originalNode.getTokenStartIndex()); elWithOpt.setTokenStopIndex(originalNode.getTokenStopIndex()); } else { // the original AST node could not be located by index; // make sure to assign valid values for the start/stop // index so toTokenString will not throw exceptions. elWithOpt.setTokenStartIndex(newTok.getTokenIndex()); elWithOpt.setTokenStopIndex(newTok.getTokenIndex()); } } } } }
public static void augmentTokensWithOriginalPosition(final Grammar g, GrammarAST tree) { if ( tree==null ) return; List<GrammarAST> optionsSubTrees = tree.getNodesWithType(ANTLRParser.ELEMENT_OPTIONS); for (int i = 0; i < optionsSubTrees.size(); i++) { GrammarAST t = optionsSubTrees.get(i); CommonTree elWithOpt = t.parent; if ( elWithOpt instanceof GrammarASTWithOptions ) { Map<String, GrammarAST> options = ((GrammarASTWithOptions) elWithOpt).getOptions(); if ( options.containsKey(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME) ) { GrammarToken newTok = new GrammarToken(g, elWithOpt.getToken()); newTok.originalTokenIndex = Integer.valueOf(options.get(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME).getText()); elWithOpt.token = newTok; GrammarAST originalNode = g.ast.getNodeWithTokenIndex(newTok.getTokenIndex()); if (originalNode != null) { // update the AST node start/stop index to match the values // of the corresponding node in the original parse tree. elWithOpt.setTokenStartIndex(originalNode.getTokenStartIndex()); elWithOpt.setTokenStopIndex(originalNode.getTokenStopIndex()); } else { // the original AST node could not be located by index; // make sure to assign valid values for the start/stop // index so toTokenString will not throw exceptions. elWithOpt.setTokenStartIndex(newTok.getTokenIndex()); elWithOpt.setTokenStopIndex(newTok.getTokenIndex()); } } } } }
public static void augmentTokensWithOriginalPosition(final Grammar g, GrammarAST tree) { if ( tree==null ) return; List<GrammarAST> optionsSubTrees = tree.getNodesWithType(ANTLRParser.ELEMENT_OPTIONS); for (int i = 0; i < optionsSubTrees.size(); i++) { GrammarAST t = optionsSubTrees.get(i); CommonTree elWithOpt = t.parent; if ( elWithOpt instanceof GrammarASTWithOptions ) { Map<String, GrammarAST> options = ((GrammarASTWithOptions) elWithOpt).getOptions(); if ( options.containsKey(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME) ) { GrammarToken newTok = new GrammarToken(g, elWithOpt.getToken()); newTok.originalTokenIndex = Integer.valueOf(options.get(LeftRecursiveRuleTransformer.TOKENINDEX_OPTION_NAME).getText()); elWithOpt.token = newTok; GrammarAST originalNode = g.ast.getNodeWithTokenIndex(newTok.getTokenIndex()); if (originalNode != null) { // update the AST node start/stop index to match the values // of the corresponding node in the original parse tree. elWithOpt.setTokenStartIndex(originalNode.getTokenStartIndex()); elWithOpt.setTokenStopIndex(originalNode.getTokenStopIndex()); } else { // the original AST node could not be located by index; // make sure to assign valid values for the start/stop // index so toTokenString will not throw exceptions. elWithOpt.setTokenStartIndex(newTok.getTokenIndex()); elWithOpt.setTokenStopIndex(newTok.getTokenIndex()); } } } } }
List<GrammarAST> actionRoots = root.getNodesWithType(ANTLRParser.AT); Set<String> rootRuleNames = new HashSet<String>(); List<GrammarAST> rootRules = RULES.getNodesWithType(ANTLRParser.RULE); for (GrammarAST r : rootRules) rootRuleNames.add(r.getChild(0).getText());
List<GrammarAST> actionRoots = root.getNodesWithType(ANTLRParser.AT); Set<String> rootRuleNames = new HashSet<String>(); List<GrammarAST> rootRules = RULES.getNodesWithType(ANTLRParser.RULE); for (GrammarAST r : rootRules) rootRuleNames.add(r.getChild(0).getText());
GrammarAST tokensRoot = (GrammarAST)root.getFirstChildWithType(ANTLRParser.TOKENS_SPEC); List<GrammarAST> actionRoots = root.getNodesWithType(ANTLRParser.AT); Set<String> rootRuleNames = new HashSet<String>(); List<GrammarAST> rootRules = RULES.getNodesWithType(ANTLRParser.RULE); for (GrammarAST r : rootRules) rootRuleNames.add(r.getChild(0).getText()); List<GrammarAST> rootModes = root.getNodesWithType(ANTLRParser.MODE); Set<String> rootModeNames = new HashSet<String>(); for (GrammarAST m : rootModes) rootModeNames.add(m.getChild(0).getText());
GrammarAST tokensRoot = (GrammarAST)root.getFirstChildWithType(ANTLRParser.TOKENS_SPEC); List<GrammarAST> actionRoots = root.getNodesWithType(ANTLRParser.AT); Set<String> rootRuleNames = new HashSet<String>(); List<GrammarAST> rootRules = RULES.getNodesWithType(ANTLRParser.RULE); for (GrammarAST r : rootRules) rootRuleNames.add(r.getChild(0).getText()); List<GrammarAST> rootModes = root.getNodesWithType(ANTLRParser.MODE); Set<String> rootModeNames = new HashSet<String>(); for (GrammarAST m : rootModes) rootModeNames.add(m.getChild(0).getText());
GrammarAST tokensRoot = (GrammarAST)root.getFirstChildWithType(ANTLRParser.TOKENS_SPEC); List<GrammarAST> actionRoots = root.getNodesWithType(ANTLRParser.AT); Set<String> rootRuleNames = new HashSet<String>(); List<GrammarAST> rootRules = RULES.getNodesWithType(ANTLRParser.RULE); for (GrammarAST r : rootRules) rootRuleNames.add(r.getChild(0).getText()); List<GrammarAST> rootModes = root.getNodesWithType(ANTLRParser.MODE); Set<String> rootModeNames = new HashSet<String>(); for (GrammarAST m : rootModes) rootModeNames.add(m.getChild(0).getText());