0
+ include Treetop::Runtime
0
+ @root ||= :uri_template
0
+ uri_element.value(env) << more_elements.elements.map{|el| el.value(env)}.join
0
+ if node_cache[:uri_template].has_key?(index)
0
+ cached = node_cache[:uri_template][index]
0
+ @index = cached.interval.end if cached
0
+ r2 = SyntaxNode.new(input, i2...index, s2)
0
+ r0 = (SyntaxNode).new(input, i0...index, s0)
0
+ r0.extend(UriTemplate0)
0
+ r0.extend(UriTemplate1)
0
+ node_cache[:uri_template][start_index] = r0
0
+ if node_cache[:uri_element].has_key?(index)
0
+ cached = node_cache[:uri_element][index]
0
+ @index = cached.interval.end if cached
0
+ node_cache[:uri_element][start_index] = r0
0
+ if c.respond_to? :value
0
+ c.interval.to_s + "<>"
0
+ if node_cache[:expansion].has_key?(index)
0
+ cached = node_cache[:expansion][index]
0
+ @index = cached.interval.end if cached
0
+ if input.index('{', index) == index
0
+ r1 = (SyntaxNode).new(input, index...(index + 1))
0
+ terminal_parse_failure('{')
0
+ if input.index('}', index) == index
0
+ r5 = (SyntaxNode).new(input, index...(index + 1))
0
+ terminal_parse_failure('}')
0
+ r0 = (SyntaxNode).new(input, i0...index, s0)
0
+ node_cache[:expansion][start_index] = r0
0
+ if node_cache[:uri_part].has_key?(index)
0
+ cached = node_cache[:uri_part][index]
0
+ @index = cached.interval.end if cached
0
+ node_cache[:uri_part][start_index] = r0
0
+ if node_cache[:arg].has_key?(index)
0
+ cached = node_cache[:arg][index]
0
+ @index = cached.interval.end if cached
0
+ r0 = SyntaxNode.new(input, i0...index, s0)
0
+ node_cache[:arg][start_index] = r0
0
+ # If one or more of the variables are defined and non-empty then
0
+ # substitute the value of 'arg', otherwise substitute the empty string.
0
+ lambda do |env, arg, vars|
0
+ vars.split(',').each do |var|
0
+ if !env[var.to_s].to_s.blank?
0
+ # If all of the variables are un-defined or empty then substitute the
0
+ # value of arg, otherwise substitute the empty string.
0
+ lambda do |env, arg, vars|
0
+ vars.split(',').each do |var|
0
+ if !env[var.to_s].to_s.blank?
0
+ # The prefix operator MUST only have one variable in its expansion. If
0
+ # the variable is defined and non-empty then substitute the value of
0
+ # arg followed by the value of the variable, otherwise substitute the
0
+ lambda do |env, prefix, vars|
0
+ if vars =~ /([^=]+)=([^=]+)/
0
+ var, default = $1.dup, $2.dup
0
+ v = default if v.to_s.blank?
0
+ !v.blank? ? "#{prefix}#{UriTemplate::Encoder.encode(v)}" : ""
0
+ # The append operator MUST only have one variable in its expansion. If
0
+ # the variable is defined and non-empty then substitute the value of
0
+ # the variable followed by the value of arg, otherwise substitute the
0
+ lambda do |env, append, vars|
0
+ if vars =~ /([^=]+)=([^=]+)/
0
+ var, default = $1.dup, $2.dup
0
+ v = default if v.to_s.blank?
0
+ val = UriTemplate::Encoder.encode(v)
0
+ !val.blank? ? "#{val}#{append}" : ""
0
+ # For each variable that is defined and non-empty create a keyvalue
0
+ # string that is the concatenation of the variable name, "=", and the
0
+ # variable value. Concatenate more than one keyvalue string with
0
+ # intervening values of arg to create the substitution value.
0
+ lambda do |env, joinop, vars|
0
+ vars.split(',').map do |var|
0
+ if var =~ /([^=]+)=([^=]+)/
0
+ var, default = $1.dup, $2.dup
0
+ v = default if v.to_s.blank?
0
+ "#{var}=#{UriTemplate::Encoder.encode(v)}" if v
0
+ end.compact.join(joinop)
0
+ # The listjoin operator MUST have only one variable in its expansion
0
+ # and that variable must be a list. If the list is non-empty then
0
+ # substitute the concatenation of all the list members with intevening
0
+ # The result of substitution MUST match the URI-reference rule and
0
+ # SHOULD also match any known rules for the scheme of the resulting
0
+ lambda do |env, joinop, vars|
0
+ return "" unless env[vars.to_s].respond_to? :each
0
+ env[vars.to_s].map do |v|
0
+ "#{UriTemplate::Encoder.encode(v)}" if v
0
+ end.compact.join(joinop)
0
+ if node_cache[:op].has_key?(index)
0
+ cached = node_cache[:op][index]
0
+ @index = cached.interval.end if cached
0
+ if input.index('opt', index) == index
0
+ r1 = (SyntaxNode).new(input, index...(index + 3))
0
+ terminal_parse_failure('opt')
0
+ if input.index('neg', index) == index
0
+ r2 = (SyntaxNode).new(input, index...(index + 3))
0
+ terminal_parse_failure('neg')
0
+ if input.index('prefix', index) == index
0
+ r3 = (SyntaxNode).new(input, index...(index + 6))
0
+ terminal_parse_failure('prefix')