Commit c4befba8 authored by Alexandru Dura's avatar Alexandru Dura
Browse files

Expose the enumerateParseTrees as a static method

parent 2ed4d4c0
......@@ -86,9 +86,9 @@ public class Util {
return result;
}
public List<ParseTree> enumerateParseTrees(SPPFNode root,
Grammar grammar,
SPPFTrivialProductionRemover tpr) {
static public List<ParseTree> enumerateParseTrees(SPPFNode root,
Grammar grammar,
SPPFTrivialProductionRemover tpr) {
SPPFDebinarizeVisitor dbv = new SPPFDebinarizeVisitor();
dbv.visit(root);
......
......@@ -421,14 +421,6 @@ public class EarleyParserTest {
SPPFNode root = parser.parse(str, Java14Grammar.n_class_declaration);
assertNotNull(root);
Util.dumpParseResult("testJava5-bt.dot", root, g);
// debinarize
SPPFDebinarizeVisitor dbv = new SPPFDebinarizeVisitor();
dbv.visit(root);
Util.dumpParseResult("testJava5.dot", root, g);
// decorate nodes with the grammar rules
SPPFNodeDecorator dec = new SPPFNodeDecorator(g);
dec.visit(root);
// remove trivial productions
SPPFTrivialProductionRemover tpr = new SPPFTrivialProductionRemover(g) {
@Override public boolean isBubleUpChild(Category c) {
......@@ -439,12 +431,7 @@ public class EarleyParserTest {
return false;
}
};
tpr.visit(root);
Util.dumpParseResult("testJava5-notr.dot", root, g);
// dump the parse trees
ParseTreeGenerator ptg = new ParseTreeGenerator(g, root);
List<ParseTree> pts = ptg.getParseTrees();
List<ParseTree> pts = Util.enumerateParseTrees(root, g, tpr);
// the parsing should produce 3^6 parse trees
assertEquals(3*3*3*3*3*3, pts.size());
Util.dumpParseTrees("testJava5-parse-tree", pts);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment