remove unnecessary check for missing RULES node as that node is apparently always present; the tree construction rule is: -> ^(RULES rule*)

This commit is contained in:
Terence Parr 2015-01-12 12:59:36 -08:00
parent c9a51b98ae
commit 0c2a693638
1 changed files with 3 additions and 10 deletions

View File

@ -192,16 +192,9 @@ public class GrammarTransformPipeline {
// Compute list of rules in root grammar and ensure we have a RULES node
GrammarAST RULES = (GrammarAST)root.getFirstChildWithType(ANTLRParser.RULES);
Set<String> rootRuleNames = new HashSet<String>();
if ( RULES==null ) { // no rules in root, make RULES node, hook in
RULES = (GrammarAST)adaptor.create(ANTLRParser.RULES, "RULES");
RULES.g = rootGrammar;
root.addChild(RULES);
}
else {
// make list of rules we have in root grammar
List<GrammarAST> rootRules = RULES.getNodesWithType(ANTLRParser.RULE);
for (GrammarAST r : rootRules) rootRuleNames.add(r.getChild(0).getText());
}
// make list of rules we have in root grammar
List<GrammarAST> rootRules = RULES.getNodesWithType(ANTLRParser.RULE);
for (GrammarAST r : rootRules) rootRuleNames.add(r.getChild(0).getText());
for (Grammar imp : imports) {
// COPY TOKENS