<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,12 +3,13 @@ require_once dirname(__FILE__) . '/tree.php';
 
 class FuTreeDSLInterpreter extends Fu {
 
-	var $body, $output;
+	var $body, $defs = array(), $output;
 
 	function evaluate($node) {
-		if (method_exists($this, $method = 'sym' . $node-&gt;value())) {
+		if (method_exists($this, $method = 'sym' . $name = $node-&gt;value())) {
 			return call(array($this, $method), array($node-&gt;firstInner())); }
-		throw err('Undefined symbol')-&gt;ofName($node-&gt;value()); }
+		if (array_key_exists($name, $this-&gt;defs)) { return $this-&gt;defs[$name]; }
+		throw err('Undefined symbol')-&gt;ofName($name); }
 
 	function run($body) {
 		$this-&gt;output = new FuTreeWriter;
@@ -36,6 +37,9 @@ class FuTreeDSLInterpreter extends Fu {
 	function symCall($node) { return $this-&gt;evaluate($node)-&gt;output($this-&gt;output)-&gt;call(); }
 	function symThisFn() { return $this; }
 
+	function symDef($node) {
+		return $this-&gt;defs[$node-&gt;value()] = ($v = $node-&gt;next()) ? $this-&gt;evaluate($v) : null; }
+
 	function symIf($node) {
 		if (fuTrue($this-&gt;evaluate($node))) { return $this-&gt;evaluate($node-&gt;next()); }
 		if ($node = $node-&gt;next()-&gt;next()) {</diff>
      <filename>lib/tree_dsl.php</filename>
    </modified>
    <modified>
      <diff>@@ -97,4 +97,20 @@ class FnSpec extends DSLInterpreterSpec {
 		_($this-&gt;subj-&gt;run(n('thisFn')))-&gt;shouldBe($this-&gt;subj);
 		_($this-&gt;subj-&gt;run(
 			n('call', n('fn', n('null'), n('thisFn'))))-&gt;body())
-			-&gt;shouldEqual(nList(n('null'), n('thisFn'))); } }
\ No newline at end of file
+			-&gt;shouldEqual(nList(n('null'), n('thisFn'))); } }
+
+class DefSpec extends DSLInterpreterSpec {
+
+	function _should_define_new_sym_with_name_of_1st_and_value_of_2nd() {
+		_($this-&gt;subj-&gt;run(
+			nList(n('def', $this-&gt;undefed(), n('true')), $this-&gt;undefed())))-&gt;shouldBe(true);
+		_($this-&gt;subj-&gt;run(
+			nList(n('def', $this-&gt;undefed(), n('false')), $this-&gt;undefed())))-&gt;shouldBe(false); }
+
+	function _should_return_value_of_definition() {
+		_($this-&gt;subj-&gt;run(n('def', $this-&gt;undefed(), n('false'))))-&gt;shouldBe(false);
+		_($this-&gt;subj-&gt;run(n('def', $this-&gt;undefed(), n('true'))))-&gt;shouldBe(true); }
+
+	function _should_define_new_sym_as_null_of_2nd_omitted() {
+		_($this-&gt;subj-&gt;run(n('def', $this-&gt;undefed())))-&gt;shouldBe(null);
+		_($this-&gt;subj-&gt;run(nList(n('def', $this-&gt;undefed()), $this-&gt;undefed())))-&gt;shouldBe(null); } }
\ No newline at end of file</diff>
      <filename>spec/tree_dsl.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a4645b5db5f5fde6d299d724b2308453ff3f24dd</id>
    </parent>
  </parents>
  <author>
    <name>ole</name>
    <email>oliver.saunders@gmail.com</email>
  </author>
  <url>http://github.com/olliesaunders/fluidics/commit/da90dd033166dcd31d960f00cc279b3824680e04</url>
  <id>da90dd033166dcd31d960f00cc279b3824680e04</id>
  <committed-date>2009-11-09T03:46:05-08:00</committed-date>
  <authored-date>2009-11-09T03:46:01-08:00</authored-date>
  <message>Tree DSL: Added def, not completely lexical yet.</message>
  <tree>c047940ab0c642493a5456c5539200502464e8c8</tree>
  <committer>
    <name>ole</name>
    <email>oliver.saunders@gmail.com</email>
  </committer>
</commit>
