Sha256: e1ce73f347ed66fbf39020175c68def1db1dc4d98354c18ee7c7b81c725d2e58

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'set'
require 'time'

#
# Q - in Ruby
#
module Qrb

  DSL_METHODS = [
    :attribute,
    :heading,
    :constraints,
    :any,
    :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 ast(source)
    require "qrb/syntax"
    Syntax.ast(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

1 entries across 1 versions & 1 rubygems

Version Path
qrb-0.3.0 lib/qrb.rb