use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class TestIntegerList method negativeIntegerToCharArrayThrows.
@Test
public void negativeIntegerToCharArrayThrows() {
IntegerList l = new IntegerList();
l.add(-42);
thrown.expect(IllegalArgumentException.class);
Utils.toCharArray(l);
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class TestIntegerList method unicodeBMPIntegerListToCharArray.
@Test
public void unicodeBMPIntegerListToCharArray() {
IntegerList l = new IntegerList();
l.add(0x35);
l.add(0x4E94);
l.add(0xFF15);
char[] expected = new char[] { 0x35, 0x4E94, 0xFF15 };
assertArrayEquals(expected, Utils.toCharArray(l));
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class TestIntegerList method surrogateRangeIntegerToCharArray.
@Test
public void surrogateRangeIntegerToCharArray() {
IntegerList l = new IntegerList();
// Java allows dangling surrogates, so (currently) we do
// as well. We could change this if desired.
l.add(0xDC00);
char[] expected = new char[] { 0xDC00 };
assertArrayEquals(expected, Utils.toCharArray(l));
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class ParserATNSimulator method addDFAEdge.
@NotNull
protected DFAState addDFAEdge(@NotNull DFA dfa, @NotNull DFAState fromState, int t, IntegerList contextTransitions, @NotNull ATNConfigSet toConfigs, PredictionContextCache contextCache) {
assert contextTransitions == null || contextTransitions.isEmpty() || dfa.isContextSensitive();
DFAState from = fromState;
DFAState to = addDFAState(dfa, toConfigs, contextCache);
if (contextTransitions != null) {
for (int context : contextTransitions.toArray()) {
if (context == PredictionContext.EMPTY_FULL_STATE_KEY) {
if (from.configs.isOutermostConfigSet()) {
continue;
}
}
from.setContextSensitive(atn);
from.setContextSymbol(t);
DFAState next = from.getContextTarget(context);
if (next != null) {
from = next;
continue;
}
next = addDFAContextState(dfa, from.configs, context, contextCache);
assert context != PredictionContext.EMPTY_FULL_STATE_KEY || next.configs.isOutermostConfigSet();
from.setContextTarget(context, next);
from = next;
}
}
if (debug)
System.out.println("EDGE " + from + " -> " + to + " upon " + getTokenName(t));
addDFAEdge(from, t, to);
if (debug)
System.out.println("DFA=\n" + dfa.toString(parser != null ? parser.getVocabulary() : VocabularyImpl.EMPTY_VOCABULARY, parser != null ? parser.getRuleNames() : null));
return to;
}
use of org.antlr.v4.runtime.misc.IntegerList in project antlr4 by tunnelvisionlabs.
the class ATNSerializer method getDecoded.
public static String getDecoded(ATN atn, List<String> ruleNames, List<String> tokenNames) {
IntegerList serialized = getSerialized(atn, ruleNames);
char[] data = Utils.toCharArray(serialized);
return new ATNSerializer(atn, ruleNames, tokenNames).decode(data);
}
Aggregations