use of org.antlr.v4.runtime.atn.PredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_ax$_a$_fullctx.
@Test
public void test_ax$_a$_fullctx() {
PredictionContext x = x();
PredictionContext a1 = createSingleton(x, 1);
PredictionContext a2 = a();
PredictionContext r = PredictionContext.merge(a1, a2, fullCtx(), null);
// System.out.println(toDOTString(r, fullCtx()));
String expecting = "digraph G {\n" + "rankdir=LR;\n" + " s0[label=\"0\"];\n" + " s1[shape=record, label=\"<p0>|<p1>$\"];\n" + " s2[label=\"$\"];\n" + " s0->s1[label=\"1\"];\n" + " s1:p0->s2[label=\"9\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, fullCtx()));
}
use of org.antlr.v4.runtime.atn.PredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aa_Abc.
@Test
public void test_Aa_Abc() {
// a + b,c
SingletonPredictionContext a = a();
SingletonPredictionContext b = b();
SingletonPredictionContext c = c();
ArrayPredictionContext A1 = array(a);
ArrayPredictionContext A2 = array(b, 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()));
}
use of org.antlr.v4.runtime.atn.PredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_aa$_a$_$_fullCtx.
@Test
public void test_aa$_a$_$_fullCtx() {
PredictionContext empty = PredictionContext.EMPTY;
PredictionContext child1 = createSingleton(empty, 8);
PredictionContext right = PredictionContext.merge(empty, child1, false, null);
PredictionContext left = createSingleton(right, 8);
PredictionContext merged = PredictionContext.merge(left, right, false, null);
String actual = toDOTString(merged, false);
// System.out.println(actual);
String expecting = "digraph G {\n" + "rankdir=LR;\n" + " s0[shape=record, label=\"<p0>|<p1>$\"];\n" + " s1[shape=record, label=\"<p0>|<p1>$\"];\n" + " s2[label=\"$\"];\n" + " s0:p0->s1[label=\"8\"];\n" + " s1:p0->s2[label=\"8\"];\n" + "}\n";
assertEquals(expecting, actual);
}
use of org.antlr.v4.runtime.atn.PredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aaubv_Abvdx.
@Test
public void test_Aaubv_Abvdx() {
// au,bv + bv,dx -> [a,b,d]->[u,v,x]
SingletonPredictionContext a = createSingleton(u(), 1);
SingletonPredictionContext b1 = createSingleton(v(), 2);
SingletonPredictionContext b2 = createSingleton(v(), 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[label=\"2\"];\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->s4[label=\"7\"];\n" + " s1->s4[label=\"6\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
use of org.antlr.v4.runtime.atn.PredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_Aab_Aa.
@Test
public void test_Aab_Aa() {
// a,b + a
ArrayPredictionContext A1 = array(a(), b());
ArrayPredictionContext A2 = array(a());
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" + " s1[label=\"*\"];\n" + " s0:p0->s1[label=\"1\"];\n" + " s0:p1->s1[label=\"2\"];\n" + "}\n";
assertEquals(expecting, toDOTString(r, rootIsWildcard()));
}
Aggregations