Sha256: 094465744b576fe67d4019809b6d6e4ce150811dac74c9e44ac7bf50c792b12e

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require 'citrus'
require_relative 'syntax/node'
require_relative 'syntax/literal'
require_relative 'syntax/expr'
require_relative 'syntax/type'
require_relative 'syntax/import'
require_relative 'syntax/imports'
require_relative 'syntax/definitions'
require_relative 'syntax/system'
module Finitio
  module Syntax

    Citrus.load File.expand_path('../syntax/lexer.citrus', __FILE__)
    Citrus.load File.expand_path('../syntax/literals.citrus', __FILE__)
    Citrus.load File.expand_path('../syntax/expressions.citrus', __FILE__)
    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, cpl = nil)
      cpl = Compilation.coerce(cpl, source)
      parse(source, root: 'system').compile(cpl)
      ProxyResolver.new.resolve!(cpl.system)
    end

    def self.compile_type(source, cpl = nil)
      cpl = Compilation.coerce(cpl, source)
      parse(source, root: 'type').compile(cpl)
    end

  end # module Syntax
end # module Finitio

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.12.0 lib/finitio/syntax.rb
finitio-0.11.4 lib/finitio/syntax.rb