Sha256: c2fcd0993c74a12bf4041ec45c24967ac63ebe75cbd670d90f60cc34932fb912

Contents?: true

Size: 642 Bytes

Versions: 185

Compression:

Stored size: 642 Bytes

Contents

module Treetop
  module Compiler    
    class Terminal < AtomicExpression
      def compile(address, builder, parent_expression = nil)
        super
        string_length = eval(text_value).length
        
        builder.if__ "has_terminal?(#{text_value}, false, index)" do
          assign_result "instantiate_node(#{node_class_name},input, index...(index + #{string_length}))"
          extend_result_with_inline_module
          builder << "@index += #{string_length}"
        end
        builder.else_ do
          builder << "terminal_parse_failure(#{text_value})"
          assign_result 'nil'
        end
      end
    end
  end
end

Version data entries

185 entries across 170 versions & 29 rubygems

Version Path
challah-0.3.1 vendor/bundle/gems/treetop-1.4.10/lib/treetop/compiler/node_classes/terminal.rb
challah-0.3.0 vendor/bundle/gems/treetop-1.4.10/lib/treetop/compiler/node_classes/terminal.rb
challah-0.2.1 vendor/bundle/gems/treetop-1.4.10/lib/treetop/compiler/node_classes/terminal.rb
challah-0.2.0 vendor/bundle/gems/treetop-1.4.10/lib/treetop/compiler/node_classes/terminal.rb
treetop-1.4.10 lib/treetop/compiler/node_classes/terminal.rb