use of org.antlr.v4.runtime.atn.ATN in project antlr4 by antlr.
the class TestATNSerialization method testLexerUnicodeEscapedSMPSetWithRange.
@Test
public void testLexerUnicodeEscapedSMPSetWithRange() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "ID : ('\\u{1F4A9}'|'\\u{1F4AA}'|'\\u{1F441}'|'\\u{1D40F}'..'\\u{1D413}')\n ;");
String expecting = "max type 1\n" + "0:TOKEN_START -1\n" + "1:RULE_START 0\n" + "2:RULE_STOP 0\n" + "3:BASIC 0\n" + "4:BASIC 0\n" + "rule 0:1 1\n" + "mode 0:0\n" + "0:119823..119827, 128065..128065, 128169..128170\n" + "0->1 EPSILON 0,0,0\n" + "1->3 EPSILON 0,0,0\n" + "3->4 SET 0,0,0\n" + "4->2 EPSILON 0,0,0\n" + "0:0\n";
ATN atn = createATN(lg, true);
String result = ATNSerializer.getDecoded(atn, Arrays.asList(lg.getTokenNames()));
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.atn.ATN in project antlr4 by antlr.
the class TestATNSerialization method testLexerEOF.
@Test
public void testLexerEOF() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "INT : 'a' EOF ;\n");
String expecting = "max type 1\n" + "0:TOKEN_START -1\n" + "1:RULE_START 0\n" + "2:RULE_STOP 0\n" + "3:BASIC 0\n" + "4:BASIC 0\n" + "5:BASIC 0\n" + "rule 0:1 1\n" + "mode 0:0\n" + "0->1 EPSILON 0,0,0\n" + "1->3 EPSILON 0,0,0\n" + "3->4 ATOM 97,0,0\n" + "4->5 ATOM 0,0,1\n" + "5->2 EPSILON 0,0,0\n" + "0:0\n";
ATN atn = createATN(lg, true);
String result = ATNSerializer.getDecoded(atn, Arrays.asList(lg.getTokenNames()));
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.atn.ATN in project antlr4 by antlr.
the class TestATNSerialization method testNot.
@Test
public void testNot() throws Exception {
Grammar g = new Grammar("parser grammar T;\n" + "tokens {A, B, C}\n" + "a : ~A ;");
String expecting = "max type 3\n" + "0:RULE_START 0\n" + "1:RULE_STOP 0\n" + "2:BASIC 0\n" + "3:BASIC 0\n" + "4:BASIC 0\n" + "rule 0:0\n" + "0:A..A\n" + "0->2 EPSILON 0,0,0\n" + "2->3 NOT_SET 0,0,0\n" + "3->1 EPSILON 0,0,0\n";
ATN atn = createATN(g, true);
DOTGenerator gen = new DOTGenerator(g);
String result = ATNSerializer.getDecoded(atn, Arrays.asList(g.getTokenNames()));
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.atn.ATN in project antlr4 by antlr.
the class TestATNSerialization method testLexerNotSetWithRange.
@Test
public void testLexerNotSetWithRange() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "ID : ~('a'|'b'|'e'|'p'..'t')\n ;");
String expecting = "max type 1\n" + "0:TOKEN_START -1\n" + "1:RULE_START 0\n" + "2:RULE_STOP 0\n" + "3:BASIC 0\n" + "4:BASIC 0\n" + "rule 0:1 1\n" + "mode 0:0\n" + "0:'a'..'b', 'e'..'e', 'p'..'t'\n" + "0->1 EPSILON 0,0,0\n" + "1->3 EPSILON 0,0,0\n" + "3->4 NOT_SET 0,0,0\n" + "4->2 EPSILON 0,0,0\n" + "0:0\n";
ATN atn = createATN(lg, true);
String result = ATNSerializer.getDecoded(atn, Arrays.asList(lg.getTokenNames()));
assertEquals(expecting, result);
}
use of org.antlr.v4.runtime.atn.ATN in project antlr4 by antlr.
the class TestATNSerialization method testEOF.
@Test
public void testEOF() throws Exception {
Grammar g = new Grammar("parser grammar T;\n" + "a : A EOF ;");
String expecting = "max type 1\n" + "0:RULE_START 0\n" + "1:RULE_STOP 0\n" + "2:BASIC 0\n" + "3:BASIC 0\n" + "4:BASIC 0\n" + "5:BASIC 0\n" + "rule 0:0\n" + "0->2 EPSILON 0,0,0\n" + "2->3 ATOM 1,0,0\n" + "3->4 ATOM 0,0,1\n" + "4->1 EPSILON 0,0,0\n";
ATN atn = createATN(g, true);
String result = ATNSerializer.getDecoded(atn, Arrays.asList(g.getTokenNames()));
assertEquals(expecting, result);
}
Aggregations