String result = ATNSerializer.getDecoded(atn, Arrays.asList(lg.getTokenNames()));
assertEquals(expecting, result);
}
@Test public void testLexerWildcardWithMode() throws Exception {
LexerGrammar lg = new LexerGrammar(
"lexer grammar L;\n"+
"ID : 'a'..'z'+ ;\n"+
"mode CMT;" +
"COMMENT : '*/' {skip(); popMode();} ;\n" +
"JUNK : . {more();} ;\n");
String expecting =
"max type 3\n" +
"0:TOKEN_START -1\n" +
"1:TOKEN_START -1\n" +
"2:RULE_START 0\n" +
"3:RULE_STOP 0\n" +
"4:RULE_START 1\n" +
"5:RULE_STOP 1\n" +
"6:RULE_START 2\n" +
"7:RULE_STOP 2\n" +
"8:BASIC 0\n" +
"9:PLUS_BLOCK_START 0 10\n" +
"10:BLOCK_END 0\n" +
"11:PLUS_LOOP_BACK 0\n" +
"12:LOOP_END 0 11\n" +
"13:BASIC 1\n" +
"14:BASIC 1\n" +
"15:BASIC 1\n" +
"16:BASIC 1\n" +
"17:BASIC 1\n" +
"18:BASIC 2\n" +
"19:BASIC 2\n" +
"20:BASIC 2\n" +
"rule 0:2 1\n" +
"rule 1:4 2\n" +
"rule 2:6 3\n" +
"mode 0:0\n" +
"mode 1:1\n" +
"0->2 EPSILON 0,0,0\n" +
"1->4 EPSILON 0,0,0\n" +
"1->6 EPSILON 0,0,0\n" +
"2->9 EPSILON 0,0,0\n" +
"4->13 EPSILON 0,0,0\n" +
"6->18 EPSILON 0,0,0\n" +
"8->10 RANGE 97,122,0\n" +
"9->8 EPSILON 0,0,0\n" +
"10->11 EPSILON 0,0,0\n" +
"11->9 EPSILON 0,0,0\n" +
"11->12 EPSILON 0,0,0\n" +
"12->3 EPSILON 0,0,0\n" +
"13->14 ATOM 42,0,0\n" +
"14->15 ATOM 47,0,0\n" +
"15->16 EPSILON 0,0,0\n" +
"16->17 ACTION 1,0,0\n" +
"17->5 EPSILON 0,0,0\n" +
"18->19 WILDCARD 0,0,0\n" +
"19->20 ACTION 2,1,0\n" +
"20->7 EPSILON 0,0,0\n" +
"0:0\n" +
"1:1\n" +
"2:11\n";
ATN atn = createATN(lg, true);
String result = ATNSerializer.getDecoded(atn, Arrays.asList(lg.getTokenNames()));
assertEquals(expecting, result);
}