% A test function for the "getyields" predicate, % which finds yields of a given size of symbols % of a context-free grammar test:- makegrammar(s,[np,vp,pp],[P1,P2,P3,P4,P5,P6,P7,P8],G), makerule(s, [np, vp], P1), makerule(np, [det, n], P2), makerule(np, [det, n, pp], P3), makerule(pp, [p, np], P4), makerule(vp, [v], P5), makerule(vp, [v, np], P6), makerule(vp, [v, pp], P7), makerule(vp, [v, np, pp], P8), getyields(G,s,3,Z1), print(Z1), nl, getyields(G,s,4,Z2), print(Z2), nl, getyields(G,s,5,Z3), print(Z3), nl, getyields(G,s,6,Z4), print(Z4), nl, getyields(G,s,7,Z5), print(Z5), nl, getyields(G,s,8,Z6), print(Z6), nl, makegrammar(s,[],[R1,R2],G1), makerule(s,[x],R1), makerule(s,[x,s,s],R2), getyields(G1,s,3,Y1), print(Y1), nl, getyields(G1,s,5,Y2), print(Y2), nl, getyields(G1,s,6,Y3), print(Y3), nl, getyields(G1,s,7,Y4), print(Y4), nl, makegrammar(e,[t,f],[R3,R4,R5,R6,R7,R8,R9],G2), makerule(e,[t],R3), makerule(e,[t, +, e],R4), makerule(t,[f],R5), makerule(t,[f, *, t],R6), makerule(f,[x],R7), makerule(f,[y],R8), makerule(f,[<, e, >],R9), getyields(G2,e,1,W1), print(W1), nl, getyields(G2,e,3,W2), print(W2), nl, getyields(G2,e,4,W3), print(W3), nl, getyields(G2,e,5,W4), print(W4), nl, length(W4,L4), print(L4), nl, nl.