_nt_compare_operator

in logstash-core/lib/logstash/config/grammar.rb [3243:3340]


  def _nt_compare_operator
    start_index = index
    if node_cache[:compare_operator].has_key?(index)
      cached = node_cache[:compare_operator][index]
      if cached
        node_cache[:compare_operator][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, index))
      r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
      @index += match_len
    else
      terminal_parse_failure('"=="')
      r1 = nil
    end
    if r1
      r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
      r0 = r1
      r0.extend(LogStash::Config::AST::ComparisonOperator)
    else
      if (match_len = has_terminal?("!=", false, index))
        r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
        @index += match_len
      else
        terminal_parse_failure('"!="')
        r2 = nil
      end
      if r2
        r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
        r0 = r2
        r0.extend(LogStash::Config::AST::ComparisonOperator)
      else
        if (match_len = has_terminal?("<=", false, index))
          r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
          @index += match_len
        else
          terminal_parse_failure('"<="')
          r3 = nil
        end
        if r3
          r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
          r0 = r3
          r0.extend(LogStash::Config::AST::ComparisonOperator)
        else
          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
          if r4
            r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
            r0 = r4
            r0.extend(LogStash::Config::AST::ComparisonOperator)
          else
            if (match_len = has_terminal?("<", false, index))
              r5 = true
              @index += match_len
            else
              terminal_parse_failure('"<"')
              r5 = nil
            end
            if r5
              r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
              r0 = r5
              r0.extend(LogStash::Config::AST::ComparisonOperator)
            else
              if (match_len = has_terminal?(">", false, index))
                r6 = true
                @index += match_len
              else
                terminal_parse_failure('">"')
                r6 = nil
              end
              if r6
                r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
                r0 = r6
                r0.extend(LogStash::Config::AST::ComparisonOperator)
              else
                @index = i0
                r0 = nil
              end
            end
          end
        end
      end
    end

    node_cache[:compare_operator][start_index] = r0

    r0
  end