Sha256: 4458b1aaf8172b9c02e565422f8947ccf6566a1125e9d3d8e38978546d51480e

Contents?: true

Size: 537 Bytes

Versions: 1

Compression:

Stored size: 537 Bytes

Contents

module Qrb
  module Syntax
    module Constraints

      def compile(var_name)
        constraints = {}
        captures[:named_constraint].each do |node|
          compiled = node.compile(var_name)
          constraints.merge!(compiled) do |k,_,_|
            raise Error, "Duplicate constraint name `#{k}`"
          end
        end
        constraints
      end

      def to_ast(var_name)
        captures[:named_constraint].map{|c| c.to_ast(var_name) }
      end

    end # module Constraints
  end # module Syntax
end # module Qrb

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qrb-0.3.0 lib/qrb/syntax/constraints.rb