<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>testargs.l</filename>
    </added>
    <added>
      <filename>testarray.l</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -6,33 +6,22 @@ parser: parser.o runtime.o
 
 parser.o: parser.s
 
-parser.s: parser.rb
-	ruby parser.rb &gt;parser.s
-
-
-parser2: parser2.o runtime.o
-
-parser2.o: parser2.s
-
-parser2.s: parser2.rb parser
-	ruby parser2.rb &gt;parser2.s
-
-parser2.rb: parser.l parser
-	@./parser &lt;parser.l &gt;parser2.rb
+parser.s: parser.l
+	ruby compiler.rb &lt;parser.l &gt;parser.s
 
 clean:
-	@rm -f *~ *.o *.s parser parser2
+	@rm -f *~ *.o *.s parser testarray testargs
 
-testarray.s: testarray.rb
-	ruby testarray.rb &gt;testarray.s
+testarray.s: testarray.l
+	ruby compiler.rb &lt;testarray.l &gt;testarray.s
 
 testarray.o: testarray.s 
 
 testarray: testarray.o runtime.o
 	gcc -o testarray testarray.o runtime.o
 
-testargs.s: testargs.rb
-	ruby testargs.rb &gt;testargs.s
+testargs.s: testargs.l
+	ruby compiler.rb &lt;testargs.l &gt;testargs.s
 
 testargs.o: testargs.s
 </diff>
      <filename>Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 #!/bin/env ruby
 
 require 'emitter'
+require 'sexp'
 
 DO_BEFORE= [ 
   [:defun, :array, [:size],[:malloc,[:mul,:size,4]]]
@@ -259,3 +260,19 @@ class Compiler
   end  
 end
 
+s = Scanner.new(STDIN)
+prog = nil
+
+begin
+  prog = SEXParser.new(s).parse
+rescue Exception =&gt; e
+  STDERR.puts &quot;#{e.message}&quot;
+  STDERR.puts &quot;Failed before:\n&quot;
+  buf = &quot;&quot;
+  while s.peek &amp;&amp; buf.size &lt; 100
+    buf += s.get
+  end
+  STDERR.puts buf
+end
+
+Compiler.new.compile(prog) if prog</diff>
      <filename>compiler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -30,21 +30,9 @@ class SEXParser
   end
 
   def parse_exp
+    ws
     (ret = @s.expect(Atom) || @s.expect(Int) || @s.expect(Quoted) || parse_sexp) &amp;&amp; ws
     return ret
   end
 end
 
-s = Scanner.new(STDIN)
-
-begin
-  PP.pp SEXParser.new(s).parse
-rescue Exception =&gt; e
-  PP.pp e
-  buf = &quot;&quot;
-  while s.peek
-    buf += s.get
-  end
-  puts buf
-end
-</diff>
      <filename>sexp.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>parser.rb</filename>
    </removed>
    <removed>
      <filename>testargs.rb</filename>
    </removed>
    <removed>
      <filename>testarray.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>40801c6e5b77db3a32d39368b1adfdc88fc70bdc</id>
    </parent>
  </parents>
  <author>
    <name>Vidar Hokstad</name>
    <email>vidar@hokstad.com</email>
  </author>
  <url>http://github.com/vidarh/writing-a-compiler-in-ruby/commit/5484cf8581d1d0d0ff1b21f129f3d031da0d568a</url>
  <id>5484cf8581d1d0d0ff1b21f129f3d031da0d568a</id>
  <committed-date>2009-02-14T04:34:00-08:00</committed-date>
  <authored-date>2009-02-14T04:34:00-08:00</authored-date>
  <message>Converted test programs to the 'lisp like' s-expression syntax; Made the compiler driver use the s-expression parser as a frontend</message>
  <tree>aae65dcb34c04d835fe6de32c8005187a413bf68</tree>
  <committer>
    <name>Vidar Hokstad</name>
    <email>vidar@hokstad.com</email>
  </committer>
</commit>
