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

Add a convenience function to get the parse trees

parent a2d41e0a
......@@ -33,6 +33,3 @@ subprojects {
maxParallelForks = Runtime.runtime.availableProcessors()
}
}
// Define the main class for the application
mainClassName = 'Schedule'
......@@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.mutable.MutableInt;
......@@ -84,6 +85,26 @@ public class Util {
return result;
}
public List<ParseTree> enumerateParseTrees(SPPFNode root,
Grammar grammar,
SPPFTrivialProductionRemover tpr) {
SPPFDebinarizeVisitor dbv = new SPPFDebinarizeVisitor();
dbv.visit(root);
// decorate nodes with the grammar rules
SPPFNodeDecorator dec = new SPPFNodeDecorator(grammar);
dec.visit(root);
// remove trivial productions
tpr.visit(root);
// generate all the possible parse trees
ParseTreeGenerator ptg = new ParseTreeGenerator(grammar, root);
List<ParseTree> pts = ptg.getParseTrees();
return pts;
}
}
class DotVisitor implements SPPFNodeVisitor {
......
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