Search in sources :

Example 36 with PredictionContext

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

the class TestGraphNodes method test_Aac_Ab.

@Test
public void test_Aac_Ab() {
    // a,c + b
    SingletonPredictionContext a = a();
    SingletonPredictionContext b = b();
    SingletonPredictionContext c = c();
    ArrayPredictionContext A1 = array(a, c);
    ArrayPredictionContext A2 = array(b);
    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)

Example 37 with PredictionContext

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

the class TestGraphNodes method test_a_a.

@Test
public void test_a_a() {
    PredictionContext r = PredictionContext.merge(a(), a(), 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 : 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 38 with PredictionContext

use of org.antlr.v4.runtime.atn.PredictionContext 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 39 with PredictionContext

use of org.antlr.v4.runtime.atn.PredictionContext 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)

Example 40 with PredictionContext

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

the class TestGraphNodes method test_a_b.

@Test
public void test_a_b() {
    PredictionContext r = PredictionContext.merge(a(), b(), rootIsWildcard(), null);
    //		System.out.println(toDOTString(r, rootIsWildcard()));
    String expecting = "digraph G {\n" + "rankdir=LR;\n" + "  s0[shape=record, label=\"<p0>|<p1>\"];\n" + "  s1[label=\"*\"];\n" + "  s0:p0->s1[label=\"1\"];\n" + "  s0:p1->s1[label=\"2\"];\n" + "}\n";
    assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
Also used : 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)39 PredictionContext (org.antlr.v4.runtime.atn.PredictionContext)39 SingletonPredictionContext (org.antlr.v4.runtime.atn.SingletonPredictionContext)39 Test (org.junit.Test)38 ArrayDeque (java.util.ArrayDeque)1 BitSet (java.util.BitSet)1 IdentityHashMap (java.util.IdentityHashMap)1 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)1 Ignore (org.junit.Ignore)1