use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class TestIntegerList method unicodeSMPIntegerListToCharArray.
@Test
public void unicodeSMPIntegerListToCharArray() {
IntegerList l = new IntegerList();
l.add(0x104A5);
l.add(0x116C5);
l.add(0x1D7FB);
char[] expected = new char[] { 0xD801, 0xDCA5, 0xD805, 0xDEC5, 0xD835, 0xDFFB };
assertArrayEquals(expected, Utils.toCharArray(l));
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class TestIntegerList method tooLargeIntegerToCharArrayThrows.
@Test
public void tooLargeIntegerToCharArrayThrows() {
IntegerList l = new IntegerList();
l.add(0x110000);
thrown.expect(IllegalArgumentException.class);
Utils.toCharArray(l);
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.
the class TestATNParserPrediction method checkDFAConstruction.
public void checkDFAConstruction(LexerGrammar lg, Grammar g, int decision, String[] inputString, String[] dfaString) {
// Tool.internalOption_ShowATNConfigsInDFA = true;
ATN lexatn = createATN(lg, true);
LexerATNSimulator lexInterp = new LexerATNSimulator(lexatn, new DFA[] { new DFA(lexatn.getDecisionState(Lexer.DEFAULT_MODE)) }, new PredictionContextCache());
semanticProcess(lg);
g.importVocab(lg);
semanticProcess(g);
ParserInterpreterForTesting interp = new ParserInterpreterForTesting(g, null);
for (int i = 0; i < inputString.length; i++) {
// Check DFA
IntegerList types = getTokenTypesViaATN(inputString[i], lexInterp);
// System.out.println(types);
TokenStream input = new MockIntTokenStream(types);
try {
interp.adaptivePredict(input, decision, ParserRuleContext.EMPTY);
} catch (NoViableAltException nvae) {
nvae.printStackTrace(System.err);
}
DFA dfa = interp.parser.decisionToDFA[decision];
assertEquals(dfaString[i], dfa.toString(g.getVocabulary()));
}
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by antlr.
the class RuntimeTestUtils method getTokenTypesViaATN.
public static 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 TestIntegerList method emptyListToEmptyCharArray.
@Test
public void emptyListToEmptyCharArray() {
IntegerList l = new IntegerList();
assertArrayEquals(new char[0], l.toCharArray());
}
Aggregations