<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,7 +3,6 @@ grammar UriTemplate
   rule uri_template
     uri_element more_elements:(uri_element)* {
       def value(env={})
-		#raise more_elements.elements.inspect
         uri_element.value(env) &lt;&lt; more_elements.elements.map{|el| el.value(env)}.join
       end
     }
@@ -14,32 +13,28 @@ grammar UriTemplate
   end
 
   rule expansion
-    '{' 
-	c:(
-		var
-		/
-		operator
-	) 
-	'}'
-	 {
-        def value(env = {})
-	  if c.respond_to? :value
-	    c.value(env)
-	  else
-	    c.interval.to_s + &quot;&lt;&gt;&quot;
-	  end
-        end
+    '{'
+   c:(
+      var
+      /
+      operator
+   ) 
+   '}'
+    {
+      def value(env = {})
+        c.value(env)
+      end
       } 
   end
 
   rule uri_part
     (unreserved / reserved / pct_encoded) {
-          def value(env = {})
-            text_value
-          end
-        }
+      def value(env = {})
+        text_value
+      end
+    }
   end
- 
+
   rule arg
     (reserved / unreserved / pct_encoded)*
   end
@@ -47,25 +42,25 @@ grammar UriTemplate
   rule op
     (
     'opt' {
-	      # If one or more of the variables are defined and non-empty then
-	   	  # substitute the value of 'arg', otherwise substitute the empty string.
-	      def exec
-	        lambda do |env, arg, vars|
-                  ret = ''
-                  vars.split(',').each do |var| 
-	            if !env[var].to_s.blank?
-	              ret = &quot;#{arg}&quot;
-                      break
-	            end
-		  end
-                  ret
-                end
-	      end
-	    }
+         # If one or more of the variables are defined and non-empty then
+           # substitute the value of 'arg', otherwise substitute the empty string.
+         def exec
+           lambda do |env, arg, vars|
+             ret = ''
+             vars.split(',').each do |var| 
+               if !env[var].to_s.blank?
+                 ret = &quot;#{arg}&quot;
+                 break
+               end
+             end
+             ret
+           end
+         end
+       }
     / 
     'neg' {
-	  # If all of the variables are un-defined or empty then substitute the
-	  # value of arg, otherwise substitute the empty string.
+     # If all of the variables are un-defined or empty then substitute the
+     # value of arg, otherwise substitute the empty string.
       def exec
         lambda do |env, arg, vars| 
           ret = &quot;#{arg}&quot;
@@ -81,85 +76,84 @@ grammar UriTemplate
     }
     / 
     'prefix' {
-	  # The prefix operator MUST only have one variable in its expansion.  If
-	  # the variable is defined and non-empty then substitute the value of
-	  # arg followed by the value of the variable, otherwise substitute the
-	  # empty string.
+     # The prefix operator MUST only have one variable in its expansion.  If
+     # the variable is defined and non-empty then substitute the value of
+     # arg followed by the value of the variable, otherwise substitute the
+     # empty string.
       def exec
         lambda do |env, prefix, vars| 
-                  v = env[vars]
-                  if vars =~ /([^=]+)=([^=]+)/
-                    var, default = $1.dup, $2.dup
-                    v = env[var]
-                    v = default if v.to_s.blank?
-                  end
-
-		  !v.blank? ? &quot;#{prefix}#{UriTemplate::Encoder.encode(v)}&quot; : &quot;&quot;
-		end
+          v = env[vars]
+          if vars =~ /([^=]+)=([^=]+)/
+            var, default = $1.dup, $2.dup
+            v = env[var]
+            v = default if v.to_s.blank?
+          end
+          !v.blank? ? &quot;#{prefix}#{UriTemplate::Encoder.encode(v)}&quot; : &quot;&quot;
+        end
       end
     } 
     / 
     'append' {
-	  # The append operator MUST only have one variable in its expansion.  If
-	  # the variable is defined and non-empty then substitute the value of
-	  # the variable followed by the value of arg, otherwise substitute the
-	  # empty string.
+     # The append operator MUST only have one variable in its expansion.  If
+     # the variable is defined and non-empty then substitute the value of
+     # the variable followed by the value of arg, otherwise substitute the
+     # empty string.
       def exec
         lambda do |env, append, vars|
-                  v = env[vars]
-                  if vars =~ /([^=]+)=([^=]+)/
-                    var, default = $1.dup, $2.dup
-                    v = env[var]
-                    v = default if v.to_s.blank?
-                  end  
-		  if v
-			val = UriTemplate::Encoder.encode(v)
-			!val.blank? ? &quot;#{val}#{append}&quot; : &quot;&quot;
-		  else
-		    ''
-		  end
-		end
+          v = env[vars]
+          if vars =~ /([^=]+)=([^=]+)/
+            var, default = $1.dup, $2.dup
+            v = env[var]
+            v = default if v.to_s.blank?
+          end  
+          if v
+            val = UriTemplate::Encoder.encode(v)
+            !val.blank? ? &quot;#{val}#{append}&quot; : &quot;&quot;
+          else
+            ''
+          end
+        end
       end
     } 
     / 
     'join' {
-	  # For each variable that is defined and non-empty create a keyvalue
-	  # string that is the concatenation of the variable name, &quot;=&quot;, and the
-	  # variable value.  Concatenate more than one keyvalue string with
-	  # intervening values of arg to create the substitution value.
-	  def exec
+     # For each variable that is defined and non-empty create a keyvalue
+     # string that is the concatenation of the variable name, &quot;=&quot;, and the
+     # variable value.  Concatenate more than one keyvalue string with
+     # intervening values of arg to create the substitution value.
+     def exec
         lambda do |env, joinop, vars| 
-		  vars.split(',').map do |var|
-                    v = env[var]
-                    if var =~ /([^=]+)=([^=]+)/
-                      var, default = $1.dup, $2.dup
-                      v = env[var]
-                      v = default if v.to_s.blank?
-                    end
-		    &quot;#{var}=#{UriTemplate::Encoder.encode(v)}&quot; if v
-		  end.compact.join(joinop)
-		end
-	  end
-	}
+          vars.split(',').map do |var|
+          v = env[var]
+          if var =~ /([^=]+)=([^=]+)/
+            var, default = $1.dup, $2.dup
+            v = env[var]
+            v = default if v.to_s.blank?
+          end
+          &quot;#{var}=#{UriTemplate::Encoder.encode(v)}&quot; if v
+        end.compact.join(joinop)
+      end
+     end
+   }
     / 
     'listjoin' {
-	  # The listjoin operator MUST have only one variable in its expansion
-	  # and that variable must be a list.  If the list is non-empty then
-	  # substitute the concatenation of all the list members with intevening
-	  # values of arg.
+     # The listjoin operator MUST have only one variable in its expansion
+     # and that variable must be a list.  If the list is non-empty then
+     # substitute the concatenation of all the list members with intevening
+     # values of arg.
       #
-	  # The result of substitution MUST match the URI-reference rule and
-	  # SHOULD also match any known rules for the scheme of the resulting
-	  # URI.
-	  def exec
-            lambda do |env, joinop, vars|
-              return &quot;&quot; unless env[vars].respond_to? :each
-	      env[vars].map do |v|
-                &quot;#{UriTemplate::Encoder.encode(v)}&quot; if v
-              end.compact.join(joinop)
-	    end
-	  end
-	}
+     # The result of substitution MUST match the URI-reference rule and
+     # SHOULD also match any known rules for the scheme of the resulting
+     # URI.
+     def exec
+       lambda do |env, joinop, vars|
+         return &quot;&quot; unless env[vars].respond_to? :each
+         env[vars].map do |v|
+           &quot;#{UriTemplate::Encoder.encode(v)}&quot; if v
+         end.compact.join(joinop)
+       end
+     end
+   }
     )
   end
 
