# class Treetop::Compiler::Repetition

### Public Instance Methods

assign_and_extend_result() click to toggle source

    # File lib/treetop/compiler/node_classes/repetition.rb, line 31
    def assign_and_extend_result
      assign_result "instantiate_node(#{node_class_name},input, #{start_index_var}...index, #{accumulator_var})"
      extend_result_with_inline_module
    end

compile(address, builder, parent_expression) click to toggle source
Calls superclass method Treetop::Compiler::ParsingExpression#compile

    # File lib/treetop/compiler/node_classes/repetition.rb, line 4
    def compile(address, builder, parent_expression)
      super
      repeated_expression = parent_expression.atomic
      begin_comment(parent_expression)
      use_vars :result, :accumulator, :start_index

      builder.loop do
        obtain_new_subexpression_address
        repeated_expression.compile(subexpression_address, builder)
        builder.if__ subexpression_success? do
          accumulate_subexpression_result
        end
        builder.else_ do
          builder.break
        end
        if max && !max.empty?
          builder.if_ "#{accumulator_var}.size == #{max.text_value}" do
            builder.break
          end
        end
      end
    end

inline_module_name() click to toggle source

    # File lib/treetop/compiler/node_classes/repetition.rb, line 27
    def inline_module_name
      parent_expression.inline_module_name
    end