use of org.antlr.v4.runtime.atn.SingletonPredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aaxc_Aayd.
@Test
public void test_Aaxc_Aayd() {
// ax,c + ay,d -> merged a, array parent
SingletonPredictionContext a1 = createSingleton(x(), 1);
SingletonPredictionContext a2 = createSingleton(y(), 1);
ArrayPredictionContext A1 = array(a1, c());
ArrayPredictionContext A2 = array(a2, d());
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" + " s2[label=\"*\"];\n" + " s1[shape=record, label=\"<p0>|<p1>\"];\n" + " s0:p0->s1[label=\"1\"];\n" + " s0:p1->s2[label=\"3\"];\n" + " s0:p2->s2[label=\"4\"];\n" + " s1:p0->s2[label=\"9\"];\n" + " s1:p1->s2[label=\"10\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
use of org.antlr.v4.runtime.atn.SingletonPredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aax_Aby.
@Test
public void test_Aax_Aby() {
// ax + by but in arrays
SingletonPredictionContext a = createSingleton(x(), 1);
SingletonPredictionContext b = createSingleton(y(), 2);
ArrayPredictionContext A1 = array(a);
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>\"];\n" + " s2[label=\"2\"];\n" + " s3[label=\"*\"];\n" + " s1[label=\"1\"];\n" + " s0:p0->s1[label=\"1\"];\n" + " s0:p1->s2[label=\"2\"];\n" + " s2->s3[label=\"10\"];\n" + " s1->s3[label=\"9\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
use of org.antlr.v4.runtime.atn.SingletonPredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aaubv_Acwdx.
@Test
public void test_Aaubv_Acwdx() {
// au,bv + cw,dx -> [a,b,c,d]->[u,v,w,x]
SingletonPredictionContext a = createSingleton(u(), 1);
SingletonPredictionContext b = createSingleton(v(), 2);
SingletonPredictionContext c = createSingleton(w(), 3);
SingletonPredictionContext d = createSingleton(x(), 4);
ArrayPredictionContext A1 = array(a, b);
ArrayPredictionContext A2 = array(c, d);
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>|<p3>\"];\n" + " s4[label=\"4\"];\n" + " s5[label=\"*\"];\n" + " s3[label=\"3\"];\n" + " s2[label=\"2\"];\n" + " s1[label=\"1\"];\n" + " s0:p0->s1[label=\"1\"];\n" + " s0:p1->s2[label=\"2\"];\n" + " s0:p2->s3[label=\"3\"];\n" + " s0:p3->s4[label=\"4\"];\n" + " s4->s5[label=\"9\"];\n" + " s3->s5[label=\"8\"];\n" + " s2->s5[label=\"7\"];\n" + " s1->s5[label=\"6\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
use of org.antlr.v4.runtime.atn.SingletonPredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aaubv_Abwdx.
@Test
public void test_Aaubv_Abwdx() {
// au,bv + bw,dx -> [a,b,d]->[u,[v,w],x]
SingletonPredictionContext a = createSingleton(u(), 1);
SingletonPredictionContext b1 = createSingleton(v(), 2);
SingletonPredictionContext b2 = createSingleton(w(), 2);
SingletonPredictionContext d = createSingleton(x(), 4);
ArrayPredictionContext A1 = array(a, b1);
ArrayPredictionContext A2 = array(b2, d);
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" + " s3[label=\"3\"];\n" + " s4[label=\"*\"];\n" + " s2[shape=record, label=\"<p0>|<p1>\"];\n" + " s1[label=\"1\"];\n" + " s0:p0->s1[label=\"1\"];\n" + " s0:p1->s2[label=\"2\"];\n" + " s0:p2->s3[label=\"4\"];\n" + " s3->s4[label=\"9\"];\n" + " s2:p0->s4[label=\"7\"];\n" + " s2:p1->s4[label=\"8\"];\n" + " s1->s4[label=\"6\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
use of org.antlr.v4.runtime.atn.SingletonPredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aaubu_Acudu.
@Test
public void test_Aaubu_Acudu() {
// au,bu + cu,du -> [a,b,c,d]->[u,u,u,u]
SingletonPredictionContext a = createSingleton(u(), 1);
SingletonPredictionContext b = createSingleton(u(), 2);
SingletonPredictionContext c = createSingleton(u(), 3);
SingletonPredictionContext d = createSingleton(u(), 4);
ArrayPredictionContext A1 = array(a, b);
ArrayPredictionContext A2 = array(c, d);
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>|<p3>\"];\n" + " s1[label=\"1\"];\n" + " s2[label=\"*\"];\n" + " s0:p0->s1[label=\"1\"];\n" + " s0:p1->s1[label=\"2\"];\n" + " s0:p2->s1[label=\"3\"];\n" + " s0:p3->s1[label=\"4\"];\n" + " s1->s2[label=\"6\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
Aggregations