use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.
the class BaseBrowserTest method getTokenTypesViaATN.
public IntegerList getTokenTypesViaATN(String input, LexerATNSimulator lexerATN) {
ANTLRInputStream in = new ANTLRInputStream(input);
IntegerList tokenTypes = new IntegerList();
int ttype;
do {
ttype = lexerATN.match(in, Lexer.DEFAULT_MODE);
tokenTypes.add(ttype);
} while (ttype != Token.EOF);
return tokenTypes;
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.
the class BaseNodeTest method getTokenTypesViaATN.
public IntegerList getTokenTypesViaATN(String input, LexerATNSimulator lexerATN) {
ANTLRInputStream in = new ANTLRInputStream(input);
IntegerList tokenTypes = new IntegerList();
int ttype;
do {
ttype = lexerATN.match(in, Lexer.DEFAULT_MODE);
tokenTypes.add(ttype);
} while (ttype != Token.EOF);
return tokenTypes;
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.
the class BaseCppTest method getTypesFromString.
// public void minimizeDFA(DFA dfa) {
// DFAMinimizer dmin = new DFAMinimizer(dfa);
// dfa.minimized = dmin.minimize();
// }
IntegerList getTypesFromString(Grammar g, String expecting) {
IntegerList expectingTokenTypes = new IntegerList();
if (expecting != null && !expecting.trim().isEmpty()) {
for (String tname : expecting.replace(" ", "").split(",")) {
int ttype = g.getTokenType(tname);
expectingTokenTypes.add(ttype);
}
}
return expectingTokenTypes;
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.
the class BaseGoTest method getTypesFromString.
IntegerList getTypesFromString(Grammar g, String expecting) {
IntegerList expectingTokenTypes = new IntegerList();
if (expecting != null && !expecting.trim().isEmpty()) {
for (String tname : expecting.replace(" ", "").split(",")) {
int ttype = g.getTokenType(tname);
expectingTokenTypes.add(ttype);
}
}
return expectingTokenTypes;
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class Tool method generateInterpreterData.
private void generateInterpreterData(Grammar g) {
StringBuilder content = new StringBuilder();
content.append("token literal names:\n");
String[] names = g.getTokenLiteralNames();
for (String name : names) {
content.append(name).append("\n");
}
content.append("\n");
content.append("token symbolic names:\n");
names = g.getTokenSymbolicNames();
for (String name : names) {
content.append(name).append("\n");
}
content.append("\n");
content.append("rule names:\n");
names = g.getRuleNames();
for (String name : names) {
content.append(name).append("\n");
}
content.append("\n");
if (g.isLexer()) {
content.append("channel names:\n");
content.append("DEFAULT_TOKEN_CHANNEL\n");
content.append("HIDDEN\n");
for (String channel : g.channelValueToNameList) {
content.append(channel).append("\n");
}
content.append("\n");
content.append("mode names:\n");
for (String mode : ((LexerGrammar) g).modes.keySet()) {
content.append(mode).append("\n");
}
}
content.append("\n");
IntegerList serializedATN = ATNSerializer.getSerialized(g.atn, Arrays.asList(g.getRuleNames()));
content.append("atn:\n");
content.append(serializedATN.toString());
try {
Writer fw = getOutputFileWriter(g, g.name + ".interp");
try {
fw.write(content.toString());
} finally {
fw.close();
}
} catch (IOException ioe) {
errMgr.toolError(ErrorType.CANNOT_WRITE_FILE, ioe);
}
}
Aggregations