# Autogenerated from a Treetop grammar. Edits may be lost.


module CBOR_DIAG
  include Treetop::Runtime

  def root
    @root ||= :text
  end

  module Text0
    def soc
      elements[0]
    end

    def value
      elements[1]
    end
  end

  module Text1
    def value
      elements[0]
    end

    def ows
      elements[1]
    end

    def an
      elements[2]
    end

    def soc
      elements[3]
    end
  end

  module Text2
    def ows
      elements[0]
    end

    def a1
      elements[1]
    end
  end

  module Text3
    def to_rb
      r = if e = a1.elements
        [e[0].to_rb] + e[2].elements.map {|x| x.value.to_rb }
      else
        []
      end
      if r.size == 1
        r.first
      else
        CBOR::Sequence.new(r)
      end
    end
  end

  def _nt_text
    start_index = index
    if node_cache[:text].has_key?(index)
      cached = node_cache[:text][index]
      if cached
        node_cache[:text][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    r1 = _nt_ows
    s0 << r1
    if r1
      i3, s3 = index, []
      r4 = _nt_value
      s3 << r4
      if r4
        r5 = _nt_ows
        s3 << r5
        if r5
          s6, i6 = [], index
          loop do
            i7, s7 = index, []
            r8 = _nt_soc
            s7 << r8
            if r8
              r9 = _nt_value
              s7 << r9
            end
            if s7.last
              r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
              r7.extend(Text0)
            else
              @index = i7
              r7 = nil
            end
            if r7
              s6 << r7
            else
              break
            end
          end
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          s3 << r6
          if r6
            r10 = _nt_soc
            s3 << r10
          end
        end
      end
      if s3.last
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        r3.extend(Text1)
      else
        @index = i3
        r3 = nil
      end
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r2
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Text2)
      r0.extend(Text3)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:text][start_index] = r0

    r0
  end

  def _nt_value
    start_index = index
    if node_cache[:value].has_key?(index)
      cached = node_cache[:value][index]
      if cached
        node_cache[:value][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0 = index
    r1 = _nt_string
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
    else
      r2 = _nt_map
      if r2
        r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
        r0 = r2
      else
        r3 = _nt_array
        if r3
          r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
          r0 = r3
        else
          r4 = _nt_tagged
          if r4
            r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
            r0 = r4
          else
            r5 = _nt_hnumber
            if r5
              r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
              r0 = r5
            else
              r6 = _nt_fnumber
              if r6
                r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
                r0 = r6
              else
                r7 = _nt_infin
                if r7
                  r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
                  r0 = r7
                else
                  r8 = _nt_simple
                  if r8
                    r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
                    r0 = r8
                  else
                    r9 = _nt_hstring
                    if r9
                      r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
                      r0 = r9
                    else
                      r10 = _nt_bstring
                      if r10
                        r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
                        r0 = r10
                      else
                        r11 = _nt_b64string
                        if r11
                          r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
                          r0 = r11
                        else
                          r12 = _nt_appstring
                          if r12
                            r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
                            r0 = r12
                          else
                            r13 = _nt_embedded
                            if r13
                              r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
                              r0 = r13
                            else
                              r14 = _nt_streamstring
                              if r14
                                r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
                                r0 = r14
                              else
                                @index = i0
                                r0 = nil
                              end
                            end
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end

    node_cache[:value][start_index] = r0

    r0
  end

  module Fnumber0
  end

  module Fnumber1
  end

  module Fnumber2
  end

  module Fnumber3
    def ip
      elements[0]
    end

    def dp
      elements[1]
    end

    def ep
      elements[2]
    end
  end

  module Fnumber4
    def to_rb
      if dp.empty? && ep.empty?
        ip.text_value.to_i
      else
        (ip.text_value + dp.text_value + ep.text_value).to_f
      end
    end
  end

  def _nt_fnumber
    start_index = index
    if node_cache[:fnumber].has_key?(index)
      cached = node_cache[:fnumber][index]
      if cached
        node_cache[:fnumber][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    i1, s1 = index, []
    if has_terminal?(@regexps[gr = '\A[-+]'] ||= Regexp.new(gr), :regexp, index)
      r3 = true
      @index += 1
    else
      terminal_parse_failure('[-+]')
      r3 = nil
    end
    if r3
      r2 = r3
    else
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s1 << r2
    if r2
      s4, i4 = [], index
      loop do
        if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
          r5 = true
          @index += 1
        else
          terminal_parse_failure('[0-9]')
          r5 = nil
        end
        if r5
          s4 << r5
        else
          break
        end
      end
      if s4.empty?
        @index = i4
        r4 = nil
      else
        r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
      end
      s1 << r4
    end
    if s1.last
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      r1.extend(Fnumber0)
    else
      @index = i1
      r1 = nil
    end
    s0 << r1
    if r1
      i7, s7 = index, []
      if (match_len = has_terminal?('.', false, index))
        r8 = true
        @index += match_len
      else
        terminal_parse_failure('\'.\'')
        r8 = nil
      end
      s7 << r8
      if r8
        s9, i9 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
            r10 = true
            @index += 1
          else
            terminal_parse_failure('[0-9]')
            r10 = nil
          end
          if r10
            s9 << r10
          else
            break
          end
        end
        if s9.empty?
          @index = i9
          r9 = nil
        else
          r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
        end
        s7 << r9
      end
      if s7.last
        r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
        r7.extend(Fnumber1)
      else
        @index = i7
        r7 = nil
      end
      if r7
        r6 = r7
      else
        r6 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r6
      if r6
        i12, s12 = index, []
        if has_terminal?(@regexps[gr = '\A[Ee]'] ||= Regexp.new(gr), :regexp, index)
          r13 = true
          @index += 1
        else
          terminal_parse_failure('[Ee]')
          r13 = nil
        end
        s12 << r13
        if r13
          if has_terminal?(@regexps[gr = '\A[-+]'] ||= Regexp.new(gr), :regexp, index)
            r15 = true
            @index += 1
          else
            terminal_parse_failure('[-+]')
            r15 = nil
          end
          if r15
            r14 = r15
          else
            r14 = instantiate_node(SyntaxNode,input, index...index)
          end
          s12 << r14
          if r14
            s16, i16 = [], index
            loop do
              if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
                r17 = true
                @index += 1
              else
                terminal_parse_failure('[0-9]')
                r17 = nil
              end
              if r17
                s16 << r17
              else
                break
              end
            end
            if s16.empty?
              @index = i16
              r16 = nil
            else
              r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
            end
            s12 << r16
          end
        end
        if s12.last
          r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
          r12.extend(Fnumber2)
        else
          @index = i12
          r12 = nil
        end
        if r12
          r11 = r12
        else
          r11 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r11
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Fnumber3)
      r0.extend(Fnumber4)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:fnumber][start_index] = r0

    r0
  end

  module Hnumber0
  end

  module Hnumber1
  end

  module Hnumber2
  end

  module Hnumber3
  end

  module Hnumber4
    def ip
      elements[0]
    end
  end

  module Hnumber5
    def to_rb
      Integer(ip.text_value)
    end
  end

  def _nt_hnumber
    start_index = index
    if node_cache[:hnumber].has_key?(index)
      cached = node_cache[:hnumber][index]
      if cached
        node_cache[:hnumber][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    i1, s1 = index, []
    if has_terminal?(@regexps[gr = '\A[-+]'] ||= Regexp.new(gr), :regexp, index)
      r3 = true
      @index += 1
    else
      terminal_parse_failure('[-+]')
      r3 = nil
    end
    if r3
      r2 = r3
    else
      r2 = instantiate_node(SyntaxNode,input, index...index)
    end
    s1 << r2
    if r2
      if (match_len = has_terminal?('0', false, index))
        r4 = true
        @index += match_len
      else
        terminal_parse_failure('\'0\'')
        r4 = nil
      end
      s1 << r4
      if r4
        i5 = index
        i6, s6 = index, []
        if has_terminal?(@regexps[gr = '\A[xX]'] ||= Regexp.new(gr), :regexp, index)
          r7 = true
          @index += 1
        else
          terminal_parse_failure('[xX]')
          r7 = nil
        end
        s6 << r7
        if r7
          s8, i8 = [], index
          loop do
            if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
              r9 = true
              @index += 1
            else
              terminal_parse_failure('[0-9a-fA-F]')
              r9 = nil
            end
            if r9
              s8 << r9
            else
              break
            end
          end
          if s8.empty?
            @index = i8
            r8 = nil
          else
            r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
          end
          s6 << r8
        end
        if s6.last
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          r6.extend(Hnumber0)
        else
          @index = i6
          r6 = nil
        end
        if r6
          r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
          r5 = r6
        else
          i10, s10 = index, []
          if has_terminal?(@regexps[gr = '\A[oO]'] ||= Regexp.new(gr), :regexp, index)
            r11 = true
            @index += 1
          else
            terminal_parse_failure('[oO]')
            r11 = nil
          end
          s10 << r11
          if r11
            s12, i12 = [], index
            loop do
              if has_terminal?(@regexps[gr = '\A[0-7]'] ||= Regexp.new(gr), :regexp, index)
                r13 = true
                @index += 1
              else
                terminal_parse_failure('[0-7]')
                r13 = nil
              end
              if r13
                s12 << r13
              else
                break
              end
            end
            if s12.empty?
              @index = i12
              r12 = nil
            else
              r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
            end
            s10 << r12
          end
          if s10.last
            r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
            r10.extend(Hnumber1)
          else
            @index = i10
            r10 = nil
          end
          if r10
            r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
            r5 = r10
          else
            i14, s14 = index, []
            if has_terminal?(@regexps[gr = '\A[bB]'] ||= Regexp.new(gr), :regexp, index)
              r15 = true
              @index += 1
            else
              terminal_parse_failure('[bB]')
              r15 = nil
            end
            s14 << r15
            if r15
              s16, i16 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[01]'] ||= Regexp.new(gr), :regexp, index)
                  r17 = true
                  @index += 1
                else
                  terminal_parse_failure('[01]')
                  r17 = nil
                end
                if r17
                  s16 << r17
                else
                  break
                end
              end
              if s16.empty?
                @index = i16
                r16 = nil
              else
                r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
              end
              s14 << r16
            end
            if s14.last
              r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
              r14.extend(Hnumber2)
            else
              @index = i14
              r14 = nil
            end
            if r14
              r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
              r5 = r14
            else
              @index = i5
              r5 = nil
            end
          end
        end
        s1 << r5
      end
    end
    if s1.last
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      r1.extend(Hnumber3)
    else
      @index = i1
      r1 = nil
    end
    s0 << r1
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Hnumber4)
      r0.extend(Hnumber5)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:hnumber][start_index] = r0

    r0
  end

  module Infin0
    def to_rb; Float::INFINITY end
  end

  module Infin1
    def to_rb; -Float::INFINITY end
  end

  module Infin2
    def to_rb; Float::NAN end
  end

  def _nt_infin
    start_index = index
    if node_cache[:infin].has_key?(index)
      cached = node_cache[:infin][index]
      if cached
        node_cache[:infin][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0 = index
    if (match_len = has_terminal?('Infinity', false, index))
      r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      r1.extend(Infin0)
      @index += match_len
    else
      terminal_parse_failure('\'Infinity\'')
      r1 = nil
    end
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
    else
      if (match_len = has_terminal?('-Infinity', false, index))
        r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        r2.extend(Infin1)
        @index += match_len
      else
        terminal_parse_failure('\'-Infinity\'')
        r2 = nil
      end
      if r2
        r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
        r0 = r2
      else
        if (match_len = has_terminal?('NaN', false, index))
          r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          r3.extend(Infin2)
          @index += match_len
        else
          terminal_parse_failure('\'NaN\'')
          r3 = nil
        end
        if r3
          r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
          r0 = r3
        else
          @index = i0
          r0 = nil
        end
      end
    end

    node_cache[:infin][start_index] = r0

    r0
  end

  module Simple0
    def to_rb; false end
  end

  module Simple1
    def to_rb; true end
  end

  module Simple2
    def to_rb; nil end
  end

  module Simple3
    def to_rb; CBOR::Simple.new(23) end
  end

  module Simple4
    def ows1
      elements[1]
    end

    def value
      elements[2]
    end

    def ows2
      elements[3]
    end

  end

  module Simple5
    def to_rb; CBOR::Simple.new(value.to_rb) end
  end

  def _nt_simple
    start_index = index
    if node_cache[:simple].has_key?(index)
      cached = node_cache[:simple][index]
      if cached
        node_cache[:simple][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0 = index
    if (match_len = has_terminal?('false', false, index))
      r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      r1.extend(Simple0)
      @index += match_len
    else
      terminal_parse_failure('\'false\'')
      r1 = nil
    end
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
    else
      if (match_len = has_terminal?('true', false, index))
        r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        r2.extend(Simple1)
        @index += match_len
      else
        terminal_parse_failure('\'true\'')
        r2 = nil
      end
      if r2
        r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
        r0 = r2
      else
        if (match_len = has_terminal?('null', false, index))
          r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          r3.extend(Simple2)
          @index += match_len
        else
          terminal_parse_failure('\'null\'')
          r3 = nil
        end
        if r3
          r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
          r0 = r3
        else
          if (match_len = has_terminal?('undefined', false, index))
            r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            r4.extend(Simple3)
            @index += match_len
          else
            terminal_parse_failure('\'undefined\'')
            r4 = nil
          end
          if r4
            r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
            r0 = r4
          else
            i5, s5 = index, []
            if (match_len = has_terminal?('simple(', false, index))
              r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
              @index += match_len
            else
              terminal_parse_failure('\'simple(\'')
              r6 = nil
            end
            s5 << r6
            if r6
              r7 = _nt_ows
              s5 << r7
              if r7
                r8 = _nt_value
                s5 << r8
                if r8
                  r9 = _nt_ows
                  s5 << r9
                  if r9
                    if (match_len = has_terminal?(')', false, index))
                      r10 = true
                      @index += match_len
                    else
                      terminal_parse_failure('\')\'')
                      r10 = nil
                    end
                    s5 << r10
                  end
                end
              end
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(Simple4)
              r5.extend(Simple5)
            else
              @index = i5
              r5 = nil
            end
            if r5
              r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
              r0 = r5
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end
    end

    node_cache[:simple][start_index] = r0

    r0
  end

  module Tagged0
    def tag
      elements[0]
    end

    def ows1
      elements[2]
    end

    def value
      elements[3]
    end

    def ows2
      elements[4]
    end

  end

  module Tagged1
    def to_rb
      CBOR::Tagged.new(tag.text_value.to_i, value.to_rb)
    end
  end

  def _nt_tagged
    start_index = index
    if node_cache[:tagged].has_key?(index)
      cached = node_cache[:tagged][index]
      if cached
        node_cache[:tagged][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    s1, i1 = [], index
    loop do
      if has_terminal?(@regexps[gr = '\A[0-9]'] ||= Regexp.new(gr), :regexp, index)
        r2 = true
        @index += 1
      else
        terminal_parse_failure('[0-9]')
        r2 = nil
      end
      if r2
        s1 << r2
      else
        break
      end
    end
    if s1.empty?
      @index = i1
      r1 = nil
    else
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    end
    s0 << r1
    if r1
      if (match_len = has_terminal?('(', false, index))
        r3 = true
        @index += match_len
      else
        terminal_parse_failure('\'(\'')
        r3 = nil
      end
      s0 << r3
      if r3
        r4 = _nt_ows
        s0 << r4
        if r4
          r5 = _nt_value
          s0 << r5
          if r5
            r6 = _nt_ows
            s0 << r6
            if r6
              if (match_len = has_terminal?(')', false, index))
                r7 = true
                @index += match_len
              else
                terminal_parse_failure('\')\'')
                r7 = nil
              end
              s0 << r7
            end
          end
        end
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Tagged0)
      r0.extend(Tagged1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:tagged][start_index] = r0

    r0
  end

  module String0
    def s
      elements[1]
    end

  end

  module String1
    #'
               def to_rb
                 s.elements.map(&:partval).join.force_encoding(Encoding::UTF_8)
               end
  end

  def _nt_string
    start_index = index
    if node_cache[:string].has_key?(index)
      cached = node_cache[:string][index]
      if cached
        node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if (match_len = has_terminal?('"', false, index))
      r1 = true
      @index += match_len
    else
      terminal_parse_failure('\'"\'')
      r1 = nil
    end
    s0 << r1
    if r1
      s2, i2 = [], index
      loop do
        r3 = _nt_string_part
        if r3
          s2 << r3
        else
          break
        end
      end
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
      s0 << r2
      if r2
        if (match_len = has_terminal?('"', false, index))
          r4 = true
          @index += match_len
        else
          terminal_parse_failure('\'"\'')
          r4 = nil
        end
        s0 << r4
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(String0)
      r0.extend(String1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:string][start_index] = r0

    r0
  end

  module StringPart0
    def partval; text_value.gsub("\r", "").b end
  end

  module StringPart1
    def s
      elements[1]
    end
  end

  module StringPart2
    #"
             def partval
               v = s.text_value
               {"b" => "\b", "f" => "\f", "n" => "\n", "r" => "\r", "t" => "\t"}[v] || v
             end
  end

  module StringPart3
  end

  module StringPart4
  end

  module StringPart5
    def s
      elements[1]
    end

    def t
      elements[3]
    end
  end

  module StringPart6
    def partval; (((s.text_value.to_i(16) & 0x3FF) << 10) +
                   (t.text_value.to_i(16) & 0x3FF) + 0x10000).chr(Encoding::UTF_8).b end
  end

  module StringPart7
  end

  module StringPart8
  end

  module StringPart9
    def s
      elements[1]
    end
  end

  module StringPart10
    def partval; s.text_value.to_i(16).chr(Encoding::UTF_8).b end
  end

  def _nt_string_part
    start_index = index
    if node_cache[:string_part].has_key?(index)
      cached = node_cache[:string_part][index]
      if cached
        node_cache[:string_part][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0 = index
    s1, i1 = [], index
    loop do
      if has_terminal?(@regexps[gr = '\A[^\\\\"\\t]'] ||= Regexp.new(gr), :regexp, index)
        r2 = true
        @index += 1
      else
        terminal_parse_failure('[^\\\\"\\t]')
        r2 = nil
      end
      if r2
        s1 << r2
      else
        break
      end
    end
    if s1.empty?
      @index = i1
      r1 = nil
    else
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      r1.extend(StringPart0)
      r1.extend(StringPart0)
    end
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
    else
      i3, s3 = index, []
      if (match_len = has_terminal?("\\", false, index))
        r4 = true
        @index += match_len
      else
        terminal_parse_failure('"\\\\"')
        r4 = nil
      end
      s3 << r4
      if r4
        if has_terminal?(@regexps[gr = '\A["\\\\/bfnrt]'] ||= Regexp.new(gr), :regexp, index)
          r5 = true
          @index += 1
        else
          terminal_parse_failure('["\\\\/bfnrt]')
          r5 = nil
        end
        s3 << r5
      end
      if s3.last
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        r3.extend(StringPart1)
        r3.extend(StringPart2)
      else
        @index = i3
        r3 = nil
      end
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        i6, s6 = index, []
        if (match_len = has_terminal?("\\u", false, index))
          r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          @index += match_len
        else
          terminal_parse_failure('"\\\\u"')
          r7 = nil
        end
        s6 << r7
        if r7
          i8, s8 = index, []
          if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
            r9 = true
            @index += 1
          else
            terminal_parse_failure('[dD]')
            r9 = nil
          end
          s8 << r9
          if r9
            if has_terminal?(@regexps[gr = '\A[89abAB]'] ||= Regexp.new(gr), :regexp, index)
              r10 = true
              @index += 1
            else
              terminal_parse_failure('[89abAB]')
              r10 = nil
            end
            s8 << r10
            if r10
              s11, i11 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                  r12 = true
                  @index += 1
                else
                  terminal_parse_failure('[0-9a-fA-F]')
                  r12 = nil
                end
                if r12
                  s11 << r12
                else
                  break
                end
                if s11.size == 2
                  break
                end
              end
              if s11.size < 2
                @index = i11
                r11 = nil
              else
                if s11.size < 2
                  @terminal_failures.pop
                end
                r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
              end
              s8 << r11
            end
          end
          if s8.last
            r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
            r8.extend(StringPart3)
          else
            @index = i8
            r8 = nil
          end
          s6 << r8
          if r8
            if (match_len = has_terminal?("\\u", false, index))
              r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
              @index += match_len
            else
              terminal_parse_failure('"\\\\u"')
              r13 = nil
            end
            s6 << r13
            if r13
              i14, s14 = index, []
              if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
                r15 = true
                @index += 1
              else
                terminal_parse_failure('[dD]')
                r15 = nil
              end
              s14 << r15
              if r15
                if has_terminal?(@regexps[gr = '\A[cCdDeEfF]'] ||= Regexp.new(gr), :regexp, index)
                  r16 = true
                  @index += 1
                else
                  terminal_parse_failure('[cCdDeEfF]')
                  r16 = nil
                end
                s14 << r16
                if r16
                  s17, i17 = [], index
                  loop do
                    if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                      r18 = true
                      @index += 1
                    else
                      terminal_parse_failure('[0-9a-fA-F]')
                      r18 = nil
                    end
                    if r18
                      s17 << r18
                    else
                      break
                    end
                    if s17.size == 2
                      break
                    end
                  end
                  if s17.size < 2
                    @index = i17
                    r17 = nil
                  else
                    if s17.size < 2
                      @terminal_failures.pop
                    end
                    r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
                  end
                  s14 << r17
                end
              end
              if s14.last
                r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
                r14.extend(StringPart4)
              else
                @index = i14
                r14 = nil
              end
              s6 << r14
            end
          end
        end
        if s6.last
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          r6.extend(StringPart5)
          r6.extend(StringPart6)
        else
          @index = i6
          r6 = nil
        end
        if r6
          r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
          r0 = r6
        else
          i19, s19 = index, []
          if (match_len = has_terminal?("\\u", false, index))
            r20 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"\\\\u"')
            r20 = nil
          end
          s19 << r20
          if r20
            i21 = index
            i22, s22 = index, []
            if has_terminal?(@regexps[gr = '\A[0-9abcefABCEF]'] ||= Regexp.new(gr), :regexp, index)
              r23 = true
              @index += 1
            else
              terminal_parse_failure('[0-9abcefABCEF]')
              r23 = nil
            end
            s22 << r23
            if r23
              s24, i24 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                  r25 = true
                  @index += 1
                else
                  terminal_parse_failure('[0-9a-fA-F]')
                  r25 = nil
                end
                if r25
                  s24 << r25
                else
                  break
                end
                if s24.size == 3
                  break
                end
              end
              if s24.size < 3
                @index = i24
                r24 = nil
              else
                if s24.size < 3
                  @terminal_failures.pop
                end
                r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
              end
              s22 << r24
            end
            if s22.last
              r22 = instantiate_node(SyntaxNode,input, i22...index, s22)
              r22.extend(StringPart7)
            else
              @index = i22
              r22 = nil
            end
            if r22
              r22 = SyntaxNode.new(input, (index-1)...index) if r22 == true
              r21 = r22
            else
              i26, s26 = index, []
              if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
                r27 = true
                @index += 1
              else
                terminal_parse_failure('[dD]')
                r27 = nil
              end
              s26 << r27
              if r27
                if has_terminal?(@regexps[gr = '\A[0-7]'] ||= Regexp.new(gr), :regexp, index)
                  r28 = true
                  @index += 1
                else
                  terminal_parse_failure('[0-7]')
                  r28 = nil
                end
                s26 << r28
                if r28
                  s29, i29 = [], index
                  loop do
                    if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                      r30 = true
                      @index += 1
                    else
                      terminal_parse_failure('[0-9a-fA-F]')
                      r30 = nil
                    end
                    if r30
                      s29 << r30
                    else
                      break
                    end
                    if s29.size == 2
                      break
                    end
                  end
                  if s29.size < 2
                    @index = i29
                    r29 = nil
                  else
                    if s29.size < 2
                      @terminal_failures.pop
                    end
                    r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
                  end
                  s26 << r29
                end
              end
              if s26.last
                r26 = instantiate_node(SyntaxNode,input, i26...index, s26)
                r26.extend(StringPart8)
              else
                @index = i26
                r26 = nil
              end
              if r26
                r26 = SyntaxNode.new(input, (index-1)...index) if r26 == true
                r21 = r26
              else
                @index = i21
                r21 = nil
              end
            end
            s19 << r21
          end
          if s19.last
            r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
            r19.extend(StringPart9)
            r19.extend(StringPart10)
          else
            @index = i19
            r19 = nil
          end
          if r19
            r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
            r0 = r19
          else
            @index = i0
            r0 = nil
          end
        end
      end
    end

    node_cache[:string_part][start_index] = r0

    r0
  end

  module Appstring0
  end

  module Appstring1
    def a
      elements[0]
    end

    def s
      elements[2]
    end

  end

  module Appstring2
    #'
               def to_rb
                 data = s.elements.map(&:partval).join.force_encoding(Encoding::UTF_8)
                 app = a.text_value
                 # Find a better place to put a default initialization
                 CBOR_DIAG.const_set(:APPS, Hash.new { |h, k|
                   h[k] = begin CBOR_DIAG.const_get("App_#{k.downcase}")
                          rescue NameError
                            raise ArgumentError.new("cbor-diagnostic: application-oriented extension #{k}'' unknown or not enabled")
                          end
                 }) unless CBOR_DIAG.const_defined?(:APPS)
                 CBOR_DIAG::APPS[app].decode(app, data)
               end
  end

  def _nt_appstring
    start_index = index
    if node_cache[:appstring].has_key?(index)
      cached = node_cache[:appstring][index]
      if cached
        node_cache[:appstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    i1, s1 = index, []
    if has_terminal?(@regexps[gr = '\A[a-z]'] ||= Regexp.new(gr), :regexp, index)
      r2 = true
      @index += 1
    else
      terminal_parse_failure('[a-z]')
      r2 = nil
    end
    s1 << r2
    if r2
      s3, i3 = [], index
      loop do
        if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
          r4 = true
          @index += 1
        else
          terminal_parse_failure('[a-z0-9]')
          r4 = nil
        end
        if r4
          s3 << r4
        else
          break
        end
      end
      r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
      s1 << r3
    end
    if s1.last
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      r1.extend(Appstring0)
    else
      @index = i1
      r1 = nil
    end
    s0 << r1
    if r1
      if (match_len = has_terminal?("'", false, index))
        r5 = true
        @index += match_len
      else
        terminal_parse_failure('"\'"')
        r5 = nil
      end
      s0 << r5
      if r5
        s6, i6 = [], index
        loop do
          r7 = _nt_bstring_part
          if r7
            s6 << r7
          else
            break
          end
        end
        r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
        s0 << r6
        if r6
          if (match_len = has_terminal?("'", false, index))
            r8 = true
            @index += match_len
          else
            terminal_parse_failure('"\'"')
            r8 = nil
          end
          s0 << r8
        end
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Appstring1)
      r0.extend(Appstring2)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:appstring][start_index] = r0

    r0
  end

  module Bstring0
    def s
      elements[1]
    end

  end

  module Bstring1
    #'
               def to_rb
                 s.elements.map(&:partval).join.b
               end
  end

  def _nt_bstring
    start_index = index
    if node_cache[:bstring].has_key?(index)
      cached = node_cache[:bstring][index]
      if cached
        node_cache[:bstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if (match_len = has_terminal?("'", false, index))
      r1 = true
      @index += match_len
    else
      terminal_parse_failure('"\'"')
      r1 = nil
    end
    s0 << r1
    if r1
      s2, i2 = [], index
      loop do
        r3 = _nt_bstring_part
        if r3
          s2 << r3
        else
          break
        end
      end
      r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
      s0 << r2
      if r2
        if (match_len = has_terminal?("'", false, index))
          r4 = true
          @index += match_len
        else
          terminal_parse_failure('"\'"')
          r4 = nil
        end
        s0 << r4
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Bstring0)
      r0.extend(Bstring1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:bstring][start_index] = r0

    r0
  end

  module BstringPart0
    def partval; text_value.gsub("\r", "") end
  end

  module BstringPart1
    def s
      elements[1]
    end
  end

  module BstringPart2
    def partval
      v = s.text_value
      {"b" => "\b", "f" => "\f", "n" => "\n", "r" => "\r", "t" => "\t"}[v] || v
    end
  end

  module BstringPart3
  end

  module BstringPart4
  end

  module BstringPart5
    def s
      elements[1]
    end

    def t
      elements[3]
    end
  end

  module BstringPart6
    def partval; (((s.text_value.to_i(16) & 0x3FF) << 10) +
                   (t.text_value.to_i(16) & 0x3FF) + 0x10000).chr(Encoding::UTF_8) end
  end

  module BstringPart7
  end

  module BstringPart8
  end

  module BstringPart9
    def s
      elements[1]
    end
  end

  module BstringPart10
    def partval; s.text_value.to_i(16).chr(Encoding::UTF_8) end
  end

  def _nt_bstring_part
    start_index = index
    if node_cache[:bstring_part].has_key?(index)
      cached = node_cache[:bstring_part][index]
      if cached
        node_cache[:bstring_part][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0 = index
    s1, i1 = [], index
    loop do
      if has_terminal?(@regexps[gr = '\A[^\\\\\'\\t]'] ||= Regexp.new(gr), :regexp, index)
        r2 = true
        @index += 1
      else
        terminal_parse_failure('[^\\\\\'\\t]')
        r2 = nil
      end
      if r2
        s1 << r2
      else
        break
      end
    end
    if s1.empty?
      @index = i1
      r1 = nil
    else
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      r1.extend(BstringPart0)
      r1.extend(BstringPart0)
    end
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
    else
      i3, s3 = index, []
      if (match_len = has_terminal?("\\", false, index))
        r4 = true
        @index += match_len
      else
        terminal_parse_failure('"\\\\"')
        r4 = nil
      end
      s3 << r4
      if r4
        if has_terminal?(@regexps[gr = '\A[\'\\\\/bfnrt]'] ||= Regexp.new(gr), :regexp, index)
          r5 = true
          @index += 1
        else
          terminal_parse_failure('[\'\\\\/bfnrt]')
          r5 = nil
        end
        s3 << r5
      end
      if s3.last
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        r3.extend(BstringPart1)
        r3.extend(BstringPart2)
      else
        @index = i3
        r3 = nil
      end
      if r3
        r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
        r0 = r3
      else
        i6, s6 = index, []
        if (match_len = has_terminal?("\\u", false, index))
          r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          @index += match_len
        else
          terminal_parse_failure('"\\\\u"')
          r7 = nil
        end
        s6 << r7
        if r7
          i8, s8 = index, []
          if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
            r9 = true
            @index += 1
          else
            terminal_parse_failure('[dD]')
            r9 = nil
          end
          s8 << r9
          if r9
            if has_terminal?(@regexps[gr = '\A[89abAB]'] ||= Regexp.new(gr), :regexp, index)
              r10 = true
              @index += 1
            else
              terminal_parse_failure('[89abAB]')
              r10 = nil
            end
            s8 << r10
            if r10
              s11, i11 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                  r12 = true
                  @index += 1
                else
                  terminal_parse_failure('[0-9a-fA-F]')
                  r12 = nil
                end
                if r12
                  s11 << r12
                else
                  break
                end
                if s11.size == 2
                  break
                end
              end
              if s11.size < 2
                @index = i11
                r11 = nil
              else
                if s11.size < 2
                  @terminal_failures.pop
                end
                r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
              end
              s8 << r11
            end
          end
          if s8.last
            r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
            r8.extend(BstringPart3)
          else
            @index = i8
            r8 = nil
          end
          s6 << r8
          if r8
            if (match_len = has_terminal?("\\u", false, index))
              r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
              @index += match_len
            else
              terminal_parse_failure('"\\\\u"')
              r13 = nil
            end
            s6 << r13
            if r13
              i14, s14 = index, []
              if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
                r15 = true
                @index += 1
              else
                terminal_parse_failure('[dD]')
                r15 = nil
              end
              s14 << r15
              if r15
                if has_terminal?(@regexps[gr = '\A[cCdDeEfF]'] ||= Regexp.new(gr), :regexp, index)
                  r16 = true
                  @index += 1
                else
                  terminal_parse_failure('[cCdDeEfF]')
                  r16 = nil
                end
                s14 << r16
                if r16
                  s17, i17 = [], index
                  loop do
                    if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                      r18 = true
                      @index += 1
                    else
                      terminal_parse_failure('[0-9a-fA-F]')
                      r18 = nil
                    end
                    if r18
                      s17 << r18
                    else
                      break
                    end
                    if s17.size == 2
                      break
                    end
                  end
                  if s17.size < 2
                    @index = i17
                    r17 = nil
                  else
                    if s17.size < 2
                      @terminal_failures.pop
                    end
                    r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
                  end
                  s14 << r17
                end
              end
              if s14.last
                r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
                r14.extend(BstringPart4)
              else
                @index = i14
                r14 = nil
              end
              s6 << r14
            end
          end
        end
        if s6.last
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          r6.extend(BstringPart5)
          r6.extend(BstringPart6)
        else
          @index = i6
          r6 = nil
        end
        if r6
          r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
          r0 = r6
        else
          i19, s19 = index, []
          if (match_len = has_terminal?("\\u", false, index))
            r20 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"\\\\u"')
            r20 = nil
          end
          s19 << r20
          if r20
            i21 = index
            i22, s22 = index, []
            if has_terminal?(@regexps[gr = '\A[0-9abcefABCEF]'] ||= Regexp.new(gr), :regexp, index)
              r23 = true
              @index += 1
            else
              terminal_parse_failure('[0-9abcefABCEF]')
              r23 = nil
            end
            s22 << r23
            if r23
              s24, i24 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                  r25 = true
                  @index += 1
                else
                  terminal_parse_failure('[0-9a-fA-F]')
                  r25 = nil
                end
                if r25
                  s24 << r25
                else
                  break
                end
                if s24.size == 3
                  break
                end
              end
              if s24.size < 3
                @index = i24
                r24 = nil
              else
                if s24.size < 3
                  @terminal_failures.pop
                end
                r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
              end
              s22 << r24
            end
            if s22.last
              r22 = instantiate_node(SyntaxNode,input, i22...index, s22)
              r22.extend(BstringPart7)
            else
              @index = i22
              r22 = nil
            end
            if r22
              r22 = SyntaxNode.new(input, (index-1)...index) if r22 == true
              r21 = r22
            else
              i26, s26 = index, []
              if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
                r27 = true
                @index += 1
              else
                terminal_parse_failure('[dD]')
                r27 = nil
              end
              s26 << r27
              if r27
                if has_terminal?(@regexps[gr = '\A[0-7]'] ||= Regexp.new(gr), :regexp, index)
                  r28 = true
                  @index += 1
                else
                  terminal_parse_failure('[0-7]')
                  r28 = nil
                end
                s26 << r28
                if r28
                  s29, i29 = [], index
                  loop do
                    if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
                      r30 = true
                      @index += 1
                    else
                      terminal_parse_failure('[0-9a-fA-F]')
                      r30 = nil
                    end
                    if r30
                      s29 << r30
                    else
                      break
                    end
                    if s29.size == 2
                      break
                    end
                  end
                  if s29.size < 2
                    @index = i29
                    r29 = nil
                  else
                    if s29.size < 2
                      @terminal_failures.pop
                    end
                    r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
                  end
                  s26 << r29
                end
              end
              if s26.last
                r26 = instantiate_node(SyntaxNode,input, i26...index, s26)
                r26.extend(BstringPart8)
              else
                @index = i26
                r26 = nil
              end
              if r26
                r26 = SyntaxNode.new(input, (index-1)...index) if r26 == true
                r21 = r26
              else
                @index = i21
                r21 = nil
              end
            end
            s19 << r21
          end
          if s19.last
            r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
            r19.extend(BstringPart9)
            r19.extend(BstringPart10)
          else
            @index = i19
            r19 = nil
          end
          if r19
            r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
            r0 = r19
          else
            @index = i0
            r0 = nil
          end
        end
      end
    end

    node_cache[:bstring_part][start_index] = r0

    r0
  end

  module Embedded0
    def s
      elements[1]
    end

  end

  module Embedded1
    def to_rb
      if se = s
        sn = se.to_rb
        if CBOR::Sequence === sn
          sn.to_cborseq
        else
          CBOR.encode(sn)
        end
      else
        "".b
      end
    end
  end

  def _nt_embedded
    start_index = index
    if node_cache[:embedded].has_key?(index)
      cached = node_cache[:embedded][index]
      if cached
        node_cache[:embedded][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if (match_len = has_terminal?("<<", false, index))
      r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      @index += match_len
    else
      terminal_parse_failure('"<<"')
      r1 = nil
    end
    s0 << r1
    if r1
      r3 = _nt_text
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r2
      if r2
        if (match_len = has_terminal?(">>", false, index))
          r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          @index += match_len
        else
          terminal_parse_failure('">>"')
          r4 = nil
        end
        s0 << r4
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Embedded0)
      r0.extend(Embedded1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:embedded][start_index] = r0

    r0
  end

  module Hexdigit0
    def dig
      elements[0]
    end
  end

  module Hexdigit1
    def sval; dig.text_value end
  end

  def _nt_hexdigit
    start_index = index
    if node_cache[:hexdigit].has_key?(index)
      cached = node_cache[:hexdigit][index]
      if cached
        node_cache[:hexdigit][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
      r1 = true
      @index += 1
    else
      terminal_parse_failure('[0-9a-fA-F]')
      r1 = nil
    end
    s0 << r1
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Hexdigit0)
      r0.extend(Hexdigit1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:hexdigit][start_index] = r0

    r0
  end

  module Twohex0
    def s1
      elements[0]
    end

    def ows1
      elements[1]
    end

    def s2
      elements[2]
    end

    def ows2
      elements[3]
    end
  end

  module Twohex1
    def bval; (s1.sval << s2.sval).to_i(16).chr(Encoding::BINARY) end
  end

  def _nt_twohex
    start_index = index
    if node_cache[:twohex].has_key?(index)
      cached = node_cache[:twohex][index]
      if cached
        node_cache[:twohex][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    r1 = _nt_hexdigit
    s0 << r1
    if r1
      r2 = _nt_ows
      s0 << r2
      if r2
        r3 = _nt_hexdigit
        s0 << r3
        if r3
          r4 = _nt_ows
          s0 << r4
        end
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Twohex0)
      r0.extend(Twohex1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:twohex][start_index] = r0

    r0
  end

  module Hstring0
    def ows
      elements[1]
    end

    def s
      elements[2]
    end

  end

  module Hstring1
    #"
                def to_rb;
                  s.elements.map(&:bval).join.b
                end
  end

  def _nt_hstring
    start_index = index
    if node_cache[:hstring].has_key?(index)
      cached = node_cache[:hstring][index]
      if cached
        node_cache[:hstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if (match_len = has_terminal?("h'", false, index))
      r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      @index += match_len
    else
      terminal_parse_failure('"h\'"')
      r1 = nil
    end
    s0 << r1
    if r1
      r2 = _nt_ows
      s0 << r2
      if r2
        s3, i3 = [], index
        loop do
          r4 = _nt_twohex
          if r4
            s3 << r4
          else
            break
          end
        end
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        s0 << r3
        if r3
          if (match_len = has_terminal?("'", false, index))
            r5 = true
            @index += match_len
          else
            terminal_parse_failure('"\'"')
            r5 = nil
          end
          s0 << r5
        end
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Hstring0)
      r0.extend(Hstring1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:hstring][start_index] = r0

    r0
  end

  def _nt_hbstring
    start_index = index
    if node_cache[:hbstring].has_key?(index)
      cached = node_cache[:hbstring][index]
      if cached
        node_cache[:hbstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0 = index
    r1 = _nt_hstring
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
    else
      r2 = _nt_bstring
      if r2
        r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
        r0 = r2
      else
        @index = i0
        r0 = nil
      end
    end

    node_cache[:hbstring][start_index] = r0

    r0
  end

  module B64string0
  end

  module B64string1
    def s
      elements[1]
    end

  end

  module B64string2
    #"
                def to_rb;
                  t = s.text_value.gsub(/\s/, '').chars.each_slice(4).map(&:join)
                  if last = t[-1]
                    last << "=" * (4 - last.size)
                  end
                  begin
                    t.join.tr("-_", "+/").unpack("m0")[0]
                  rescue ArgumentError
                    raise ArgumentError.new("invalid base64 #{t}")
                  end
                end
  end

  def _nt_b64string
    start_index = index
    if node_cache[:b64string].has_key?(index)
      cached = node_cache[:b64string][index]
      if cached
        node_cache[:b64string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if (match_len = has_terminal?("b64'", false, index))
      r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      @index += match_len
    else
      terminal_parse_failure('"b64\'"')
      r1 = nil
    end
    s0 << r1
    if r1
      i2, s2 = index, []
      s3, i3 = [], index
      loop do
        if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_\\-+/\\s]'] ||= Regexp.new(gr), :regexp, index)
          r4 = true
          @index += 1
        else
          terminal_parse_failure('[0-9a-zA-Z_\\-+/\\s]')
          r4 = nil
        end
        if r4
          s3 << r4
        else
          break
        end
      end
      r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
      s2 << r3
      if r3
        s5, i5 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[=\\s]'] ||= Regexp.new(gr), :regexp, index)
            r6 = true
            @index += 1
          else
            terminal_parse_failure('[=\\s]')
            r6 = nil
          end
          if r6
            s5 << r6
          else
            break
          end
        end
        r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
        s2 << r5
      end
      if s2.last
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        r2.extend(B64string0)
      else
        @index = i2
        r2 = nil
      end
      s0 << r2
      if r2
        if (match_len = has_terminal?("'", false, index))
          r7 = true
          @index += match_len
        else
          terminal_parse_failure('"\'"')
          r7 = nil
        end
        s0 << r7
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(B64string1)
      r0.extend(B64string2)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:b64string][start_index] = r0

    r0
  end

  module Array0
    def soc
      elements[0]
    end

    def value
      elements[1]
    end
  end

  module Array1
    def value
      elements[0]
    end

    def ows
      elements[1]
    end

    def an
      elements[2]
    end
  end

  module Array2
    def spec
      elements[1]
    end

    def a1
      elements[2]
    end

    def soc
      elements[3]
    end

  end

  module Array3
    def to_rb
      r = if e = a1.elements
        [e[0].to_rb] + e[2].elements.map {|x| x.value.to_rb }
      else
        []
      end
      if spec.is_stream?
        r.cbor_stream!
      end
      r
    end
  end

  def _nt_array
    start_index = index
    if node_cache[:array].has_key?(index)
      cached = node_cache[:array][index]
      if cached
        node_cache[:array][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if (match_len = has_terminal?('[', false, index))
      r1 = true
      @index += match_len
    else
      terminal_parse_failure('\'[\'')
      r1 = nil
    end
    s0 << r1
    if r1
      r2 = _nt_spec
      s0 << r2
      if r2
        i4, s4 = index, []
        r5 = _nt_value
        s4 << r5
        if r5
          r6 = _nt_ows
          s4 << r6
          if r6
            s7, i7 = [], index
            loop do
              i8, s8 = index, []
              r9 = _nt_soc
              s8 << r9
              if r9
                r10 = _nt_value
                s8 << r10
              end
              if s8.last
                r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
                r8.extend(Array0)
              else
                @index = i8
                r8 = nil
              end
              if r8
                s7 << r8
              else
                break
              end
            end
            r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
            s4 << r7
          end
        end
        if s4.last
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          r4.extend(Array1)
        else
          @index = i4
          r4 = nil
        end
        if r4
          r3 = r4
        else
          r3 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r3
        if r3
          r11 = _nt_soc
          s0 << r11
          if r11
            if (match_len = has_terminal?(']', false, index))
              r12 = true
              @index += match_len
            else
              terminal_parse_failure('\']\'')
              r12 = nil
            end
            s0 << r12
          end
        end
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Array2)
      r0.extend(Array3)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:array][start_index] = r0

    r0
  end

  module Map0
    def soc
      elements[0]
    end

    def kp
      elements[1]
    end
  end

  module Map1
    def kp
      elements[0]
    end

    def ows
      elements[1]
    end

    def an
      elements[2]
    end
  end

  module Map2
    def spec
      elements[1]
    end

    def a1
      elements[2]
    end

    def soc
      elements[3]
    end

  end

  module Map3
    def to_rb
      r = if e = a1.elements
        Hash[ [e[0].to_rb] + e[2].elements.map {|x| x.kp.to_rb } ]
      else
        {}
      end
      if spec.is_stream?
        r.cbor_stream!
      end
      r
    end
  end

  def _nt_map
    start_index = index
    if node_cache[:map].has_key?(index)
      cached = node_cache[:map][index]
      if cached
        node_cache[:map][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    if (match_len = has_terminal?('{', false, index))
      r1 = true
      @index += match_len
    else
      terminal_parse_failure('\'{\'')
      r1 = nil
    end
    s0 << r1
    if r1
      r2 = _nt_spec
      s0 << r2
      if r2
        i4, s4 = index, []
        r5 = _nt_kp
        s4 << r5
        if r5
          r6 = _nt_ows
          s4 << r6
          if r6
            s7, i7 = [], index
            loop do
              i8, s8 = index, []
              r9 = _nt_soc
              s8 << r9
              if r9
                r10 = _nt_kp
                s8 << r10
              end
              if s8.last
                r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
                r8.extend(Map0)
              else
                @index = i8
                r8 = nil
              end
              if r8
                s7 << r8
              else
                break
              end
            end
            r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
            s4 << r7
          end
        end
        if s4.last
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          r4.extend(Map1)
        else
          @index = i4
          r4 = nil
        end
        if r4
          r3 = r4
        else
          r3 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r3
        if r3
          r11 = _nt_soc
          s0 << r11
          if r11
            if (match_len = has_terminal?('}', false, index))
              r12 = true
              @index += match_len
            else
              terminal_parse_failure('\'}\'')
              r12 = nil
            end
            s0 << r12
          end
        end
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Map2)
      r0.extend(Map3)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:map][start_index] = r0

    r0
  end

  module Kp0
    def v1
      elements[0]
    end

    def ows1
      elements[1]
    end

    def ows2
      elements[3]
    end

    def v2
      elements[4]
    end
  end

  module Kp1
    def to_rb
      [v1.to_rb, v2.to_rb]
    end
  end

  def _nt_kp
    start_index = index
    if node_cache[:kp].has_key?(index)
      cached = node_cache[:kp][index]
      if cached
        node_cache[:kp][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    r1 = _nt_value
    s0 << r1
    if r1
      r2 = _nt_ows
      s0 << r2
      if r2
        if (match_len = has_terminal?(":", false, index))
          r3 = true
          @index += match_len
        else
          terminal_parse_failure('":"')
          r3 = nil
        end
        s0 << r3
        if r3
          r4 = _nt_ows
          s0 << r4
          if r4
            r5 = _nt_value
            s0 << r5
          end
        end
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Kp0)
      r0.extend(Kp1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:kp][start_index] = r0

    r0
  end

  module Ows0
  end

  module Ows1
  end

  module Ows2
    def sval; "" end
  end

  def _nt_ows
    start_index = index
    if node_cache[:ows].has_key?(index)
      cached = node_cache[:ows][index]
      if cached
        node_cache[:ows][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    s1, i1 = [], index
    loop do
      if has_terminal?(@regexps[gr = '\A[ \\t\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
        r2 = true
        @index += 1
      else
        terminal_parse_failure('[ \\t\\n\\r]')
        r2 = nil
      end
      if r2
        s1 << r2
      else
        break
      end
    end
    r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
    s0 << r1
    if r1
      s3, i3 = [], index
      loop do
        i4, s4 = index, []
        if (match_len = has_terminal?("/", false, index))
          r5 = true
          @index += match_len
        else
          terminal_parse_failure('"/"')
          r5 = nil
        end
        s4 << r5
        if r5
          s6, i6 = [], index
          loop do
            if has_terminal?(@regexps[gr = '\A[^/]'] ||= Regexp.new(gr), :regexp, index)
              r7 = true
              @index += 1
            else
              terminal_parse_failure('[^/]')
              r7 = nil
            end
            if r7
              s6 << r7
            else
              break
            end
          end
          r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
          s4 << r6
          if r6
            if (match_len = has_terminal?("/", false, index))
              r8 = true
              @index += match_len
            else
              terminal_parse_failure('"/"')
              r8 = nil
            end
            s4 << r8
            if r8
              s9, i9 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[ \\t\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
                  r10 = true
                  @index += 1
                else
                  terminal_parse_failure('[ \\t\\n\\r]')
                  r10 = nil
                end
                if r10
                  s9 << r10
                else
                  break
                end
              end
              r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
              s4 << r9
            end
          end
        end
        if s4.last
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          r4.extend(Ows0)
        else
          @index = i4
          r4 = nil
        end
        if r4
          s3 << r4
        else
          break
        end
      end
      r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
      s0 << r3
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Ows1)
      r0.extend(Ows2)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:ows][start_index] = r0

    r0
  end

  module Soc0
    def ows
      elements[1]
    end
  end

  module Soc1
    def ows
      elements[0]
    end

  end

  module Soc2
    def sval; "" end
  end

  def _nt_soc
    start_index = index
    if node_cache[:soc].has_key?(index)
      cached = node_cache[:soc][index]
      if cached
        node_cache[:soc][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    r1 = _nt_ows
    s0 << r1
    if r1
      i3, s3 = index, []
      if (match_len = has_terminal?(',', false, index))
        r4 = true
        @index += match_len
      else
        terminal_parse_failure('\',\'')
        r4 = nil
      end
      s3 << r4
      if r4
        r5 = _nt_ows
        s3 << r5
      end
      if s3.last
        r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
        r3.extend(Soc0)
      else
        @index = i3
        r3 = nil
      end
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r2
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Soc1)
      r0.extend(Soc2)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:soc][start_index] = r0

    r0
  end

  module Streamstring0
    def ows1
      elements[1]
    end

    def string
      elements[2]
    end

    def ows2
      elements[3]
    end
  end

  module Streamstring1
    def string
      elements[0]
    end

    def ows
      elements[1]
    end

    def an
      elements[2]
    end
  end

  module Streamstring2
    def ows1
      elements[1]
    end

    def ows2
      elements[3]
    end

    def a1
      elements[4]
    end

  end

  module Streamstring3
    def to_rb
       r = if e = a1.elements
         [e[0].to_rb] + e[2].elements.map {|x| x.string.to_rb }
       else
         []
       end
       r.join.cbor_stream!(r.map(&:size))
    end
  end

  module Streamstring4
    def ows1
      elements[1]
    end

    def hbstring
      elements[2]
    end

    def ows2
      elements[3]
    end
  end

  module Streamstring5
    def hbstring
      elements[0]
    end

    def ows
      elements[1]
    end

    def an
      elements[2]
    end
  end

  module Streamstring6
    def ows1
      elements[1]
    end

    def ows2
      elements[3]
    end

    def a1
      elements[4]
    end

  end

  module Streamstring7
    def to_rb
       r = if e = a1.elements
         [e[0].to_rb] + e[2].elements.map {|x| x.hbstring.to_rb }
       else
         []
       end
       r.join.b.cbor_stream!(r.map(&:size))
    end
  end

  def _nt_streamstring
    start_index = index
    if node_cache[:streamstring].has_key?(index)
      cached = node_cache[:streamstring][index]
      if cached
        node_cache[:streamstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0 = index
    i1, s1 = index, []
    if (match_len = has_terminal?('(', false, index))
      r2 = true
      @index += match_len
    else
      terminal_parse_failure('\'(\'')
      r2 = nil
    end
    s1 << r2
    if r2
      r3 = _nt_ows
      s1 << r3
      if r3
        if (match_len = has_terminal?("_", false, index))
          r4 = true
          @index += match_len
        else
          terminal_parse_failure('"_"')
          r4 = nil
        end
        s1 << r4
        if r4
          r5 = _nt_ows
          s1 << r5
          if r5
            i6, s6 = index, []
            r7 = _nt_string
            s6 << r7
            if r7
              r8 = _nt_ows
              s6 << r8
              if r8
                s9, i9 = [], index
                loop do
                  i10, s10 = index, []
                  if (match_len = has_terminal?(",", false, index))
                    r11 = true
                    @index += match_len
                  else
                    terminal_parse_failure('","')
                    r11 = nil
                  end
                  s10 << r11
                  if r11
                    r12 = _nt_ows
                    s10 << r12
                    if r12
                      r13 = _nt_string
                      s10 << r13
                      if r13
                        r14 = _nt_ows
                        s10 << r14
                      end
                    end
                  end
                  if s10.last
                    r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
                    r10.extend(Streamstring0)
                  else
                    @index = i10
                    r10 = nil
                  end
                  if r10
                    s9 << r10
                  else
                    break
                  end
                end
                r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
                s6 << r9
              end
            end
            if s6.last
              r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
              r6.extend(Streamstring1)
            else
              @index = i6
              r6 = nil
            end
            s1 << r6
            if r6
              if (match_len = has_terminal?(')', false, index))
                r15 = true
                @index += match_len
              else
                terminal_parse_failure('\')\'')
                r15 = nil
              end
              s1 << r15
            end
          end
        end
      end
    end
    if s1.last
      r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
      r1.extend(Streamstring2)
      r1.extend(Streamstring3)
    else
      @index = i1
      r1 = nil
    end
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
    else
      i16, s16 = index, []
      if (match_len = has_terminal?('(', false, index))
        r17 = true
        @index += match_len
      else
        terminal_parse_failure('\'(\'')
        r17 = nil
      end
      s16 << r17
      if r17
        r18 = _nt_ows
        s16 << r18
        if r18
          if (match_len = has_terminal?("_", false, index))
            r19 = true
            @index += match_len
          else
            terminal_parse_failure('"_"')
            r19 = nil
          end
          s16 << r19
          if r19
            r20 = _nt_ows
            s16 << r20
            if r20
              i21, s21 = index, []
              r22 = _nt_hbstring
              s21 << r22
              if r22
                r23 = _nt_ows
                s21 << r23
                if r23
                  s24, i24 = [], index
                  loop do
                    i25, s25 = index, []
                    if (match_len = has_terminal?(",", false, index))
                      r26 = true
                      @index += match_len
                    else
                      terminal_parse_failure('","')
                      r26 = nil
                    end
                    s25 << r26
                    if r26
                      r27 = _nt_ows
                      s25 << r27
                      if r27
                        r28 = _nt_hbstring
                        s25 << r28
                        if r28
                          r29 = _nt_ows
                          s25 << r29
                        end
                      end
                    end
                    if s25.last
                      r25 = instantiate_node(SyntaxNode,input, i25...index, s25)
                      r25.extend(Streamstring4)
                    else
                      @index = i25
                      r25 = nil
                    end
                    if r25
                      s24 << r25
                    else
                      break
                    end
                  end
                  r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
                  s21 << r24
                end
              end
              if s21.last
                r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
                r21.extend(Streamstring5)
              else
                @index = i21
                r21 = nil
              end
              s16 << r21
              if r21
                if (match_len = has_terminal?(')', false, index))
                  r30 = true
                  @index += match_len
                else
                  terminal_parse_failure('\')\'')
                  r30 = nil
                end
                s16 << r30
              end
            end
          end
        end
      end
      if s16.last
        r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
        r16.extend(Streamstring6)
        r16.extend(Streamstring7)
      else
        @index = i16
        r16 = nil
      end
      if r16
        r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
        r0 = r16
      else
        @index = i0
        r0 = nil
      end
    end

    node_cache[:streamstring][start_index] = r0

    r0
  end

  module Spec0
    def ows1
      elements[0]
    end

    def a1
      elements[1]
    end

    def ows2
      elements[2]
    end
  end

  module Spec1
    def is_stream?
      !a1.empty?
    end
  end

  def _nt_spec
    start_index = index
    if node_cache[:spec].has_key?(index)
      cached = node_cache[:spec][index]
      if cached
        node_cache[:spec][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
        @index = cached.interval.end
      end
      return cached
    end

    i0, s0 = index, []
    r1 = _nt_ows
    s0 << r1
    if r1
      if (match_len = has_terminal?("_", false, index))
        r3 = true
        @index += match_len
      else
        terminal_parse_failure('"_"')
        r3 = nil
      end
      if r3
        r2 = r3
      else
        r2 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r2
      if r2
        r4 = _nt_ows
        s0 << r4
      end
    end
    if s0.last
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      r0.extend(Spec0)
      r0.extend(Spec1)
    else
      @index = i0
      r0 = nil
    end

    node_cache[:spec][start_index] = r0

    r0
  end


  class Parser < Treetop::Runtime::CompiledParser
    include CBOR_DIAG
  end
end

CBOR_DIAGParser = CBOR_DIAG::Parser

