Merge pull request #28 from willfaught/fmt-structure

Fix the layout of some generated Go code
This commit is contained in:
Peter Boyer 2016-06-14 13:17:23 -04:00 committed by GitHub
commit e50b0ca8cd
3 changed files with 716 additions and 261 deletions

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -55,10 +56,10 @@ public abstract class Recognizer extends OutputModelObject {
* {@link #literalNames} and {@link #symbolicNames}.
*/
@Deprecated
public String[] tokenNames;
public List<String> tokenNames;
public String[] literalNames;
public String[] symbolicNames;
public List<String> literalNames;
public List<String> symbolicNames;
public Set<String> ruleNames;
public Collection<Rule> rules;
@ModelElement public ActionChunk superClass;
@ -98,7 +99,7 @@ public abstract class Recognizer extends OutputModelObject {
symbolicNames = translateTokenStringsToTarget(g.getTokenSymbolicNames(), gen);
}
protected static String[] translateTokenStringsToTarget(String[] tokenStrings, CodeGenerator gen) {
protected static List<String> translateTokenStringsToTarget(String[] tokenStrings, CodeGenerator gen) {
String[] result = tokenStrings.clone();
for (int i = 0; i < tokenStrings.length; i++) {
result[i] = translateTokenStringToTarget(tokenStrings[i], gen);
@ -113,7 +114,7 @@ public abstract class Recognizer extends OutputModelObject {
result = Arrays.copyOf(result, lastTrueEntry + 1);
}
return result;
return Arrays.asList(result);
}
protected static String translateTokenStringToTarget(String tokenName, CodeGenerator gen) {

View File

@ -1,4 +1,3 @@
package org.antlr.v4.codegen.target;
import org.antlr.v4.codegen.CodeGenerator;
@ -66,7 +65,7 @@ public class GoTarget extends Target {
@Override
public String encodeIntAsCharEscape(int v) {
return Integer.toString(v) + ",";
return Integer.toString(v);
}
@Override