forked from jasder/antlr
Make sure to check rules in modes while checking for undefined rules
This commit is contained in:
parent
094f40c961
commit
038d3ad44f
|
@ -433,14 +433,13 @@ public class Tool {
|
||||||
public boolean checkForRuleIssues(final Grammar g) {
|
public boolean checkForRuleIssues(final Grammar g) {
|
||||||
// check for redefined rules
|
// check for redefined rules
|
||||||
GrammarAST RULES = (GrammarAST)g.ast.getFirstChildWithType(ANTLRParser.RULES);
|
GrammarAST RULES = (GrammarAST)g.ast.getFirstChildWithType(ANTLRParser.RULES);
|
||||||
|
List<GrammarAST> rules = new ArrayList<GrammarAST>(RULES.getAllChildrenWithType(ANTLRParser.RULE));
|
||||||
List<?> rules = (List<?>)RULES.getChildren();
|
for (GrammarAST mode : g.ast.getAllChildrenWithType(ANTLRParser.MODE)) {
|
||||||
if (rules == null) {
|
rules.addAll(mode.getAllChildrenWithType(ANTLRParser.RULE));
|
||||||
rules = Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, RuleAST> ruleToAST = new HashMap<String, RuleAST>();
|
final Map<String, RuleAST> ruleToAST = new HashMap<String, RuleAST>();
|
||||||
for (Object r : rules) {
|
for (GrammarAST r : rules) {
|
||||||
RuleAST ruleAST = (RuleAST)r;
|
RuleAST ruleAST = (RuleAST)r;
|
||||||
GrammarAST ID = (GrammarAST)ruleAST.getChild(0);
|
GrammarAST ID = (GrammarAST)ruleAST.getChild(0);
|
||||||
String ruleName = ID.getText();
|
String ruleName = ID.getText();
|
||||||
|
|
Loading…
Reference in New Issue