Fix NPE when a grammar contains no rules (instead of appropriate error message)

This commit is contained in:
Sam Harwell 2012-03-27 21:25:23 -05:00
parent 9c1e58db7c
commit 95b6cd58c4
1 changed files with 8 additions and 1 deletions

View File

@ -317,7 +317,14 @@ public class GrammarTransformPipeline {
(GrammarAST)adaptor.create(ANTLRParser.RULES, "RULES");
lexerAST.addChild(lexerRulesRoot);
List<GrammarAST> rulesWeMoved = new ArrayList<GrammarAST>();
GrammarASTWithOptions[] rules = ((List<?>)combinedRulesRoot.getChildren()).toArray(new GrammarASTWithOptions[0]);
GrammarASTWithOptions[] rules;
if (combinedRulesRoot.getChildCount() > 0) {
rules = ((List<?>)combinedRulesRoot.getChildren()).toArray(new GrammarASTWithOptions[0]);
}
else {
rules = new GrammarASTWithOptions[0];
}
if ( rules!=null ) {
for (GrammarASTWithOptions r : rules) {
String ruleName = r.getChild(0).getText();