@@ -167,48 +161,20 @@ grammar UriTemplate
     var (&quot;,&quot; var)*
   end
   
-  # see http://www.ietf.org/rfc/rfc3986.txt
-  rule unreserved
-    alphanumeric / &quot;-&quot; / &quot;.&quot; / &quot;_&quot; / &quot;~&quot;
-  end
-
-  # see http://www.ietf.org/rfc/rfc3986.txt
-  rule pct_encoded
-    '%' hexdig hexdig
-  end
-
-  rule hexdig
-    [a-fA-F0-9]
-  end
-  
-  # see http://www.ietf.org/rfc/rfc3986.txt
-  rule reserved
-    gen_delims / sub_delims
-  end
-
-  rule gen_delims
-    &quot;:&quot; / &quot;/&quot; / &quot;?&quot; / &quot;#&quot; / &quot;[&quot; / &quot;]&quot; / &quot;@&quot;
-  end
-
-  rule sub_delims
-    &quot;!&quot; / &quot;$&quot; / &quot;&amp;&quot; / &quot;'&quot; / &quot;(&quot; / &quot;)&quot; / &quot;*&quot; / &quot;+&quot; / &quot;,&quot; / &quot;;&quot; / &quot;=&quot;
-  end
-
-
   rule vardefault
     (unreserved / pct_encoded)*  
   end
 
   rule var
     varname defaults:('=' vardefault)* {
-        def value(env={} )
-		  return UriTemplate::Encoder.encode(env[name]) if env[name] # UriTemplate::Encoder.encode(env[name])
-		  #defaults.elements[0].text_value if defaults.elements.size &gt; 0
-		  defaults.text_value.gsub(/=/, '')
-        end
-        def name
-		  varname.text_value
-        end
+      def value(env={} )
+        return UriTemplate::Encoder.encode(env[name]) if env[name]
+        defaults.text_value.gsub(/=/, '')
+      end
+        
+      def name
+        varname.text_value
+      end
     }
   end
 
