dodgy code cleanup (Coverity)

This commit is contained in:
Terence Parr 2013-08-31 17:36:16 -07:00
parent ba6c711e85
commit fc2dfcda96
1 changed files with 6 additions and 9 deletions

View File

@ -334,22 +334,19 @@ public class GrammarTransformPipeline {
List<GrammarAST> rulesWeMoved = new ArrayList<GrammarAST>();
GrammarASTWithOptions[] rules;
if (combinedRulesRoot.getChildCount() > 0) {
rules = ((List<?>)combinedRulesRoot.getChildren()).toArray(new GrammarASTWithOptions[0]);
rules = combinedRulesRoot.getChildren().toArray(new GrammarASTWithOptions[0]);
}
else {
rules = new GrammarASTWithOptions[0];
}
if ( rules!=null ) {
for (GrammarASTWithOptions r : rules) {
String ruleName = r.getChild(0).getText();
if (Grammar.isTokenName(ruleName)) {
lexerRulesRoot.addChild((Tree)adaptor.dupTree(r));
rulesWeMoved.add(r);
}
for (GrammarASTWithOptions r : rules) {
String ruleName = r.getChild(0).getText();
if (Grammar.isTokenName(ruleName)) {
lexerRulesRoot.addChild((Tree)adaptor.dupTree(r));
rulesWeMoved.add(r);
}
}
int nLexicalRules = rulesWeMoved.size();
for (GrammarAST r : rulesWeMoved) {
combinedRulesRoot.deleteChild( r );
}