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

module WorkingSet
  module QueryLanguage
    include Treetop::Runtime

    def root
      @root ||= :boolean_expression
    end

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

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

      node_cache[:boolean_expression][start_index] = r0

      r0
    end

    module Conjonctive0
      def head
        elements[0]
      end

      def spacer1
        elements[1]
      end

      def spacer2
        elements[3]
      end

      def operand
        elements[4]
      end
    end

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

      i0 = index
      i1, s1 = index, []
      r2 = _nt_test
      s1 << r2
      if r2
        r3 = _nt_spacer
        s1 << r3
        if r3
          if (match_len = has_terminal?("and", false, index))
            r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"and"')
            r4 = nil
          end
          s1 << r4
          if r4
            r5 = _nt_spacer
            s1 << r5
            if r5
              r6 = _nt_conjonctive
              s1 << r6
            end
          end
        end
      end
      if s1.last
        r1 = instantiate_node(Conjunction,input, i1...index, s1)
        r1.extend(Conjonctive0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
        r0 = r1
      else
        r7 = _nt_test
        if r7
          r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
          r0 = r7
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:conjonctive][start_index] = r0

      r0
    end

    module Disjunctive0
      def head
        elements[0]
      end

      def spacer1
        elements[1]
      end

      def spacer2
        elements[3]
      end

      def operand
        elements[4]
      end
    end

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

      i0 = index
      i1, s1 = index, []
      r2 = _nt_conjonctive
      s1 << r2
      if r2
        r3 = _nt_spacer
        s1 << r3
        if r3
          if (match_len = has_terminal?("or", false, index))
            r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"or"')
            r4 = nil
          end
          s1 << r4
          if r4
            r5 = _nt_spacer
            s1 << r5
            if r5
              r6 = _nt_disjunctive
              s1 << r6
            end
          end
        end
      end
      if s1.last
        r1 = instantiate_node(Disjunction,input, i1...index, s1)
        r1.extend(Disjunctive0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
        r0 = r1
      else
        r7 = _nt_conjonctive
        if r7
          r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
          r0 = r7
        else
          @index = i0
          r0 = nil
        end
      end

      node_cache[:disjunctive][start_index] = r0

      r0
    end

    module Test0
      def boolean_expression
        elements[1]
      end
    end

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

      i0 = index
      r1 = _nt_abilitive
      if r1
        r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
        r0 = r1
      else
        r2 = _nt_essence
        if r2
          r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
          r0 = r2
        else
          r3 = _nt_non_essence
          if r3
            r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
            r0 = r3
          else
            r4 = _nt_derivative
            if r4
              r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
              r0 = r4
            else
              r5 = _nt_non_derivative
              if r5
                r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
                r0 = r5
              else
                r6 = _nt_inclusion
                if r6
                  r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
                  r0 = r6
                else
                  r7 = _nt_indicative
                  if r7
                    r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
                    r0 = r7
                  else
                    r8 = _nt_negative
                    if r8
                      r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
                      r0 = r8
                    else
                      i9, s9 = index, []
                      if (match_len = has_terminal?("(", false, index))
                        r10 = true
                        @index += match_len
                      else
                        terminal_parse_failure('"("')
                        r10 = nil
                      end
                      s9 << r10
                      if r10
                        r11 = _nt_boolean_expression
                        s9 << r11
                        if r11
                          if (match_len = has_terminal?(")", false, index))
                            r12 = true
                            @index += match_len
                          else
                            terminal_parse_failure('")"')
                            r12 = nil
                          end
                          s9 << r12
                        end
                      end
                      if s9.last
                        r9 = instantiate_node(BooleanExpression,input, i9...index, s9)
                        r9.extend(Test0)
                      else
                        @index = i9
                        r9 = nil
                      end
                      if r9
                        r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
                        r0 = r9
                      else
                        @index = i0
                        r0 = nil
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end

      node_cache[:test][start_index] = r0

      r0
    end

    module Essence0
      def spacer
        elements[1]
      end

      def variety_name
        elements[2]
      end
    end

    def _nt_essence
      start_index = index
      if node_cache[:essence].has_key?(index)
        cached = node_cache[:essence][index]
        if cached
          node_cache[:essence][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?("is", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"is"')
        r1 = nil
      end
      s0 << r1
      if r1
        r2 = _nt_spacer
        s0 << r2
        if r2
          r3 = _nt_variety_name
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(EssenceTest,input, i0...index, s0)
        r0.extend(Essence0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:essence][start_index] = r0

      r0
    end

    module NonEssence0
      def spacer
        elements[1]
      end

      def variety_name
        elements[2]
      end
    end

    def _nt_non_essence
      start_index = index
      if node_cache[:non_essence].has_key?(index)
        cached = node_cache[:non_essence][index]
        if cached
          node_cache[:non_essence][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?("isnt", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"isnt"')
        r1 = nil
      end
      s0 << r1
      if r1
        r2 = _nt_spacer
        s0 << r2
        if r2
          r3 = _nt_variety_name
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(NonEssenceTest,input, i0...index, s0)
        r0.extend(NonEssence0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:non_essence][start_index] = r0

      r0
    end

    module Derivative0
      def spacer1
        elements[1]
      end

      def spacer2
        elements[3]
      end

      def variety_name
        elements[4]
      end
    end

    def _nt_derivative
      start_index = index
      if node_cache[:derivative].has_key?(index)
        cached = node_cache[:derivative][index]
        if cached
          node_cache[:derivative][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?("derives", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"derives"')
        r1 = nil
      end
      s0 << r1
      if r1
        r2 = _nt_spacer
        s0 << r2
        if r2
          if (match_len = has_terminal?("from", false, index))
            r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"from"')
            r3 = nil
          end
          s0 << r3
          if r3
            r4 = _nt_spacer
            s0 << r4
            if r4
              r5 = _nt_variety_name
              s0 << r5
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(DerivativeTest,input, i0...index, s0)
        r0.extend(Derivative0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:derivative][start_index] = r0

      r0
    end

    module NonDerivative0
      def spacer1
        elements[1]
      end

      def spacer2
        elements[3]
      end

      def spacer3
        elements[5]
      end

      def variety_name
        elements[6]
      end
    end

    def _nt_non_derivative
      start_index = index
      if node_cache[:non_derivative].has_key?(index)
        cached = node_cache[:non_derivative][index]
        if cached
          node_cache[:non_derivative][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?("dont", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"dont"')
        r1 = nil
      end
      s0 << r1
      if r1
        r2 = _nt_spacer
        s0 << r2
        if r2
          if (match_len = has_terminal?("derive", false, index))
            r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"derive"')
            r3 = nil
          end
          s0 << r3
          if r3
            r4 = _nt_spacer
            s0 << r4
            if r4
              if (match_len = has_terminal?("from", false, index))
                r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
                @index += match_len
              else
                terminal_parse_failure('"from"')
                r5 = nil
              end
              s0 << r5
              if r5
                r6 = _nt_spacer
                s0 << r6
                if r6
                  r7 = _nt_variety_name
                  s0 << r7
                end
              end
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(DerivativeTest,input, i0...index, s0)
        r0.extend(NonDerivative0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:non_derivative][start_index] = r0

      r0
    end

    module Inclusion0
      def spacer
        elements[1]
      end

      def variety_name
        elements[2]
      end
    end

    def _nt_inclusion
      start_index = index
      if node_cache[:inclusion].has_key?(index)
        cached = node_cache[:inclusion][index]
        if cached
          node_cache[:inclusion][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?("includes", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"includes"')
        r1 = nil
      end
      s0 << r1
      if r1
        r2 = _nt_spacer
        s0 << r2
        if r2
          r3 = _nt_variety_name
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(InclusionTest,input, i0...index, s0)
        r0.extend(Inclusion0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:inclusion][start_index] = r0

      r0
    end

    module Indicative0
      def spacer
        elements[0]
      end

      def mode
        elements[1]
      end
    end

    module Indicative1
      def indicator_filter
        elements[1]
      end

      def spacer1
        elements[2]
      end

      def spacer2
        elements[4]
      end

      def indicator_name
        elements[5]
      end
    end

    def _nt_indicative
      start_index = index
      if node_cache[:indicative].has_key?(index)
        cached = node_cache[:indicative][index]
        if cached
          node_cache[:indicative][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?("has", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"has"')
        r1 = nil
      end
      s0 << r1
      if r1
        i3, s3 = index, []
        r4 = _nt_spacer
        s3 << r4
        if r4
          i5 = index
          if (match_len = has_terminal?("frozen", false, index))
            r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
            @index += match_len
          else
            terminal_parse_failure('"frozen"')
            r6 = nil
          end
          if r6
            r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
            r5 = r6
          else
            if (match_len = has_terminal?("variable", false, index))
              r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
              @index += match_len
            else
              terminal_parse_failure('"variable"')
              r7 = nil
            end
            if r7
              r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
              r5 = r7
            else
              @index = i5
              r5 = nil
            end
          end
          s3 << r5
        end
        if s3.last
          r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
          r3.extend(Indicative0)
        else
          @index = i3
          r3 = nil
        end
        if r3
          r2 = r3
        else
          r2 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r2
        if r2
          r8 = _nt_spacer
          s0 << r8
          if r8
            if (match_len = has_terminal?("indicator", false, index))
              r9 = instantiate_node(SyntaxNode,input, index...(index + match_len))
              @index += match_len
            else
              terminal_parse_failure('"indicator"')
              r9 = nil
            end
            s0 << r9
            if r9
              r10 = _nt_spacer
              s0 << r10
              if r10
                r11 = _nt_indicator_name
                s0 << r11
              end
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(IndicatorTest,input, i0...index, s0)
        r0.extend(Indicative1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:indicative][start_index] = r0

      r0
    end

    module Abilitive0
      def spacer
        elements[1]
      end

      def ability
        elements[2]
      end
    end

    def _nt_abilitive
      start_index = index
      if node_cache[:abilitive].has_key?(index)
        cached = node_cache[:abilitive][index]
        if cached
          node_cache[:abilitive][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?("can", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"can"')
        r1 = nil
      end
      s0 << r1
      if r1
        r2 = _nt_spacer
        s0 << r2
        if r2
          r3 = _nt_ability
          s0 << r3
        end
      end
      if s0.last
        r0 = instantiate_node(AbilityTest,input, i0...index, s0)
        r0.extend(Abilitive0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:abilitive][start_index] = r0

      r0
    end

    module Ability0
      def parameter
        elements[3]
      end
    end

    module Ability1
      def first_parameter
        elements[0]
      end

      def other_parameters
        elements[1]
      end
    end

    module Ability2
      def parameters
        elements[2]
      end
    end

    module Ability3
      def ability_name
        elements[0]
      end

      def ability_parameters
        elements[1]
      end
    end

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

      i0, s0 = index, []
      r1 = _nt_ability_name
      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
          r6 = _nt_space
          if r6
            r5 = r6
          else
            r5 = instantiate_node(SyntaxNode,input, index...index)
          end
          s3 << r5
          if r5
            i8, s8 = index, []
            r9 = _nt_ability_argument
            s8 << r9
            if r9
              s10, i10 = [], index
              loop do
                i11, s11 = index, []
                r13 = _nt_space
                if r13
                  r12 = r13
                else
                  r12 = instantiate_node(SyntaxNode,input, index...index)
                end
                s11 << r12
                if r12
                  if (match_len = has_terminal?(",", false, index))
                    r14 = true
                    @index += match_len
                  else
                    terminal_parse_failure('","')
                    r14 = nil
                  end
                  s11 << r14
                  if r14
                    r16 = _nt_space
                    if r16
                      r15 = r16
                    else
                      r15 = instantiate_node(SyntaxNode,input, index...index)
                    end
                    s11 << r15
                    if r15
                      r17 = _nt_ability_argument
                      s11 << r17
                    end
                  end
                end
                if s11.last
                  r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
                  r11.extend(Ability0)
                else
                  @index = i11
                  r11 = nil
                end
                if r11
                  s10 << r11
                else
                  break
                end
              end
              r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
              s8 << r10
            end
            if s8.last
              r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
              r8.extend(Ability1)
            else
              @index = i8
              r8 = nil
            end
            if r8
              r7 = r8
            else
              r7 = instantiate_node(SyntaxNode,input, index...index)
            end
            s3 << r7
            if r7
              r19 = _nt_space
              if r19
                r18 = r19
              else
                r18 = instantiate_node(SyntaxNode,input, index...index)
              end
              s3 << r18
              if r18
                if (match_len = has_terminal?(")", false, index))
                  r20 = true
                  @index += match_len
                else
                  terminal_parse_failure('")"')
                  r20 = nil
                end
                s3 << r20
              end
            end
          end
        end
        if s3.last
          r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
          r3.extend(Ability2)
        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(Ability3)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:ability][start_index] = r0

      r0
    end

    module AbilitiesList0
      def ability
        elements[3]
      end
    end

    module AbilitiesList1
      def first_ability
        elements[0]
      end

      def other_abilities
        elements[1]
      end
    end

    module AbilitiesList2
      def list
        elements[0]
      end
    end

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

      i0, s0 = index, []
      i2, s2 = index, []
      r3 = _nt_ability
      s2 << r3
      if r3
        s4, i4 = [], index
        loop do
          i5, s5 = index, []
          r7 = _nt_space
          if r7
            r6 = r7
          else
            r6 = instantiate_node(SyntaxNode,input, index...index)
          end
          s5 << r6
          if r6
            if (match_len = has_terminal?(",", false, index))
              r8 = true
              @index += match_len
            else
              terminal_parse_failure('","')
              r8 = nil
            end
            s5 << r8
            if r8
              r10 = _nt_space
              if r10
                r9 = r10
              else
                r9 = instantiate_node(SyntaxNode,input, index...index)
              end
              s5 << r9
              if r9
                r11 = _nt_ability
                s5 << r11
              end
            end
          end
          if s5.last
            r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
            r5.extend(AbilitiesList0)
          else
            @index = i5
            r5 = nil
          end
          if r5
            s4 << r5
          else
            break
          end
        end
        r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
        s2 << r4
      end
      if s2.last
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        r2.extend(AbilitiesList1)
      else
        @index = i2
        r2 = nil
      end
      if r2
        r1 = r2
      else
        r1 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r1
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(AbilitiesList2)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:abilities_list][start_index] = r0

      r0
    end

    module AbilityParameters0
      def parameter
        elements[3]
      end
    end

    module AbilityParameters1
      def first_parameter
        elements[0]
      end

      def other_parameters
        elements[1]
      end
    end

    module AbilityParameters2
      def parameters
        elements[2]
      end
    end

    def _nt_ability_parameters
      start_index = index
      if node_cache[:ability_parameters].has_key?(index)
        cached = node_cache[:ability_parameters][index]
        if cached
          node_cache[:ability_parameters][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
        r3 = _nt_space
        if r3
          r2 = r3
        else
          r2 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r2
        if r2
          i5, s5 = index, []
          r6 = _nt_ability_argument
          s5 << r6
          if r6
            s7, i7 = [], index
            loop do
              i8, s8 = index, []
              r10 = _nt_space
              if r10
                r9 = r10
              else
                r9 = instantiate_node(SyntaxNode,input, index...index)
              end
              s8 << r9
              if r9
                if (match_len = has_terminal?(",", false, index))
                  r11 = true
                  @index += match_len
                else
                  terminal_parse_failure('","')
                  r11 = nil
                end
                s8 << r11
                if r11
                  r13 = _nt_space
                  if r13
                    r12 = r13
                  else
                    r12 = instantiate_node(SyntaxNode,input, index...index)
                  end
                  s8 << r12
                  if r12
                    r14 = _nt_ability_argument
                    s8 << r14
                  end
                end
              end
              if s8.last
                r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
                r8.extend(AbilityParameters0)
              else
                @index = i8
                r8 = nil
              end
              if r8
                s7 << r8
              else
                break
              end
            end
            r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
            s5 << r7
          end
          if s5.last
            r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
            r5.extend(AbilityParameters1)
          else
            @index = i5
            r5 = nil
          end
          if r5
            r4 = r5
          else
            r4 = instantiate_node(SyntaxNode,input, index...index)
          end
          s0 << r4
          if r4
            r16 = _nt_space
            if r16
              r15 = r16
            else
              r15 = instantiate_node(SyntaxNode,input, index...index)
            end
            s0 << r15
            if r15
              if (match_len = has_terminal?(")", false, index))
                r17 = true
                @index += match_len
              else
                terminal_parse_failure('")"')
                r17 = nil
              end
              s0 << r17
            end
          end
        end
      end
      if s0.last
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
        r0.extend(AbilityParameters2)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:ability_parameters][start_index] = r0

      r0
    end

    module AbilityName0
    end

    module AbilityName1
    end

    def _nt_ability_name
      start_index = index
      if node_cache[:ability_name].has_key?(index)
        cached = node_cache[:ability_name][index]
        if cached
          node_cache[:ability_name][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[a-z]'] ||= Regexp.new(gr), :regexp, index)
        r1 = true
        @index += 1
      else
        terminal_parse_failure('[a-z]')
        r1 = nil
      end
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
            r3 = true
            @index += 1
          else
            terminal_parse_failure('[a-z0-9]')
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
        if r2
          s4, i4 = [], index
          loop do
            i5, s5 = index, []
            if (match_len = has_terminal?("_", false, index))
              r6 = true
              @index += match_len
            else
              terminal_parse_failure('"_"')
              r6 = nil
            end
            s5 << r6
            if r6
              s7, i7 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
                  r8 = true
                  @index += 1
                else
                  terminal_parse_failure('[a-z0-9]')
                  r8 = nil
                end
                if r8
                  s7 << r8
                else
                  break
                end
              end
              if s7.empty?
                @index = i7
                r7 = nil
              else
                r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
              end
              s5 << r7
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(AbilityName0)
            else
              @index = i5
              r5 = nil
            end
            if r5
              s4 << r5
            else
              break
            end
          end
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          s0 << r4
        end
      end
      if s0.last
        r0 = instantiate_node(AbilityName,input, i0...index, s0)
        r0.extend(AbilityName1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:ability_name][start_index] = r0

      r0
    end

    module AbilityArgument0
    end

    module AbilityArgument1
    end

    def _nt_ability_argument
      start_index = index
      if node_cache[:ability_argument].has_key?(index)
        cached = node_cache[:ability_argument][index]
        if cached
          node_cache[:ability_argument][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[a-z]'] ||= Regexp.new(gr), :regexp, index)
        r1 = true
        @index += 1
      else
        terminal_parse_failure('[a-z]')
        r1 = nil
      end
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
            r3 = true
            @index += 1
          else
            terminal_parse_failure('[a-z0-9]')
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
        if r2
          s4, i4 = [], index
          loop do
            i5, s5 = index, []
            if (match_len = has_terminal?("_", false, index))
              r6 = true
              @index += match_len
            else
              terminal_parse_failure('"_"')
              r6 = nil
            end
            s5 << r6
            if r6
              s7, i7 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
                  r8 = true
                  @index += 1
                else
                  terminal_parse_failure('[a-z0-9]')
                  r8 = nil
                end
                if r8
                  s7 << r8
                else
                  break
                end
              end
              if s7.empty?
                @index = i7
                r7 = nil
              else
                r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
              end
              s5 << r7
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(AbilityArgument0)
            else
              @index = i5
              r5 = nil
            end
            if r5
              s4 << r5
            else
              break
            end
          end
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          s0 << r4
        end
      end
      if s0.last
        r0 = instantiate_node(AbilityArgument,input, i0...index, s0)
        r0.extend(AbilityArgument1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:ability_argument][start_index] = r0

      r0
    end

    module VarietyName0
    end

    module VarietyName1
    end

    def _nt_variety_name
      start_index = index
      if node_cache[:variety_name].has_key?(index)
        cached = node_cache[:variety_name][index]
        if cached
          node_cache[:variety_name][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[a-z]'] ||= Regexp.new(gr), :regexp, index)
        r1 = true
        @index += 1
      else
        terminal_parse_failure('[a-z]')
        r1 = nil
      end
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
            r3 = true
            @index += 1
          else
            terminal_parse_failure('[a-z0-9]')
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
        if r2
          s4, i4 = [], index
          loop do
            i5, s5 = index, []
            if (match_len = has_terminal?("_", false, index))
              r6 = true
              @index += match_len
            else
              terminal_parse_failure('"_"')
              r6 = nil
            end
            s5 << r6
            if r6
              s7, i7 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
                  r8 = true
                  @index += 1
                else
                  terminal_parse_failure('[a-z0-9]')
                  r8 = nil
                end
                if r8
                  s7 << r8
                else
                  break
                end
              end
              if s7.empty?
                @index = i7
                r7 = nil
              else
                r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
              end
              s5 << r7
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(VarietyName0)
            else
              @index = i5
              r5 = nil
            end
            if r5
              s4 << r5
            else
              break
            end
          end
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          s0 << r4
        end
      end
      if s0.last
        r0 = instantiate_node(VarietyName,input, i0...index, s0)
        r0.extend(VarietyName1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:variety_name][start_index] = r0

      r0
    end

    module IndicatorName0
    end

    module IndicatorName1
    end

    def _nt_indicator_name
      start_index = index
      if node_cache[:indicator_name].has_key?(index)
        cached = node_cache[:indicator_name][index]
        if cached
          node_cache[:indicator_name][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[a-z]'] ||= Regexp.new(gr), :regexp, index)
        r1 = true
        @index += 1
      else
        terminal_parse_failure('[a-z]')
        r1 = nil
      end
      s0 << r1
      if r1
        s2, i2 = [], index
        loop do
          if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
            r3 = true
            @index += 1
          else
            terminal_parse_failure('[a-z0-9]')
            r3 = nil
          end
          if r3
            s2 << r3
          else
            break
          end
        end
        r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
        s0 << r2
        if r2
          s4, i4 = [], index
          loop do
            i5, s5 = index, []
            if (match_len = has_terminal?("_", false, index))
              r6 = true
              @index += match_len
            else
              terminal_parse_failure('"_"')
              r6 = nil
            end
            s5 << r6
            if r6
              s7, i7 = [], index
              loop do
                if has_terminal?(@regexps[gr = '\A[a-z0-9]'] ||= Regexp.new(gr), :regexp, index)
                  r8 = true
                  @index += 1
                else
                  terminal_parse_failure('[a-z0-9]')
                  r8 = nil
                end
                if r8
                  s7 << r8
                else
                  break
                end
              end
              if s7.empty?
                @index = i7
                r7 = nil
              else
                r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
              end
              s5 << r7
            end
            if s5.last
              r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
              r5.extend(IndicatorName0)
            else
              @index = i5
              r5 = nil
            end
            if r5
              s4 << r5
            else
              break
            end
          end
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          s0 << r4
        end
      end
      if s0.last
        r0 = instantiate_node(VarietyName,input, i0...index, s0)
        r0.extend(IndicatorName1)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:indicator_name][start_index] = r0

      r0
    end

    module Negative0
      def negated_test
        elements[1]
      end
    end

    def _nt_negative
      start_index = index
      if node_cache[:negative].has_key?(index)
        cached = node_cache[:negative][index]
        if cached
          node_cache[:negative][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?("not", false, index))
        r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"not"')
        r1 = nil
      end
      s0 << r1
      if r1
        r2 = _nt_negated_test
        s0 << r2
      end
      if s0.last
        r0 = instantiate_node(NegativeTest,input, i0...index, s0)
        r0.extend(Negative0)
      else
        @index = i0
        r0 = nil
      end

      node_cache[:negative][start_index] = r0

      r0
    end

    module NegatedTest0
      def spacer
        elements[0]
      end

      def ability
        elements[1]
      end
    end

    module NegatedTest1
      def spacer
        elements[0]
      end

      def essence
        elements[1]
      end
    end

    module NegatedTest2
      def spacer
        elements[0]
      end

      def derivative
        elements[1]
      end
    end

    module NegatedTest3
      def boolean_expression
        elements[1]
      end
    end

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

      i0 = index
      i1, s1 = index, []
      r2 = _nt_spacer
      s1 << r2
      if r2
        r3 = _nt_ability
        s1 << r3
      end
      if s1.last
        r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
        r1.extend(NegatedTest0)
      else
        @index = i1
        r1 = nil
      end
      if r1
        r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
        r0 = r1
      else
        i4, s4 = index, []
        r5 = _nt_spacer
        s4 << r5
        if r5
          r6 = _nt_essence
          s4 << r6
        end
        if s4.last
          r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
          r4.extend(NegatedTest1)
        else
          @index = i4
          r4 = nil
        end
        if r4
          r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
          r0 = r4
        else
          i7, s7 = index, []
          r8 = _nt_spacer
          s7 << r8
          if r8
            r9 = _nt_derivative
            s7 << r9
          end
          if s7.last
            r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
            r7.extend(NegatedTest2)
          else
            @index = i7
            r7 = nil
          end
          if r7
            r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
            r0 = r7
          else
            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_boolean_expression
              s10 << r12
              if r12
                if (match_len = has_terminal?(")", false, index))
                  r13 = true
                  @index += match_len
                else
                  terminal_parse_failure('")"')
                  r13 = nil
                end
                s10 << r13
              end
            end
            if s10.last
              r10 = instantiate_node(BooleanExpression,input, i10...index, s10)
              r10.extend(NegatedTest3)
            else
              @index = i10
              r10 = nil
            end
            if r10
              r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
              r0 = r10
            else
              @index = i0
              r0 = nil
            end
          end
        end
      end

      node_cache[:negated_test][start_index] = r0

      r0
    end

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

      s0, i0 = [], index
      loop do
        if (match_len = has_terminal?(" ", false, index))
          r1 = true
          @index += match_len
        else
          terminal_parse_failure('" "')
          r1 = nil
        end
        if r1
          s0 << r1
        else
          break
        end
      end
      if s0.empty?
        @index = i0
        r0 = nil
      else
        r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
      end

      node_cache[:spacer][start_index] = r0

      r0
    end

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

      s0, i0 = [], index
      loop do
        if has_terminal?(@regexps[gr = '\A[\\s\\n]'] ||= Regexp.new(gr), :regexp, index)
          r1 = true
          @index += 1
        else
          terminal_parse_failure('[\\s\\n]')
          r1 = nil
        end
        if r1
          s0 << r1
        else
          break
        end
      end
      r0 = instantiate_node(SyntaxNode,input, i0...index, s0)

      node_cache[:space][start_index] = r0

      r0
    end
  end

  class QueryLanguageParser < Treetop::Runtime::CompiledParser
    include QueryLanguage
  end
end
