Sha256: 1c1336a2041af77967b5e3cd431f74d8b75d0867eee29bed4e3dfe76f1fe8d19

Contents?: true

Size: 599 Bytes

Versions: 2

Compression:

Stored size: 599 Bytes

Contents

module Treetop
  module Compiler    
    class CharacterClass < AtomicExpression
      def compile(address, builder, parent_expression = nil)
        super
        
        builder.if__ "input.index(Regexp.new(#{single_quote(text_value)}), index) == index" do
          assign_result "instantiate_node(#{node_class_name},input, index...(index + 1))"
          extend_result_with_inline_module
          builder << "@index += 1"
        end
        builder.else_ do
          "terminal_parse_failure(#{single_quote(characters)})"
          assign_result 'nil'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
treetop-1.2.5 lib/treetop/compiler/node_classes/character_class.rb
treetop-1.2.6 lib/treetop/compiler/node_classes/character_class.rb