package nuthatch.examples.steve.xmpl;

import static nuthatch.examples.xmpllang.expronly.ExprPatterns.Add;
import static nuthatch.examples.xmpllang.expronly.ExprPatterns.Int;
import nuthatch.examples.steve.actions.UnitLawAdd;
import nuthatch.examples.steve.strategies.OnceTD;
import nuthatch.examples.xmpllang.Expr;
import nuthatch.examples.xmpllang.expronly.ExprCursor;
import nuthatch.examples.xmpllang.expronly.ExprWalker;

public class OnceTDTest {
	public static void main(String[] args) {

		// Possible trees to be walked
		Expr e = Add(Int(5), Add(Add(Int(7), Int(3)), Int(0)));
		//Expr e = Add(Int(5), Int(0));
		//Expr e = Add(Add(Int(5), Int(0)), Add(Int(5), Int(0)));

		UnitLawAdd unitLawAdd = new UnitLawAdd();
		OnceTD onceTD = new OnceTD(unitLawAdd);

		ExprWalker walker = new ExprWalker(new ExprCursor(e), new OnceTD(new UnitLawAdd()));
		walker.start();

		for(String msg : onceTD.getLog()) {
			System.out.println(msg);
		}

		System.out.println("Result: " + walker.treeToString());
	}
}
