Sha256: f14dfa00d0d8210ffce29caeb93b84b9b34c9b8e79427c27823ab34c779f341f

Contents?: true

Size: 897 Bytes

Versions: 349

Compression:

Stored size: 897 Bytes

Contents

module Treetop
  module Compiler
    class Choice < ParsingExpression
      def compile(address, builder, parent_expression = nil)
        super
        begin_comment(self)
        use_vars :result, :start_index
        compile_alternatives(alternatives)
        end_comment(self)
      end
      
      def compile_alternatives(alternatives)
        obtain_new_subexpression_address
        alternatives.first.compile(subexpression_address, builder)
        builder.if__ subexpression_success? do
          assign_result subexpression_result_var
          extend_result_with_declared_module
          extend_result_with_inline_module
        end
        builder.else_ do
          if alternatives.size == 1
            reset_index
            assign_failure start_index_var
          else
            compile_alternatives(alternatives[1..-1])
          end
        end
      end
    end
  end
end

Version data entries

349 entries across 304 versions & 42 rubygems

Version Path
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-csharp-0.1.0 vendor/bundle/jruby/2.3.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-htmlentities-0.1.0 vendor/bundle/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-output-icinga-1.0.0 vendor/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-input-fifo-0.9.1 vendor/bundle/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-input-fifo-0.9.0 vendor/bundle/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
ivanvc-logstash-input-s3-3.1.1.2 vendor/local/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-delta-1.1.0 vendor/bundle/jruby/2.2.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-delta-1.0.1 vendor/bundle/jruby/2.2.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-base64-1.0.4 vendor/bundle/jruby/2.2.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-base64-1.0.3 vendor/bundle/jruby/2.2.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-delta-1.0.0 vendor/bundle/jruby/2.2.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-base64-1.0.2 vendor/bundle/jruby/2.3.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-base64-1.0.1 vendor/bundle/jruby/2.3.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb
logstash-filter-base64-1.0.0 vendor/bundle/jruby/2.3.0/gems/treetop-1.4.15/lib/treetop/compiler/node_classes/choice.rb