use of org.antlr.v4.tool.Grammar in project antlr4 by antlr.
the class TestATNConstruction method testAorB.
@Test
public void testAorB() throws Exception {
Grammar g = new Grammar("parser grammar P;\n" + "a : A | B {;} ;");
String expecting = "RuleStart_a_0->BlockStart_5\n" + "BlockStart_5->s2\n" + "BlockStart_5->s3\n" + "s2-A->BlockEnd_6\n" + "s3-B->s4\n" + "BlockEnd_6->RuleStop_a_1\n" + "s4-action_0:-1->BlockEnd_6\n" + "RuleStop_a_1-EOF->s7\n";
checkRuleATN(g, "a", expecting);
}
use of org.antlr.v4.tool.Grammar in project antlr4 by antlr.
the class TestATNConstruction method testRangeOrRange.
@Test
public void testRangeOrRange() throws Exception {
LexerGrammar g = new LexerGrammar("lexer grammar P;\n" + "A : ('a'..'c' 'h' | 'q' 'j'..'l') ;");
String expecting = "s0->RuleStart_A_1\n" + "RuleStart_A_1->BlockStart_7\n" + "BlockStart_7->s3\n" + "BlockStart_7->s5\n" + "s3-'a'..'c'->s4\n" + "s5-'q'->s6\n" + "s4-'h'->BlockEnd_8\n" + "s6-'j'..'l'->BlockEnd_8\n" + "BlockEnd_8->RuleStop_A_2\n";
checkTokensRule(g, null, expecting);
}
use of org.antlr.v4.tool.Grammar in project antlr4 by antlr.
the class TestATNConstruction method testCharSetUnicodeBMPEscapeRange.
@Test
public void testCharSetUnicodeBMPEscapeRange() throws Exception {
LexerGrammar g = new LexerGrammar("lexer grammar P;\n" + "A : [a-c\\uABCD-\\uABFF] ;");
String expecting = "s0->RuleStart_A_1\n" + "RuleStart_A_1->s3\n" + "s3-{97..99, 43981..44031}->s4\n" + "s4->RuleStop_A_2\n";
checkTokensRule(g, null, expecting);
}
use of org.antlr.v4.tool.Grammar in project antlr4 by antlr.
the class TestATNConstruction method testAorEpsilon.
@Test
public void testAorEpsilon() throws Exception {
Grammar g = new Grammar("parser grammar P;\n" + "a : A | ;");
String expecting = "RuleStart_a_0->BlockStart_4\n" + "BlockStart_4->s2\n" + "BlockStart_4->s3\n" + "s2-A->BlockEnd_5\n" + "s3->BlockEnd_5\n" + "BlockEnd_5->RuleStop_a_1\n" + "RuleStop_a_1-EOF->s6\n";
checkRuleATN(g, "a", expecting);
}
use of org.antlr.v4.tool.Grammar in project antlr4 by antlr.
the class TestATNConstruction method testEmptyOrEmpty.
@Test
public void testEmptyOrEmpty() throws Exception {
Grammar g = new Grammar("parser grammar P;\n" + "a : | ;");
String expecting = "RuleStart_a_0->BlockStart_4\n" + "BlockStart_4->s2\n" + "BlockStart_4->s3\n" + "s2->BlockEnd_5\n" + "s3->BlockEnd_5\n" + "BlockEnd_5->RuleStop_a_1\n" + "RuleStop_a_1-EOF->s6\n";
checkRuleATN(g, "a", expecting);
}
Aggregations