<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>spec/compiler/test_grammar_do.treetop</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -12,14 +12,17 @@ end
 
 compiler = Treetop::Compiler::GrammarCompiler.new
 
-# explicit output file name option
-if ARGV.size == 3 &amp;&amp; ARGV[1] == '-o'
-  compiler.compile(ARGV[0], ARGV[2])
-  exit
-end
-
-# list of input files option
-treetop_files = ARGV
-treetop_files.each do |treetop_file_path|
-  compiler.compile(treetop_file_path)
+while !ARGV.empty?
+  treetop_file = ARGV.shift
+  if !File.exist?(treetop_file)
+    puts &quot;Error: file '#{treetop_file}' doesn't exist\n\n&quot;
+    exit(2) 
+  end
+  if ARGV.size &gt;= 2 &amp;&amp; ARGV[1] == '-o'
+    ARGV.shift	  # explicit output file name option
+    compiler.compile(treetop_file, ARGV.shift)
+  else
+    # list of input files option
+    compiler.compile(treetop_file)
+  end
 end</diff>
      <filename>bin/tt</filename>
    </modified>
    <modified>
      <diff>@@ -232,6 +232,12 @@ module Treetop
         def space
           elements[1]
         end
+      end
+
+      module Grammar1
+        def space
+          elements[1]
+        end
 
         def grammar_name
           elements[2]
@@ -242,7 +248,7 @@ module Treetop
         end
 
         def declaration_sequence
-          elements[4]
+          elements[5]
         end
 
       end
@@ -274,25 +280,53 @@ module Treetop
               r4 = _nt_space
               s0 &lt;&lt; r4
               if r4
-                r5 = _nt_declaration_sequence
+                i6, s6 = index, []
+                if input.index('do', index) == index
+                  r7 = (SyntaxNode).new(input, index...(index + 2))
+                  @index += 2
+                else
+                  terminal_parse_failure('do')
+                  r7 = nil
+                end
+                s6 &lt;&lt; r7
+                if r7
+                  r8 = _nt_space
+                  s6 &lt;&lt; r8
+                end
+                if s6.last
+                  r6 = (SyntaxNode).new(input, i6...index, s6)
+                  r6.extend(Grammar0)
+                else
+                  self.index = i6
+                  r6 = nil
+                end
+                if r6
+                  r5 = r6
+                else
+                  r5 = SyntaxNode.new(input, index...index)
+                end
                 s0 &lt;&lt; r5
                 if r5
-                  r7 = _nt_space
-                  if r7
-                    r6 = r7
-                  else
-                    r6 = SyntaxNode.new(input, index...index)
-                  end
-                  s0 &lt;&lt; r6
-                  if r6
-                    if input.index('end', index) == index
-                      r8 = (SyntaxNode).new(input, index...(index + 3))
-                      @index += 3
+                  r9 = _nt_declaration_sequence
+                  s0 &lt;&lt; r9
+                  if r9
+                    r11 = _nt_space
+                    if r11
+                      r10 = r11
                     else
-                      terminal_parse_failure('end')
-                      r8 = nil
+                      r10 = SyntaxNode.new(input, index...index)
+                    end
+                    s0 &lt;&lt; r10
+                    if r10
+                      if input.index('end', index) == index
+                        r12 = (SyntaxNode).new(input, index...(index + 3))
+                        @index += 3
+                      else
+                        terminal_parse_failure('end')
+                        r12 = nil
+                      end
+                      s0 &lt;&lt; r12
                     end
-                    s0 &lt;&lt; r8
                   end
                 end
               end
@@ -301,7 +335,7 @@ module Treetop
         end
         if s0.last
           r0 = (Grammar).new(input, i0...index, s0)
-          r0.extend(Grammar0)
+          r0.extend(Grammar1)
         else
           self.index = i0
           r0 = nil
@@ -581,6 +615,12 @@ module Treetop
         def space
           elements[1]
         end
+      end
+
+      module ParsingRule1
+        def space
+          elements[1]
+        end
 
         def nonterminal
           elements[2]
@@ -591,11 +631,11 @@ module Treetop
         end
 
         def parsing_expression
-          elements[4]
+          elements[5]
         end
 
         def space
-          elements[5]
+          elements[6]
         end
 
       end
@@ -627,20 +667,48 @@ module Treetop
               r4 = _nt_space
               s0 &lt;&lt; r4
               if r4
-                r5 = _nt_parsing_expression
+                i6, s6 = index, []
+                if input.index('do', index) == index
+                  r7 = (SyntaxNode).new(input, index...(index + 2))
+                  @index += 2
+                else
+                  terminal_parse_failure('do')
+                  r7 = nil
+                end
+                s6 &lt;&lt; r7
+                if r7
+                  r8 = _nt_space
+                  s6 &lt;&lt; r8
+                end
+                if s6.last
+                  r6 = (SyntaxNode).new(input, i6...index, s6)
+                  r6.extend(ParsingRule0)
+                else
+                  self.index = i6
+                  r6 = nil
+                end
+                if r6
+                  r5 = r6
+                else
+                  r5 = SyntaxNode.new(input, index...index)
+                end
                 s0 &lt;&lt; r5
                 if r5
