use of org.antlr.v4.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestATNSerialization method testLexerUnicodeEscapedSMPNotSetWithRange.
@Test
public void testLexerUnicodeEscapedSMPNotSetWithRange() 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 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.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestATNSerialization method testLexerUnicodeEscapedBMPNotSet.
@Test
public void testLexerUnicodeEscapedBMPNotSet() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "ID : ~('\\u4E9C'|'\\u4E9D')\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:'\\u4E9C'..'\\u4E9D'\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.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestATNSerialization method testLexerTwoRules.
@Test
public void testLexerTwoRules() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "A : 'a' ;\n" + "B : 'b' ;\n");
String expecting = "max type 2\n" + "0:TOKEN_START -1\n" + "1:RULE_START 0\n" + "2:RULE_STOP 0\n" + "3:RULE_START 1\n" + "4:RULE_STOP 1\n" + "5:BASIC 0\n" + "6:BASIC 0\n" + "7:BASIC 1\n" + "8:BASIC 1\n" + "rule 0:1 1\n" + "rule 1:3 2\n" + "mode 0:0\n" + "0->1 EPSILON 0,0,0\n" + "0->3 EPSILON 0,0,0\n" + "1->5 EPSILON 0,0,0\n" + "3->7 EPSILON 0,0,0\n" + "5->6 ATOM 97,0,0\n" + "6->2 EPSILON 0,0,0\n" + "7->8 ATOM 98,0,0\n" + "8->4 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.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestATNSerialization method testLexerUnicodeUnescapedBMPSetWithRange.
@Test
public void testLexerUnicodeUnescapedBMPSetWithRange() throws Exception {
LexerGrammar lg = new LexerGrammar("lexer grammar L;\n" + "ID : ('亜'|'亝'|'江'|'た'..'ほ')\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:'\\u305F'..'\\u307B', '\\u4E9C'..'\\u4E9D', '\\u6C5F'..'\\u6C5F'\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.misc.EscapeSequenceParsing.Result in project antlr4 by antlr.
the class TestATNSerialization method testWildcard.
@Test
public void testWildcard() throws Exception {
Grammar g = new Grammar("parser grammar T;\n" + "tokens {A, B, C}\n" + "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->2 EPSILON 0,0,0\n" + "2->3 WILDCARD 0,0,0\n" + "3->1 EPSILON 0,0,0\n";
ATN atn = createATN(g, true);
String result = ATNSerializer.getDecoded(atn, Arrays.asList(g.getTokenNames()));
assertEquals(expecting, result);
}
Aggregations