@@ -232,4 +198,31 @@ grammar UriTemplate
     alpha / [0-9]
   end
 
+  # see http://www.ietf.org/rfc/rfc3986.txt
+  rule unreserved
+    alphanumeric / &quot;-&quot; / &quot;.&quot; / &quot;_&quot; / &quot;~&quot;
+  end
+
+  # see http://www.ietf.org/rfc/rfc3986.txt
+  rule pct_encoded
+    '%' hexdig hexdig
+  end
+
+  rule hexdig
+    [a-fA-F0-9]
+  end
+  
+  # see http://www.ietf.org/rfc/rfc3986.txt
+  rule reserved
+    gen_delims / sub_delims
+  end
+
+  rule gen_delims
+    &quot;:&quot; / &quot;/&quot; / &quot;?&quot; / &quot;#&quot; / &quot;[&quot; / &quot;]&quot; / &quot;@&quot;
+  end
+
+  rule sub_delims
+    &quot;!&quot; / &quot;$&quot; / &quot;&amp;&quot; / &quot;'&quot; / &quot;(&quot; / &quot;)&quot; / &quot;*&quot; / &quot;+&quot; / &quot;,&quot; / &quot;;&quot; / &quot;=&quot;
+  end
+
 end</diff>
      <filename>grammar/uri_template.treetop</filename>
    </modified>
    <modified>
      <diff>@@ -47,5 +47,27 @@ module UriTemplate
       end
     end
   end
+  
+  class URI
+    
+    def initialize(tmpl)
+      @tmpl, @parser = tmpl, UriTemplateParser.new
+      yield self if block_given?
+    end
+    
+    def replace(vars = {})
+      puts @parser.parse(@tmpl).value(vars)
+    end
+    
+  end
+  
+end
+
+if __FILE__ == $0
+  UriTemplate::URI.new(DATA.read) do |u|
+    u.replace(:userID =&gt; &quot;stefan&quot;)
+  end
 end
 
+__END__
+http://www.google.com/notebook/feeds/{userID}{-prefix|/notebooks/|notebookID}{-opt|/-/|categories}{-listjoin|/|categories}?{-join|&amp;|updated-min,updated-max,alt,start-index,max-results,entryID,orderby}
\ No newline at end of file</diff>
      <filename>lib/uri_template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,3 @@
-#  Created by Stefan Saasen.
-#  Copyright (c) 2008. All rights reserved.
-#
-# ! This file is generated from 
 module UriTemplate
   include Treetop::Runtime
 
@@ -21,7 +17,6 @@ module UriTemplate
 
   module UriTemplate1
     def value(env={})
-		#raise more_elements.elements.inspect
       uri_element.value(env) &lt;&lt; more_elements.elements.map{|el| el.value(env)}.join
     end
   end
@@ -100,11 +95,11 @@ module UriTemplate
 
   module Expansion1
     def value(env = {})
-	  if c.respond_to? :value
-	    c.value(env)
-	  else
-	    c.interval.to_s + &quot;&lt;&gt;&quot;
-	  end
+ if c.respond_to? :value
+   c.value(env)
+ else
+   c.interval.to_s + &quot;&lt;&gt;&quot;
+ end
     end
   end
 
@@ -248,31 +243,14 @@ module UriTemplate
   end
 
   module Op0
-	      # If one or more of the variables are defined and non-empty then
-	   	  # substitute the value of 'arg', otherwise substitute the empty string.
-	      def exec
-	        lambda do |env, arg, vars|
-    ret = ''
-    vars.split(',').each do |var| 
-	            if !env[var].to_s.blank?
-	              ret = &quot;#{arg}&quot;
-        break
-	            end
-		  end
-    ret
-  end
-	      end
-  end
-
-  module Op1
-	  # If all of the variables are un-defined or empty then substitute the
-	  # value of arg, otherwise substitute the empty string.
+    # If one or more of the variables are defined and non-empty then
+      # substitute the value of 'arg', otherwise substitute the empty string.
     def exec
