Search in sources :

Example 11 with SingletonPredictionContext

use of org.antlr.v4.runtime.atn.SingletonPredictionContext in project antlr4 by antlr.

the class TestGraphNodes method test_Aa_Aa.

@Test
public void test_Aa_Aa() {
    SingletonPredictionContext a1 = a();
    SingletonPredictionContext a2 = a();
    ArrayPredictionContext A1 = array(a1);
    ArrayPredictionContext A2 = array(a2);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    //		System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting = "digraph G {\n" + "rankdir=LR;\n" + "  s0[label=\"0\"];\n" + "  s1[label=\"*\"];\n" + "  s0->s1[label=\"1\"];\n" + "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
Also used : ArrayPredictionContext(org.antlr.v4.runtime.atn.ArrayPredictionContext) SingletonPredictionContext(org.antlr.v4.runtime.atn.SingletonPredictionContext) SingletonPredictionContext(org.antlr.v4.runtime.atn.SingletonPredictionContext) PredictionContext(org.antlr.v4.runtime.atn.PredictionContext) ArrayPredictionContext(org.antlr.v4.runtime.atn.ArrayPredictionContext) Test(org.junit.Test)

Example 12 with SingletonPredictionContext

use of org.antlr.v4.runtime.atn.SingletonPredictionContext in project antlr4 by antlr.

the class TestGraphNodes method test_Aab_Ac.

@Test
public void test_Aab_Ac() {
    // a,b + c
    SingletonPredictionContext a = a();
    SingletonPredictionContext b = b();
    SingletonPredictionContext c = c();
    ArrayPredictionContext A1 = array(a, b);
    ArrayPredictionContext A2 = array(c);
    PredictionContext r = PredictionContext.merge(A1, A2, rootIsWildcard(), null);
    //		System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting = "digraph G {\n" + "rankdir=LR;\n" + "  s0[shape=record, label=\"<p0>|<p1>|<p2>\"];\n" + "  s1[label=\"*\"];\n" + "  s0:p0->s1[label=\"1\"];\n" + "  s0:p1->s1[label=\"2\"];\n" + "  s0:p2->s1[label=\"3\"];\n" + "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
Also used : ArrayPredictionContext(org.antlr.v4.runtime.atn.ArrayPredictionContext) SingletonPredictionContext(org.antlr.v4.runtime.atn.SingletonPredictionContext) SingletonPredictionContext(org.antlr.v4.runtime.atn.SingletonPredictionContext) PredictionContext(org.antlr.v4.runtime.atn.PredictionContext) ArrayPredictionContext(org.antlr.v4.runtime.atn.ArrayPredictionContext) Test(org.junit.Test)

Aggregations

ArrayPredictionContext (org.antlr.v4.runtime.atn.ArrayPredictionContext)12 PredictionContext (org.antlr.v4.runtime.atn.PredictionContext)12 SingletonPredictionContext (org.antlr.v4.runtime.atn.SingletonPredictionContext)12 Test (org.junit.Test)12