From 038d3ad44f330215dbd1c818bf66e1e84d819229 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 21 Nov 2012 18:36:28 -0600 Subject: [PATCH] Make sure to check rules in modes while checking for undefined rules --- tool/src/org/antlr/v4/Tool.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tool/src/org/antlr/v4/Tool.java b/tool/src/org/antlr/v4/Tool.java index 52f7d7b19..7f3029a3b 100644 --- a/tool/src/org/antlr/v4/Tool.java +++ b/tool/src/org/antlr/v4/Tool.java @@ -433,14 +433,13 @@ public class Tool { public boolean checkForRuleIssues(final Grammar g) { // check for redefined rules GrammarAST RULES = (GrammarAST)g.ast.getFirstChildWithType(ANTLRParser.RULES); - - List rules = (List)RULES.getChildren(); - if (rules == null) { - rules = Collections.emptyList(); + List rules = new ArrayList(RULES.getAllChildrenWithType(ANTLRParser.RULE)); + for (GrammarAST mode : g.ast.getAllChildrenWithType(ANTLRParser.MODE)) { + rules.addAll(mode.getAllChildrenWithType(ANTLRParser.RULE)); } final Map ruleToAST = new HashMap(); - for (Object r : rules) { + for (GrammarAST r : rules) { RuleAST ruleAST = (RuleAST)r; GrammarAST ID = (GrammarAST)ruleAST.getChild(0); String ruleName = ID.getText();