-      lambda do |env, arg, vars| 
-        ret = &quot;#{arg}&quot;
-        vars.split(',').each do |var|
-          if !env[var].to_s.blank?
-            ret = &quot;&quot;
+      lambda do |env, arg, vars|
+        ret = ''
+        vars.split(',').each do |var| 
+          if !env[var.to_s].to_s.blank?
+            ret = &quot;#{arg}&quot;
             break
           end
         end
@@ -281,85 +259,101 @@ module UriTemplate
     end
   end
 
-  module Op2
-	  # The prefix operator MUST only have one variable in its expansion.  If
-	  # the variable is defined and non-empty then substitute the value of
-	  # arg followed by the value of the variable, otherwise substitute the
-	  # empty string.
-    def exec
-      lambda do |env, prefix, vars| 
-                v = env[vars]
-                if vars =~ /([^=]+)=([^=]+)/
-                  var, default = $1.dup, $2.dup
-                  v = env[var]
-                  v = default if v.to_s.blank?
-                end
+  module Op1
+    # If all of the variables are un-defined or empty then substitute the
+    # value of arg, otherwise substitute the empty string.
+     def exec
+       lambda do |env, arg, vars| 
+         ret = &quot;#{arg}&quot;
+         vars.split(',').each do |var|
+           if !env[var.to_s].to_s.blank?
+             ret = &quot;&quot;
+             break
+           end
+         end
+         ret
+       end
+     end
+  end
 
-		  !v.blank? ? &quot;#{prefix}#{UriTemplate::Encoder.encode(v)}&quot; : &quot;&quot;
-		end
-    end
+  module Op2
+    # The prefix operator MUST only have one variable in its expansion.  If
+    # the variable is defined and non-empty then substitute the value of
+    # arg followed by the value of the variable, otherwise substitute the
+    # empty string.
+     def exec
+       lambda do |env, prefix, vars| 
+         v = env[vars]
+         if vars =~ /([^=]+)=([^=]+)/
+           var, default = $1.dup, $2.dup
+           v = env[var.to_s]
+           v = default if v.to_s.blank?
+         end
+         !v.blank? ? &quot;#{prefix}#{UriTemplate::Encoder.encode(v)}&quot; : &quot;&quot;
+       end
+     end
   end
 
   module Op3
-	  # The append operator MUST only have one variable in its expansion.  If
-	  # the variable is defined and non-empty then substitute the value of
-	  # the variable followed by the value of arg, otherwise substitute the
-	  # empty string.
-    def exec
-      lambda do |env, append, vars|
-                v = env[vars]
-                if vars =~ /([^=]+)=([^=]+)/
-                  var, default = $1.dup, $2.dup
-                  v = env[var]
-                  v = default if v.to_s.blank?
-                end  
-		  if v
-			val = UriTemplate::Encoder.encode(v)
-			!val.blank? ? &quot;#{val}#{append}&quot; : &quot;&quot;
-		  else
-		    ''
-		  end
-		end
-    end
+    # The append operator MUST only have one variable in its expansion.  If
+    # the variable is defined and non-empty then substitute the value of
+    # the variable followed by the value of arg, otherwise substitute the
+    # empty string.
+     def exec
+       lambda do |env, append, vars|
+         v = env[vars]
+         if vars =~ /([^=]+)=([^=]+)/
+           var, default = $1.dup, $2.dup
+           v = env[var.to_s]
+           v = default if v.to_s.blank?
+         end  
+         if v
+           val = UriTemplate::Encoder.encode(v)
+           !val.blank? ? &quot;#{val}#{append}&quot; : &quot;&quot;
+         else
+           ''
+         end
+       end
+     end
   end
 
   module Op4
-	  # For each variable that is defined and non-empty create a keyvalue
-	  # string that is the concatenation of the variable name, &quot;=&quot;, and the
-	  # variable value.  Concatenate more than one keyvalue string with
-	  # intervening values of arg to create the substitution value.
-	  def exec
-    lambda do |env, joinop, vars| 
-		  vars.split(',').map do |var|
-                v = env[var]
-                if var =~ /([^=]+)=([^=]+)/
-                  var, default = $1.dup, $2.dup
-                  v = env[var]
-                  v = default if v.to_s.blank?
-                end
-		    &quot;#{var}=#{UriTemplate::Encoder.encode(v)}&quot; if v
-		  end.compact.join(joinop)
-		end
-	  end
+    # For each variable that is defined and non-empty create a keyvalue
+    # string that is the concatenation of the variable name, &quot;=&quot;, and the
+    # variable value.  Concatenate more than one keyvalue string with
+    # intervening values of arg to create the substitution value.
+    def exec
+       lambda do |env, joinop, vars| 
+         vars.split(',').map do |var|
+         v = env[var.to_s]
+         if var =~ /([^=]+)=([^=]+)/
+           var, default = $1.dup, $2.dup
+           v = env[var.to_s]
+           v = default if v.to_s.blank?
+         end
+         &quot;#{var}=#{UriTemplate::Encoder.encode(v)}&quot; if v
+       end.compact.join(joinop)
+     end
+    end
   end
 
   module Op5
