Merge pull request #2098 from jasonmoo/rule_context_methods_fix

Add RuleContext interface methods to reserved words
This commit is contained in:
Terence Parr 2017-11-04 12:17:13 -07:00 committed by GitHub
commit c1b7bf94f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -170,3 +170,4 @@ YYYY/MM/DD, github id, Full name, email
2017/10/27, Griffon26, Maurice van der Pot, griffon26@kfk4ever.com
2017/05/29, rlfnb, Ralf Neeb, rlfnb@rlfnb.de
2017/10/29, gendalph, Максим Прохоренко, Maxim\dotProhorenko@gm@il.com
2017/11/02, jasonmoo, Jason Mooberry, jason.mooberry@gmail.com

View File

@ -49,8 +49,18 @@ public class GoTarget extends Target {
"make", "new", "panic", "print", "println", "real", "recover"
};
// interface definition of RuleContext from runtime/Go/antlr/rule_context.go
private static final String[] goRuleContextInterfaceMethods = {
"Accept", "GetAltNumber", "GetBaseRuleContext", "GetChild", "GetChildCount",
"GetChildren", "GetInvokingState", "GetParent", "GetPayload", "GetRuleContext",
"GetRuleIndex", "GetSourceInterval", "GetText", "IsEmpty", "SetAltNumber",
"SetInvokingState", "SetParent", "String"
};
/** Avoid grammar symbols in this set to prevent conflicts in gen'd code. */
private final Set<String> badWords = new HashSet<String>(goKeywords.length + goPredeclaredIdentifiers.length + 3);
private final Set<String> badWords = new HashSet<String>(
goKeywords.length + goPredeclaredIdentifiers.length + goRuleContextInterfaceMethods.length + 3
);
private static final boolean DO_GOFMT = !Boolean.parseBoolean(System.getenv("ANTLR_GO_DISABLE_GOFMT"))
&& !Boolean.parseBoolean(System.getProperty("antlr.go.disable-gofmt"));
@ -75,6 +85,7 @@ public class GoTarget extends Target {
protected void addBadWords() {
badWords.addAll(Arrays.asList(goKeywords));
badWords.addAll(Arrays.asList(goPredeclaredIdentifiers));
badWords.addAll(Arrays.asList(goRuleContextInterfaceMethods));
badWords.add("rule");
badWords.add("parserRule");
badWords.add("action");