-                  r6 = _nt_space
-                  s0 &lt;&lt; r6
-                  if r6
-                    if input.index('end', index) == index
-                      r7 = (SyntaxNode).new(input, index...(index + 3))
-                      @index += 3
-                    else
-                      terminal_parse_failure('end')
-                      r7 = nil
+                  r9 = _nt_parsing_expression
+                  s0 &lt;&lt; r9
+                  if r9
+                    r10 = _nt_space
+                    s0 &lt;&lt; r10
+                    if r10
+                      if input.index('end', index) == index
+                        r11 = (SyntaxNode).new(input, index...(index + 3))
+                        @index += 3
+                      else
+                        terminal_parse_failure('end')
+                        r11 = nil
+                      end
+                      s0 &lt;&lt; r11
                     end
-                    s0 &lt;&lt; r7
                   end
                 end
               end
@@ -649,7 +717,7 @@ module Treetop
         end
         if s0.last
           r0 = (ParsingRule).new(input, i0...index, s0)
-          r0.extend(ParsingRule0)
+          r0.extend(ParsingRule1)
         else
           self.index = i0
           r0 = nil</diff>
      <filename>lib/treetop/compiler/metagrammar.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,7 @@ module Treetop
       end
 
       rule grammar
-        'grammar' space grammar_name space declaration_sequence space? 'end' &lt;Grammar&gt;
+        'grammar' space grammar_name space ('do' space)? declaration_sequence space? 'end' &lt;Grammar&gt;
       end
 
       rule grammar_name
@@ -55,7 +55,7 @@ module Treetop
       end
 
       rule parsing_rule
-        'rule' space nonterminal space parsing_expression space 'end' &lt;ParsingRule&gt;
+        'rule' space nonterminal space ('do' space)? parsing_expression space 'end' &lt;ParsingRule&gt;
       end
 
       rule parsing_expression</diff>
      <filename>lib/treetop/compiler/metagrammar.treetop</filename>
    </modified>
    <modified>
      <diff>@@ -7,8 +7,10 @@ describe Compiler::GrammarCompiler do
 
     dir = File.dirname(__FILE__)
     @source_path_with_treetop_extension = &quot;#{dir}/test_grammar.treetop&quot;
+    @source_path_with_do = &quot;#{dir}/test_grammar_do.treetop&quot;
     @source_path_with_tt_extension = &quot;#{dir}/test_grammar.tt&quot;
     @target_path = &quot;#{dir}/test_grammar.rb&quot;
+    @target_path_with_do = &quot;#{dir}/test_grammar_do.rb&quot;
     @alternate_target_path = &quot;#{dir}/test_grammar_alt.rb&quot;
     delete_target_files
   end
@@ -67,9 +69,15 @@ describe Compiler::GrammarCompiler do
     Test::GrammarParser.new.parse('foo').should_not be_nil
   end
 
+  specify &quot;grammars with 'do' compile&quot; do
+    compiler.compile(source_path_with_do)
+    require target_path_with_do
+    Test::GrammarParser.new.parse('foo').should_not be_nil
+  end
 
   def delete_target_files
     File.delete(target_path) if File.exists?(target_path)
+    File.delete(target_path_with_do) if File.exists?(target_path_with_do)
     File.delete(alternate_target_path) if File.exists?(alternate_target_path)
   end
 end</diff>
      <filename>spec/compiler/grammar_compiler_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>91692d4b3bcf7f6d96471f11965aaf4395e48ea0</id>
    </parent>
  </parents>
  <author>
    <name>Clifford Heath</name>
    <email>clifford.heath@gmail.com</email>
  </author>
  <url>http://github.com/nathansobo/treetop/commit/96ca108fd3eaf3995a971b972b787d321f0e7c43</url>
  <id>96ca108fd3eaf3995a971b972b787d321f0e7c43</id>
  <committed-date>2008-11-18T01:51:25-08:00</committed-date>
  <authored-date>2008-11-18T01:51:25-08:00</authored-date>
  <message>Added patch from Bryan Larsen to allow the &quot;do&quot; keyword after
&quot;grammar&quot; and &quot;rule&quot;, to make ruby-based syntax-aware editors
work better.</message>
  <tree>9c7e0a86eb89be1fda873c76a9e3119fa17381be</tree>
  <committer>
    <name>Clifford Heath</name>
    <email>clifford.heath@gmail.com</email>
  </committer>
</commit>
