Module: Qrb

Extended by:
Qrb
Included in:
Qrb
Defined in:
lib/qrb.rb,
lib/qrb/type.rb,
lib/qrb/errors.rb,
lib/qrb/syntax.rb,
lib/qrb/system.rb,
lib/qrb/version.rb,
lib/qrb/data_type.rb,
lib/qrb/type/ad_type.rb,
lib/qrb/syntax/system.rb,
lib/qrb/type/seq_type.rb,
lib/qrb/type/set_type.rb,
lib/qrb/type/sub_type.rb,
lib/qrb/syntax/ad_type.rb,
lib/qrb/syntax/heading.rb,
lib/qrb/syntax/support.rb,
lib/qrb/support/heading.rb,
lib/qrb/syntax/contract.rb,
lib/qrb/syntax/seq_type.rb,
lib/qrb/syntax/set_type.rb,
lib/qrb/syntax/sub_type.rb,
lib/qrb/syntax/type_def.rb,
lib/qrb/syntax/type_ref.rb,
lib/qrb/type/tuple_type.rb,
lib/qrb/type/union_type.rb,
lib/qrb/syntax/attribute.rb,
lib/qrb/support/attribute.rb,
lib/qrb/syntax/expression.rb,
lib/qrb/syntax/tuple_type.rb,
lib/qrb/syntax/union_type.rb,
lib/qrb/type/builtin_type.rb,
lib/qrb/syntax/constraints.rb,
lib/qrb/syntax/definitions.rb,
lib/qrb/syntax/lambda_expr.rb,
lib/qrb/type/relation_type.rb,
lib/qrb/syntax/builtin_type.rb,
lib/qrb/support/dress_helper.rb,
lib/qrb/support/type_factory.rb,
lib/qrb/syntax/relation_type.rb,
lib/qrb/syntax/constraint_def.rb,
lib/qrb/support/collection_type.rb,
lib/qrb/syntax/named_constraint.rb,
lib/qrb/syntax/unnamed_constraint.rb

Overview

Q - in Ruby

Defined Under Namespace

Modules: CollectionType, DataType, Syntax, Version Classes: AdType, Attribute, BuiltinType, DressHelper, Error, Heading, RelationType, SeqType, SetType, SubType, System, TupleType, Type, TypeError, TypeFactory, UnionType

Constant Summary collapse

DSL_METHODS =
[
  :attribute,
  :heading,
  :constraints,
  :builtin,
  :adt,
  :subtype,
  :union,
  :seq,
  :set,
  :tuple,
  :relation,
  :type
]
DEFAULT_FACTORY =
TypeFactory.new
IDENTITY =
->(object){ object }
DEFAULT_SYSTEM =
system('Q/default')
VERSION =
Version.to_s

Instance Method Summary collapse

Instance Method Details

#definition_files(of) ⇒ Object



55
56
57
58
# File 'lib/qrb.rb', line 55

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

#parse(source) ⇒ Object



41
42
43
44
# File 'lib/qrb.rb', line 41

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

#system(identifier) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/qrb.rb', line 46

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