Merge pull request #2299 from dhalperi/streamline-java-statics

Java.stg: use static functions instead of inline arrays
This commit is contained in:
Terence Parr 2018-06-02 13:00:42 -07:00 committed by GitHub
commit 61acb35f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 12 deletions

View File

@ -236,9 +236,12 @@ public class <parser.name> extends <superClass; null="Parser"> {
<endif> <endif>
public static final int public static final int
<parser.rules:{r | RULE_<r.name> = <r.index>}; separator=", ", wrap, anchor>; <parser.rules:{r | RULE_<r.name> = <r.index>}; separator=", ", wrap, anchor>;
public static final String[] ruleNames = { private static String[] makeRuleNames() {
return new String[] {
<parser.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor> <parser.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor>
}; };
}
public static final String[] ruleNames = makeRuleNames();
<vocabulary(parser.literalNames, parser.symbolicNames)> <vocabulary(parser.literalNames, parser.symbolicNames)>
@ -275,12 +278,18 @@ case <f.ruleIndex>:
>> >>
vocabulary(literalNames, symbolicNames) ::= << vocabulary(literalNames, symbolicNames) ::= <<
private static final String[] _LITERAL_NAMES = { private static String[] makeLiteralNames() {
return new String[] {
<literalNames:{t | <t>}; null="null", separator=", ", wrap, anchor> <literalNames:{t | <t>}; null="null", separator=", ", wrap, anchor>
}; };
private static final String[] _SYMBOLIC_NAMES = { }
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
<symbolicNames:{t | <t>}; null="null", separator=", ", wrap, anchor> <symbolicNames:{t | <t>}; null="null", separator=", ", wrap, anchor>
}; };
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/** /**
@ -914,9 +923,12 @@ public class <lexer.name> extends <superClass; null="Lexer"> {
<lexer.modes:{m| "<m>"}; separator=", ", wrap, anchor> <lexer.modes:{m| "<m>"}; separator=", ", wrap, anchor>
}; };
public static final String[] ruleNames = { private static String[] makeRuleNames() {
return new String[] {
<lexer.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor> <lexer.ruleNames:{r | "<r>"}; separator=", ", wrap, anchor>
}; };
}
public static final String[] ruleNames = makeRuleNames();
<vocabulary(lexer.literalNames, lexer.symbolicNames)> <vocabulary(lexer.literalNames, lexer.symbolicNames)>