Sha256: 53c3c32c29a77988b24ca19430b20a6522c9f9c565e691e99b4adc0c618119d3

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'set'
require 'time'

#
# Q - in Ruby
#
module Qrb

  DSL_METHODS = [
    :attribute,
    :heading,
    :constraints,
    :builtin,
    :adt,
    :subtype,
    :union,
    :seq,
    :set,
    :tuple,
    :relation,
    :type
  ]

  require_relative "qrb/version"
  require_relative "qrb/errors"
  require_relative "qrb/support"
  require_relative 'qrb/type'
  require_relative 'qrb/data_type'
  require_relative 'qrb/system'

  DEFAULT_FACTORY = TypeFactory.new

  IDENTITY = ->(object){ object }

  DSL_METHODS.each do |meth|
    define_method(meth) do |*args, &bl|
      DEFAULT_FACTORY.public_send(meth, *args, &bl)
    end
  end

  def parse(source)
    require "qrb/syntax"
    Syntax.compile(source)
  end

  def system(identifier)
    f = File.expand_path("../qrb/#{identifier}.q", __FILE__)
    if File.exists?(f)
      parse(File.read(f))
    else
      raise Error, "Unknown system #{identifier}"
    end
  end

  def definition_files(of)
    dir = File.expand_path("../qrb/#{of}", __FILE__)
    Dir.glob("#{dir}/*.q")
  end

  extend self

  DEFAULT_SYSTEM = system('Q/default')
end # module Qrb

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qrb-0.2.0 lib/qrb.rb
qrb-0.1.0 lib/qrb.rb