use of org.antlr.v4.runtime.atn.PredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_ax_ax_same.
@Test
public void test_ax_ax_same() {
PredictionContext x = x();
PredictionContext a1 = createSingleton(x, 1);
PredictionContext a2 = createSingleton(x, 1);
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=\"1\"];\n" + " s2[label=\"*\"];\n" + " s0->s1[label=\"1\"];\n" + " s1->s2[label=\"9\"];\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_abx_abx.
@Test
public void test_abx_abx() {
PredictionContext x1 = x();
PredictionContext x2 = x();
PredictionContext b1 = createSingleton(x1, 2);
PredictionContext b2 = createSingleton(x2, 2);
PredictionContext a1 = createSingleton(b1, 1);
PredictionContext a2 = createSingleton(b2, 1);
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=\"1\"];\n" + " s2[label=\"2\"];\n" + " s3[label=\"*\"];\n" + " s0->s1[label=\"1\"];\n" + " s1->s2[label=\"2\"];\n" + " s2->s3[label=\"9\"];\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_ax$_a$.
@Test
public void test_ax$_a$() {
PredictionContext x = x();
PredictionContext a1 = createSingleton(x, 1);
PredictionContext a2 = a();
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()));
}
use of org.antlr.v4.runtime.atn.PredictionContext in project antlr4 by antlr.
the class TestGraphNodes method test_$_x.
@Test
public void test_$_x() {
PredictionContext r = PredictionContext.merge(PredictionContext.EMPTY, x(), rootIsWildcard(), null);
// System.out.println(toDOTString(r, rootIsWildcard()));
String expecting = "digraph G {\n" + "rankdir=LR;\n" + " s0[label=\"*\"];\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_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