Sha256: 972a312b0e3b8ef42297a8397edd796acc035e92801efa60e1e153d90b73c28a

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

module Treetop
  class Protometagrammar
    class SequenceExpressionBuilder < ParsingExpressionBuilder
      def build
        choice(sequence_with_block, :primary)
      end
    
      def sequence_with_block
        seq(sequence, :trailing_block) do
          def value(grammar)
            trailing_block.value(sequence.value(grammar))
          end
        
          def sequence
            elements[0]
          end
        
          def trailing_block
            elements[1]
          end
        end
      end
    
      def sequence
        two_or_more_delimited(:primary, :space) do
          def value(grammar)
            Sequence.new(element_values(grammar))
          end
        
          def element_values(grammar)
            elements.collect { |element| element.value(grammar) }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
treetop-0.1.0 lib/treetop/protometagrammar/sequence_expression_builder.rb