class Treetop::Compiler::OccurrenceRange

Public Instance Methods

compile(address, builder, parent_expression) click to toggle source
Calls superclass method Treetop::Compiler::Repetition#compile
# File lib/treetop/compiler/node_classes/repetition.rb, line 69
def compile(address, builder, parent_expression)
  super

  if min.empty? || min.text_value.to_i == 0
    assign_and_extend_result
  else
    # We got some, but fewer than we wanted. There'll be a failure reported already
    builder.if__ "#{accumulator_var}.size < #{min.text_value}" do
      reset_index
      assign_failure start_index_var
    end
    builder.else_ do
      assign_and_extend_result
    end
  end
  end_comment(parent_expression)
end