-	  # The listjoin operator MUST have only one variable in its expansion
-	  # and that variable must be a list.  If the list is non-empty then
-	  # substitute the concatenation of all the list members with intevening
-	  # values of arg.
-    #
-	  # The result of substitution MUST match the URI-reference rule and
-	  # SHOULD also match any known rules for the scheme of the resulting
-	  # URI.
-	  def exec
-          lambda do |env, joinop, vars|
-            return &quot;&quot; unless env[vars].respond_to? :each
-	      env[vars].map do |v|
-              &quot;#{UriTemplate::Encoder.encode(v)}&quot; if v
-            end.compact.join(joinop)
-	    end
-	  end
+    # The listjoin operator MUST have only one variable in its expansion
+    # and that variable must be a list.  If the list is non-empty then
+    # substitute the concatenation of all the list members with intevening
+    # values of arg.
+     #
+    # The result of substitution MUST match the URI-reference rule and
+    # SHOULD also match any known rules for the scheme of the resulting
+    # URI.
+    def exec
+      lambda do |env, joinop, vars|
+        return &quot;&quot; unless env[vars.to_s].respond_to? :each
+        env[vars.to_s].map do |v|
+          &quot;#{UriTemplate::Encoder.encode(v)}&quot; if v
+        end.compact.join(joinop)
+      end
+    end
   end
 
   def _nt_op
@@ -520,6 +514,312 @@ module UriTemplate
     return r0
   end
 
