private String getDefaultAntlrRuleName(AbstractRule rule) { if (rule instanceof ParserRule || rule instanceof EnumRule) { return "rule" + rule.getName(); } if (rule instanceof TerminalRule) { return "RULE_" + rule.getName().toUpperCase(); } throw new IllegalArgumentException(rule.eClass().getName()); }
private String getInheritedAntlrRuleName(AbstractRule rule, Set<String> usedNames) { if (rule instanceof ParserRule || rule instanceof EnumRule) { String candidate = "super" + rule.getName(); int i = 1; while (usedNames.contains(candidate)) { candidate = "super" + i + rule.getName(); i++; } return candidate; } if (rule instanceof TerminalRule) { String candidate = "SUPER_" + rule.getName(); int i = 1; while (usedNames.contains(candidate)) { candidate = "SUPER_" + i + "_" + rule.getName(); i++; } return candidate; } throw new IllegalArgumentException(rule.eClass().getName()); }