Make sure to check rules in modes while checking for undefined rules

This commit is contained in:
Sam Harwell 2012-11-21 18:36:28 -06:00
parent 094f40c961
commit 038d3ad44f
1 changed files with 4 additions and 5 deletions

View File

@ -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<GrammarAST> rules = new ArrayList<GrammarAST>(RULES.getAllChildrenWithType(ANTLRParser.RULE));
for (GrammarAST mode : g.ast.getAllChildrenWithType(ANTLRParser.MODE)) {
rules.addAll(mode.getAllChildrenWithType(ANTLRParser.RULE));
}
final Map<String, RuleAST> ruleToAST = new HashMap<String, RuleAST>();
for (Object r : rules) {
for (GrammarAST r : rules) {
RuleAST ruleAST = (RuleAST)r;
GrammarAST ID = (GrammarAST)ruleAST.getChild(0);
String ruleName = ID.getText();