+  def _nt_vardefault
+    start_index = index
+    if node_cache[:vardefault].has_key?(index)
+      cached = node_cache[:vardefault][index]
+      @index = cached.interval.end if cached
+      return cached
+    end
+
+    s0, i0 = [], index
+    loop do
+      i1 = index
+      r2 = _nt_unreserved
+      if r2
+        r1 = r2
+      else
+        r3 = _nt_pct_encoded
+        if r3
+          r1 = r3
+        else
+          self.index = i1
+          r1 = nil
+        end
+      end
+      if r1
+        s0 &lt;&lt; r1
+      else
+        break
+      end
+    end
+    r0 = SyntaxNode.new(input, i0...index, s0)
+
+    node_cache[:vardefault][start_index] = r0
+
+    return r0
+  end
+
+  module Var0
+    def vardefault
+      elements[1]
+    end
+  end
+
+  module Var1
+    def varname
+      elements[0]
+    end
+
+    def defaults
+      elements[1]
+    end
+  end
+
+  module Var2
+    def value(env={} )
+      return UriTemplate::Encoder.encode(env[name.to_s]) if env[name.to_s]
+      defaults.text_value.gsub(/=/, '')
+    end
+      
+    def name
+      varname.text_value
+    end
+  end
+
+  def _nt_var
+    start_index = index
+    if node_cache[:var].has_key?(index)
+      cached = node_cache[:var][index]
+      @index = cached.interval.end if cached
+      return cached
+    end
+
+    i0, s0 = index, []
+    r1 = _nt_varname
+    s0 &lt;&lt; r1
+    if r1
+      s2, i2 = [], index
+      loop do
+        i3, s3 = index, []
+        if input.index('=', index) == index
+          r4 = (SyntaxNode).new(input, index...(index + 1))
+          @index += 1
+        else
+          terminal_parse_failure('=')
+          r4 = nil
+        end
+        s3 &lt;&lt; r4
+        if r4
+          r5 = _nt_vardefault
+          s3 &lt;&lt; r5
+        end
+        if s3.last
+          r3 = (SyntaxNode).new(input, i3...index, s3)
+          r3.extend(Var0)
+        else
+          self.index = i3
+          r3 = nil
+        end
+        if r3
+          s2 &lt;&lt; r3
+        else
+          break
+        end
+      end
+      r2 = SyntaxNode.new(input, i2...index, s2)
+      s0 &lt;&lt; r2
+    end
+    if s0.last
+      r0 = (SyntaxNode).new(input, i0...index, s0)
+      r0.extend(Var1)
+      r0.extend(Var2)
+    else
+      self.index = i0
+      r0 = nil
+    end
+
+    node_cache[:var][start_index] = r0
+
+    return r0
+  end
+
+  module Operator0
+    def op
+      elements[1]
+    end
+
+    def arg
+      elements[3]
+    end
+
+    def vars
+      elements[5]
+    end
+  end
+
+  module Operator1
+
+    def value(env={})
+      op.exec.call(env, arg.text_value, vars.text_value) # if op.respond_to?(:exec)
+    end
+  end
+
+  def _nt_operator
+    start_index = index
+    if node_cache[:operator].has_key?(index)
+      cached = node_cache[:operator][index]
+      @index = cached.interval.end if cached
+      return cached
+    end
+
+    i0, s0 = index, []
+    if input.index(&quot;-&quot;, index) == index
+      r1 = (SyntaxNode).new(input, index...(index + 1))
+      @index += 1
+    else
+      terminal_parse_failure(&quot;-&quot;)
+      r1 = nil
+    end
+    s0 &lt;&lt; r1
+    if r1
+      r2 = _nt_op
+      s0 &lt;&lt; r2
+      if r2
+        if input.index(&quot;|&quot;, index) == index
+          r3 = (SyntaxNode).new(input, index...(index + 1))
+          @index += 1
+        else
+          terminal_parse_failure(&quot;|&quot;)
+          r3 = nil
+        end
+        s0 &lt;&lt; r3
+        if r3
+          r4 = _nt_arg
+          s0 &lt;&lt; r4
+          if r4
+            if input.index(&quot;|&quot;, index) == index
+              r5 = (SyntaxNode).new(input, index...(index + 1))
+              @index += 1
+            else
+              terminal_parse_failure(&quot;|&quot;)
+              r5 = nil
+            end
+            s0 &lt;&lt; r5
+            if r5
+              r6 = _nt_vars
+              s0 &lt;&lt; r6
+            end
+          end
+        end
+      end
+    end
+    if s0.last
+      r0 = (SyntaxNode).new(input, i0...index, s0)
+      r0.extend(Operator0)
+      r0.extend(Operator1)
+    else
+      self.index = i0
+      r0 = nil
+    end
+
+    node_cache[:operator][start_index] = r0
+
+    return r0
+  end
+
+  module Varname0
+  end
+
+  def _nt_varname
+    start_index = index
+    if node_cache[:varname].has_key?(index)
+      cached = node_cache[:varname][index]
+      @index = cached.interval.end if cached
+      return cached
+    end
+
+    i0, s0 = index, []
+    if input.index(Regexp.new('[a-zA-Z0-9]'), index) == index
+      r1 = (SyntaxNode).new(input, index...(index + 1))
+      @index += 1
+    else
+      r1 = nil
+    end
+    s0 &lt;&lt; r1
+    if r1
+      s2, i2 = [], index
+      loop do
+        if input.index(Regexp.new('[a-zA-Z0-9_.-]'), index) == index
+          r3 = (SyntaxNode).new(input, index...(index + 1))
+          @index += 1
+        else
+          r3 = nil
+        end
+        if r3
+          s2 &lt;&lt; r3
+        else
+          break
+        end
+      end
+      r2 = SyntaxNode.new(input, i2...index, s2)
+      s0 &lt;&lt; r2
+    end
+    if s0.last
+      r0 = (SyntaxNode).new(input, i0...index, s0)
+      r0.extend(Varname0)
+    else
+      self.index = i0
+      r0 = nil
+    end
+
+    node_cache[:varname][start_index] = r0
+
+    return r0
+  end
+
+  def _nt_alpha
+    start_index = index
+    if node_cache[:alpha].has_key?(index)
+      cached = node_cache[:alpha][index]
+      @index = cached.interval.end if cached
+      return cached
+    end
+
+    if input.index(Regexp.new('[A-Za-z_]'), index) == index
+      r0 = (SyntaxNode).new(input, index...(index + 1))
+      @index += 1
+    else
+      r0 = nil
+    end
+
+    node_cache[:alpha][start_index] = r0
+
+    return r0
+  end
+
+  def _nt_alphanumeric
+    start_index = index
+    if node_cache[:alphanumeric].has_key?(index)
+      cached = node_cache[:alphanumeric][index]
+      @index = cached.interval.end if cached
+      return cached
+    end
+
+    i0 = index
+    r1 = _nt_alpha
+    if r1
+      r0 = r1
+    else
+      if input.index(Regexp.new('[0-9]'), index) == index
+        r2 = (SyntaxNode).new(input, index...(index + 1))
+        @index += 1
+      else
+        r2 = nil
+      end
+      if r2
+        r0 = r2
+      else
+        self.index = i0
+        r0 = nil
+      end
+    end
+
+    node_cache[:alphanumeric][start_index] = r0
+
+    return r0
+  end
+
   def _nt_unreserved
     start_index = index
     if node_cache[:unreserved].has_key?(index)
