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/any_type.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/any_type.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/inline_pair.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/external_pair.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, AnyType, Attribute, BuiltinType, DressHelper, Error, Heading, RelationType, SeqType, SetType, SubType, System, TupleType, Type, TypeError, TypeFactory, UnionType

Constant Summary collapse

DSL_METHODS =
[
  :attribute,
  :heading,
  :constraints,
  :any,
  :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

#ast(source) ⇒ Object



47
48
49
50
# File 'lib/qrb.rb', line 47

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

#definition_files(of) ⇒ Object



61
62
63
64
# File 'lib/qrb.rb', line 61

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

#parse(source) ⇒ Object



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

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

#system(identifier) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/qrb.rb', line 52

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