Sha256: 614beecf42161e70af1d219cb00f2e53d222be1dc02002999ceb1e39a0a06e01

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'citrus'
require_relative 'syntax/support'
require_relative 'syntax/system'
require_relative 'syntax/definitions'
require_relative 'syntax/type_def'
require_relative 'syntax/expression'
require_relative 'syntax/attribute'
require_relative 'syntax/heading'
require_relative 'syntax/any_type'
require_relative 'syntax/builtin_type'
require_relative 'syntax/sub_type'
require_relative 'syntax/constraint_def'
require_relative 'syntax/constraints'
require_relative 'syntax/named_constraint'
require_relative 'syntax/unnamed_constraint'
require_relative 'syntax/seq_type'
require_relative 'syntax/set_type'
require_relative 'syntax/tuple_type'
require_relative 'syntax/relation_type'
require_relative 'syntax/union_type'
require_relative 'syntax/type_ref'
require_relative 'syntax/ad_type'
require_relative 'syntax/contract'
require_relative 'syntax/inline_pair'
require_relative 'syntax/external_pair'
require_relative 'syntax/lambda_expr'
module Finitio
  module Syntax

    Citrus.load File.expand_path('../syntax/finitio.citrus', __FILE__)

    def self.parse(source, *args, &bl)
      source = File.read(source) if source.respond_to?(:to_path)
      Parser.parse(source, *args, &bl)
    end

    def self.ast(source)
      parse(source, root: "system").to_ast
    end

    def self.compile(source, system = Finitio::System.new)
      parse(source, root: "system").compile(system)
    end

    def self.compile_type(source)
      parse(source, root: "type").compile(TypeFactory.new)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 lib/finitio/syntax.rb
finitio-0.4.0 lib/finitio/syntax.rb