Dmn.Compiler.Tree (dmn v0.1.0)

Copy Markdown View Source

The nodes of Feel.AST that the compiler builds, so that the code that maps a boxed expression says what it maps to and not how a tuple is made.

Every node is given a span, the zero-width one of the part of the model it stands for (Dmn.Compiler.Source.glue/2). A name is a list of tokens (Feel.AST), and the tokens of a name of the model are made here (tokens/1) so that they join to the canonical name that the scope of the unit has.

Summary

Functions

source[index], a filter that the analyzer finds to be an index when it is a number.

The node as the node of a boxed expression whose condition has to be a boolean (DMN 1.6, 10.2.1.8 to 10.2.1.10): an if, a filter, a some or an every that is null with an error for a condition that is a value other than a boolean (meta.boxed, Feel.Runtime.Boxed, D-212). null is taken as false, as it is in the text.

A call of a function by name, with its arguments by position.

The canonical form of a name of the model: what the scope of a unit and the keys of a context call it.

A context with the entries {name, expression}, in order. The keys are strings, so any name of a model can be one.

A name that the compiler makes for itself (the key of the result of a context, an alias of an outside value): it begins with U+0001, a character that XML 1.0 does not allow in a document, so no name, id or text of a model can be, or begin with, one, and no text of FEEL can write it (the lexer does not read it as a part of a name).

The value of one entry of a context: source.key.

The tokens of a name, as the lexer of FEEL would split it: the words, and each of the symbols that a name may have as a token of its own. Feel.Name.join/1 of them is the canonical form of the name.

A type by its name: a built-in type or the name of an item definition of the model.

Types

span()

@type span() :: Feel.Diagnostic.span()

Functions

at(span, source, index)

source[index], a filter that the analyzer finds to be an index when it is a number.

boxed(node)

The node as the node of a boxed expression whose condition has to be a boolean (DMN 1.6, 10.2.1.8 to 10.2.1.10): an if, a filter, a some or an every that is null with an error for a condition that is a value other than a boolean (meta.boxed, Feel.Runtime.Boxed, D-212). null is taken as false, as it is in the text.

iex> node = Dmn.Compiler.Tree.if_then_else({0, 0}, Dmn.Compiler.Tree.null({0, 0}), Dmn.Compiler.Tree.null({0, 0}), Dmn.Compiler.Tree.null({0, 0}))
iex> {:if, %{boxed: true}, _, _, _} = Dmn.Compiler.Tree.boxed(node)

call(span, function, arguments)

A call of a function by name, with its arguments by position.

canonical(name)

@spec canonical(String.t()) :: String.t()

The canonical form of a name of the model: what the scope of a unit and the keys of a context call it.

context(span, entries)

@spec context(span(), [{String.t(), Feel.AST.expression()}]) :: Feel.AST.expression()

A context with the entries {name, expression}, in order. The keys are strings, so any name of a model can be one.

for_in(span, variable, domain, body)

function(span, parameters, body)

@spec function(
  span(),
  [{String.t(), Feel.AST.type_expression() | nil}],
  Feel.AST.expression()
) ::
  Feel.AST.expression()

if_then_else(span, condition, then, otherwise)

internal(label)

@spec internal(String.t()) :: String.t()

A name that the compiler makes for itself (the key of the result of a context, an alias of an outside value): it begins with U+0001, a character that XML 1.0 does not allow in a document, so no name, id or text of a model can be, or begin with, one, and no text of FEEL can write it (the lexer does not read it as a part of a name).

iex> Dmn.Compiler.Tree.internal("result")
"result"

list(span, items)

@spec list(span(), [Feel.AST.expression()]) :: Feel.AST.expression()

meta(span)

@spec meta(span()) :: map()

name(span, name)

@spec name(span(), String.t()) :: Feel.AST.expression()

null(span)

@spec null(span()) :: Feel.AST.expression()

quantified(span, kind, variable, domain, test)

@spec quantified(
  span(),
  :some | :every,
  String.t(),
  Feel.AST.expression(),
  Feel.AST.expression()
) :: Feel.AST.expression()

select(span, source, key)

The value of one entry of a context: source.key.

tokens(name)

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

The tokens of a name, as the lexer of FEEL would split it: the words, and each of the symbols that a name may have as a token of its own. Feel.Name.join/1 of them is the canonical form of the name.

iex> Dmn.Compiler.Tree.tokens("Pre-bureau Risk Category")
["Pre", "-", "bureau", "Risk", "Category"]
iex> Feel.Name.join(Dmn.Compiler.Tree.tokens("a  b - c.d"))
"a b-c.d"

type_name(span, name)

@spec type_name(span(), String.t()) :: Feel.AST.type_expression()

A type by its name: a built-in type or the name of an item definition of the model.