Dmn.Compiler.Env (dmn v0.1.0)

Copy Markdown View Source

What the compiler knows while it builds the syntax tree of one unit: the model, the types of its item definitions, and the names that are in scope where it is.

scope is the Feel.Scope of the unit, the names it may read from outside with their declared types: the input data and decisions it requires, the functions it invokes. parse_scope is that and the names that the boxed expressions around the fragment bind (the entries of a context, the parameters of a function, the variable of a loop), which is what the parser of FEEL needs to read a name of several words (Feel.parse/2). The analyzer finds the second kind itself, from the tree.

Summary

Functions

The environment inside an expression that binds names: they are names for the parser, and are not typed (the analyzer types them from the tree).

The environment of the unit of element, with the scope of its requirements.

Types

t()

@type t() :: %Dmn.Compiler.Env{
  definitions: Feel.ItemDefinitions.t(),
  element: String.t(),
  external: %{optional(atom()) => String.t()},
  function_outputs: %{optional(String.t()) => String.t()},
  index: Feel.Syntax.ScopeIndex.t(),
  language: String.t() | nil,
  limits: Feel.Limits.t() | nil,
  model: Dmn.Model.t(),
  parse_scope: Feel.Scope.t(),
  scope: Feel.Scope.t()
}

Functions

bind(env, names)

@spec bind(t(), [String.t()]) :: t()

The environment inside an expression that binds names: they are names for the parser, and are not typed (the analyzer types them from the tree).

new(model, definitions, scope, element, options \\ [])

The environment of the unit of element, with the scope of its requirements.

Options: :limits, :external (the kinds of external function that the extensions run, Dmn.Extension.external_functions/1), :function_outputs (the type each function item names for its output, Dmn.Compiler.Types.function_outputs/1), and :base_index, the index (Feel.Syntax.ScopeIndex) of a scope that has the types of the scope and no name. The names of a unit are added to it, and the types, which are the size of the item definitions of the model, are not made again for each unit.