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

Add a test for the ParseTreeGenerator

parent 0a1e355b
import java.util.List;
import org.junit.Test;
import se.lth.sep.*;
import static org.junit.Assert.*;
public class ParseTreeGeneratorTest {
@Test public void test1() {
Grammar g = new Grammar();
EarleyParser parser = new EarleyParser(g);
Category str[] = {Java14Grammar.t_LPAREN,
SPPFNode root = parser.parse(str, Java14Grammar.n_expression);
SPPFTrivialProductionRemover tpr = new SPPFTrivialProductionRemover(g) {
@Override public boolean isBubleUpChild(Category p, Category c) {
if (c.getName().equals("METAVARID"))
return true;
if (c.getName().equals("GAP"))
return true;
return false;
SPPFDebinarizeVisitor dbv = new SPPFDebinarizeVisitor();
// decorate nodes with the grammar rules
SPPFNodeDecorator dec = new SPPFNodeDecorator(g);
// remove trivial productions
// generate all the possible parse trees
ParseTreeGenerator ptg = new ParseTreeGenerator(g, root);
List<ParseTree> pts1 = ptg.getParseTrees();
List<ParseTree> pts = pts1;
assertEquals(1, pts.size());
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