use of org.antlr.v4.runtime.Vocabulary in project antlr4 by antlr.
the class TestIntervalSet method testNotSetEdgeElement.
@Test
public void testNotSetEdgeElement() throws Exception {
IntervalSet vocabulary = IntervalSet.of(1, 2);
IntervalSet s = IntervalSet.of(1);
String expecting = "2";
String result = (s.complement(vocabulary)).toString();
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.Vocabulary in project antlr4 by antlr.
the class TestVocabulary method testVocabularyFromTokenNames.
@Test
public void testVocabularyFromTokenNames() {
String[] tokenNames = { "<INVALID>", "TOKEN_REF", "RULE_REF", "'//'", "'/'", "'*'", "'!'", "ID", "STRING" };
Vocabulary vocabulary = VocabularyImpl.fromTokenNames(tokenNames);
Assert.assertNotNull(vocabulary);
Assert.assertEquals("EOF", vocabulary.getSymbolicName(Token.EOF));
for (int i = 0; i < tokenNames.length; i++) {
Assert.assertEquals(tokenNames[i], vocabulary.getDisplayName(i));
if (tokenNames[i].startsWith("'")) {
Assert.assertEquals(tokenNames[i], vocabulary.getLiteralName(i));
Assert.assertNull(vocabulary.getSymbolicName(i));
} else if (Character.isUpperCase(tokenNames[i].charAt(0))) {
Assert.assertNull(vocabulary.getLiteralName(i));
Assert.assertEquals(tokenNames[i], vocabulary.getSymbolicName(i));
} else {
Assert.assertNull(vocabulary.getLiteralName(i));
Assert.assertNull(vocabulary.getSymbolicName(i));
}
}
}
Aggregations