@@ -913,312 +1213,6 @@ module UriTemplate
     return r0
   end
 
-  def _nt_vardefault
-    start_index = index
-    if node_cache[:vardefault].has_key?(index)
-      cached = node_cache[:vardefault][index]
-      @index = cached.interval.end if cached
-      return cached
-    end
-
-    s0, i0 = [], index
-    loop do
-      i1 = index
-      r2 = _nt_unreserved
-      if r2
-        r1 = r2
-      else
-        r3 = _nt_pct_encoded
-        if r3
-          r1 = r3
-        else
-          self.index = i1
-          r1 = nil
-        end
-      end
-      if r1
-        s0 &lt;&lt; r1
-      else
-        break
-      end
-    end
-    r0 = SyntaxNode.new(input, i0...index, s0)
-
-    node_cache[:vardefault][start_index] = r0
-
-    return r0
-  end
-
-  module Var0
-    def vardefault
-      elements[1]
-    end
-  end
-
-  module Var1
-    def varname
-      elements[0]
-    end
-
-    def defaults
-      elements[1]
-    end
-  end
-
-  module Var2
-    def value(env={} )
-		  return UriTemplate::Encoder.encode(env[name]) if env[name] # UriTemplate::Encoder.encode(env[name])
-		  #defaults.elements[0].text_value if defaults.elements.size &gt; 0
-		  defaults.text_value.gsub(/=/, '')
-    end
-    def name
-		  varname.text_value
-    end
-  end
-
-  def _nt_var
-    start_index = index
-    if node_cache[:var].has_key?(index)
-      cached = node_cache[:var][index]
-      @index = cached.interval.end if cached
-      return cached
-    end
-
-    i0, s0 = index, []
-    r1 = _nt_varname
-    s0 &lt;&lt; r1
-    if r1
-      s2, i2 = [], index
-      loop do
-        i3, s3 = index, []
-        if input.index('=', index) == index
-          r4 = (SyntaxNode).new(input, index...(index + 1))
-          @index += 1
-        else
-          terminal_parse_failure('=')
-          r4 = nil
-        end
-        s3 &lt;&lt; r4
-        if r4
-          r5 = _nt_vardefault
-          s3 &lt;&lt; r5
-        end
-        if s3.last
-          r3 = (SyntaxNode).new(input, i3...index, s3)
-          r3.extend(Var0)
-        else
-          self.index = i3
-          r3 = nil
-        end
-        if r3
-          s2 &lt;&lt; r3
-        else
-          break
-        end
-      end
-      r2 = SyntaxNode.new(input, i2...index, s2)
-      s0 &lt;&lt; r2
-    end
-    if s0.last
-      r0 = (SyntaxNode).new(input, i0...index, s0)
-      r0.extend(Var1)
-      r0.extend(Var2)
-    else
-      self.index = i0
-      r0 = nil
-    end
-
-    node_cache[:var][start_index] = r0
-
-    return r0
-  end
-
-  module Operator0
-    def op
-      elements[1]
-    end
-
-    def arg
-      elements[3]
-    end
-
-    def vars
-      elements[5]
-    end
-  end
-
-  module Operator1
-
-    def value(env={})
-      op.exec.call(env, arg.text_value, vars.text_value) # if op.respond_to?(:exec)
-    end
-  end
-
-  def _nt_operator
-    start_index = index
-    if node_cache[:operator].has_key?(index)
-      cached = node_cache[:operator][index]
-      @index = cached.interval.end if cached
-      return cached
-    end
-
-    i0, s0 = index, []
-    if input.index(&quot;-&quot;, index) == index
-      r1 = (SyntaxNode).new(input, index...(index + 1))
-      @index += 1
-    else
-      terminal_parse_failure(&quot;-&quot;)
-      r1 = nil
-    end
-    s0 &lt;&lt; r1
-    if r1
-      r2 = _nt_op
-      s0 &lt;&lt; r2
-      if r2
-        if input.index(&quot;|&quot;, index) == index
-          r3 = (SyntaxNode).new(input, index...(index + 1))
-          @index += 1
-        else
-          terminal_parse_failure(&quot;|&quot;)
-          r3 = nil
-        end
-        s0 &lt;&lt; r3
-        if r3
-          r4 = _nt_arg
-          s0 &lt;&lt; r4
-          if r4
-            if input.index(&quot;|&quot;, index) == index
-              r5 = (SyntaxNode).new(input, index...(index + 1))
-              @index += 1
-            else
-              terminal_parse_failure(&quot;|&quot;)
-              r5 = nil
-            end
-            s0 &lt;&lt; r5
-            if r5
-              r6 = _nt_vars
-              s0 &lt;&lt; r6
-            end
-          end
-        end
-      end
-    end
-    if s0.last
-      r0 = (SyntaxNode).new(input, i0...index, s0)
-      r0.extend(Operator0)
-      r0.extend(Operator1)
-    else
-      self.index = i0
-      r0 = nil
-    end
-
-    node_cache[:operator][start_index] = r0
-
-    return r0
-  end
-
-  module Varname0
-  end
-
-  def _nt_varname
-    start_index = index
-    if node_cache[:varname].has_key?(index)
-      cached = node_cache[:varname][index]
-      @index = cached.interval.end if cached
-      return cached
-    end
-
-    i0, s0 = index, []
-    if input.index(Regexp.new('[a-zA-Z0-9]'), index) == index
-      r1 = (SyntaxNode).new(input, index...(index + 1))
-      @index += 1
-    else
-      r1 = nil
-    end
-    s0 &lt;&lt; r1
-    if r1
-      s2, i2 = [], index
-      loop do
-        if input.index(Regexp.new('[a-zA-Z0-9_.-]'), index) == index
-          r3 = (SyntaxNode).new(input, index...(index + 1))
-          @index += 1
-        else
-          r3 = nil
-        end
-        if r3
-          s2 &lt;&lt; r3
-        else
-          break
-        end
-      end
-      r2 = SyntaxNode.new(input, i2...index, s2)
-      s0 &lt;&lt; r2
-    end
-    if s0.last
-      r0 = (SyntaxNode).new(input, i0...index, s0)
-      r0.extend(Varname0)
-    else
-      self.index = i0
-      r0 = nil
-    end
-
-    node_cache[:varname][start_index] = r0
-
-    return r0
-  end
-
-  def _nt_alpha
-    start_index = index
-    if node_cache[:alpha].has_key?(index)
-      cached = node_cache[:alpha][index]
-      @index = cached.interval.end if cached
-      return cached
-    end
-
-    if input.index(Regexp.new('[A-Za-z_]'), index) == index
-      r0 = (SyntaxNode).new(input, index...(index + 1))
-      @index += 1
-    else
-      r0 = nil
-    end
-
-    node_cache[:alpha][start_index] = r0
-
-    return r0
-  end
-
-  def _nt_alphanumeric
-    start_index = index
-    if node_cache[:alphanumeric].has_key?(index)
-      cached = node_cache[:alphanumeric][index]
-      @index = cached.interval.end if cached
-      return cached
-    end
-
-    i0 = index
-    r1 = _nt_alpha
-    if r1
-      r0 = r1
-    else
-      if input.index(Regexp.new('[0-9]'), index) == index
-        r2 = (SyntaxNode).new(input, index...(index + 1))
-        @index += 1
-      else
-        r2 = nil
-      end
-      if r2
-        r0 = r2
-      else
-        self.index = i0
-        r0 = nil
-      end
-    end
-
-    node_cache[:alphanumeric][start_index] = r0
-
-    return r0
-  end
-
 end
 
 class UriTemplateParser &lt; Treetop::Runtime::CompiledParser</diff>
      <filename>lib/uri_template/grammar.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c6641686e4add86146eed869d04995f3cd06e799</id>
    </parent>
  </parents>
  <author>
    <name>Stefan Saasen</name>
    <email>stefan@coravy.com</email>
  </author>
  <url>http://github.com/juretta/uri-templates/commit/efb735d5c745bfccc1a58e56b0de6732f6e7329e</url>
  <id>efb735d5c745bfccc1a58e56b0de6732f6e7329e</id>
  <committed-date>2008-03-14T02:31:38-07:00</committed-date>
  <authored-date>2008-03-14T02:31:38-07:00</authored-date>
  <message>structuring the gem files</message>
  <tree>4af5db1ef274dbb9ad5b720883b9334d2a833def</tree>
  <committer>
    <name>Stefan Saasen</name>
    <email>stefan@coravy.com</email>
  </committer>
</commit>
