<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -10,13 +10,17 @@ class FuTreeDSLInterpreter extends Fu {
 			return call(array($this, $method), array($node-&gt;firstInner())); }
 		throw err('Undefined direction')-&gt;ofName($node-&gt;value()); }
 
-	function dirInform($node) { $this-&gt;information[] = $this-&gt;evaluate($node); }
+	function dirTrue()      { return true;  }
+	function dirFalse()     { return false; }
+	function dirNode($node) { return $node; }
+	function dirStr($node)  { return $node-&gt;value(); }
+	function dirExpr($node) { return eval('return ' . $node-&gt;value() . ';'); }
 
-	function dirTrue()  { return true;  }
-	function dirFalse() { return false; }
+	function dirInform($node) { $this-&gt;information[] = $this-&gt;evaluate($node); }
 
-	function dirStr($node) { return $node-&gt;value(); }
-	function dirNode($node) { return $node; }
+	function dirIf($node) {
+		if (fuTrue($this-&gt;evaluate($node))) { return $this-&gt;evaluate($node-&gt;next()); }
+		return $this-&gt;evaluate($node-&gt;next()-&gt;next()); }
 
 	function dirWrite($node) {
 		$written = $this-&gt;output-&gt;write($this-&gt;evaluate($node));</diff>
      <filename>lib/tree_dsl.php</filename>
    </modified>
    <modified>
      <diff>@@ -2,9 +2,10 @@
 require_once dirname(__FILE__) . '/lib/tree.php';
 require_once dirname(__FILE__) . '/../lib/tree_dsl.php';
 
-class InterpreterSpec extends PweSpec {
+class DSLInterpreterSpec extends PweSpec {
+	function beforeEach() { $this-&gt;subj = new FuTreeDSLInterpreter; } }
 
-	function beforeEach() { $this-&gt;subj = new FuTreeDSLInterpreter; }
+class InterpreterSpec extends DSLInterpreterSpec {
 
 	function _should_return_null_for_empty_tree() {
 		_($this-&gt;subj-&gt;run(null))-&gt;shouldBe(null); }
@@ -25,9 +26,7 @@ class InterpreterSpec extends PweSpec {
 		_($this-&gt;subj-&gt;run($tree))-&gt;shouldBe(null);
 		_($this-&gt;subj-&gt;information())-&gt;shouldBe(array($expected)); } }
 
-class WriteDirectionSpec extends PweSpec {
-
-	function beforeEach() { $this-&gt;subj = new FuTreeDSLInterpreter; }
+class WriteDirectionSpec extends DSLInterpreterSpec {
 
 	function _should_eval_first_param_and_create_node_from_evaluation_return() {
 		_($this-&gt;subj-&gt;run(n('write', n('node', n('foo')))))-&gt;shouldEqual(n('foo')); }
@@ -42,4 +41,25 @@ class WriteDirectionSpec extends PweSpec {
 
 	function _should_be_able_to_write_a_whole_tree() {
 		$tree = n('write', n('node', n('foo', n('bar'), n('zim'))));
-		_($this-&gt;subj-&gt;run($tree))-&gt;shouldEqual(n('foo', n('bar'), n('zim'))); } }
\ No newline at end of file
+		_($this-&gt;subj-&gt;run($tree))-&gt;shouldEqual(n('foo', n('bar'), n('zim'))); } }
+
+class ExprDirectionSpec extends DSLInterpreterSpec {
+
+	function _should_evaluate_php() {
+		$this-&gt;subj-&gt;run(n('inform', n('expr', n('join(&quot;/&quot;, array((string)2*4, &quot;foo&quot;))'))));
+		_($this-&gt;subj-&gt;information())-&gt;shouldBe(array('8/foo')); } }
+
+class IfDirectionSpec extends DSLInterpreterSpec {
+
+	function _should_evaluate_2nd_and_return_result_if_1st_evaluates_true() {
+		$this-&gt;subj-&gt;run(n('inform', n('if', n('true'), n('str', n('foo')), n('str', n('bar')))));
+		_($this-&gt;subj-&gt;information())-&gt;shouldBe(array('foo')); }
+
+	function _should_evaluate_3nd_and_return_result_if_1st_evaluates_false() {
+		$this-&gt;subj-&gt;run(n('inform', n('if', n('false'), n('str', n('foo')), n('str', n('bar')))));
+		_($this-&gt;subj-&gt;information())-&gt;shouldBe(array('bar')); }
+
+	function _should_not_have_silly_php_definition_of_false() {
+		$tree = n('inform', n('if', n('expr', n('array()')), n('str', n('foo')), n('str', n('bar'))));
+		$this-&gt;subj-&gt;run($tree);
+		_($this-&gt;subj-&gt;information())-&gt;shouldBe(array('foo')); } }
\ No newline at end of file</diff>
      <filename>spec/tree_dsl.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>93b71c411f05f3b384e61e7adbe337fb577a8b9e</id>
    </parent>
  </parents>
  <author>
    <name>ole</name>
    <email>oliver.saunders@gmail.com</email>
  </author>
  <url>http://github.com/olliesaunders/fluidics/commit/29697bab5f121a3536b251f6e99141f4b7d5b93f</url>
  <id>29697bab5f121a3536b251f6e99141f4b7d5b93f</id>
  <committed-date>2009-11-08T00:43:19-08:00</committed-date>
  <authored-date>2009-11-08T00:43:19-08:00</authored-date>
  <message>Tree DSL: Added if and expr directions.</message>
  <tree>d2bf9ef44bbe1348f5fd5336ddd0ae55ecc9939d</tree>
  <committer>
    <name>ole</name>
    <email>oliver.saunders@gmail.com</email>
  </committer>
</commit>
