Dmn.Compiler.Expression (dmn v0.1.0)

Copy Markdown View Source

Maps a boxed expression to a syntax tree of FEEL (DMN 1.6, 10.2.2: boxed expressions "can be mapped to FEEL text").

Boxed expressionTree
literal expressionthe parse of its text
contexta context; the entry with no variable is the result, selected from the context under a key that no text can write
function definitionfunction(parameters) body, the parameters typed by their typeRef
invocationa call of the function by the names of its parameters
relationa list of contexts, one for each row
list, conditional, filter[…], if … then … else …, source[match]
for, some, everyfor v in source return body, some v in source satisfies test, every …
decision tableDmn.Compiler.Table

Each fragment of text is parsed where it stands, with the names in scope there: the names of the unit, and those that the boxed expressions around it bind. A part that is missing (an else that is not there, a binding with no formula) is null.

The tree is built as the analyzer wants it, and not as text would be written: a name is its tokens, a key is a string, and the glue has the zero-width span of its part of the model (Dmn.Compiler.Source).

Summary

Functions

The tree of an expression, with the state, at path in the element of the environment. nil is null.

The tree of a value that the model declares a type for (Feel.AST, "Declared values"): converted to the type and verified against its allowed values. Unchanged for no type; a type that FEEL cannot read is a diagnostic, and the value is not converted.

The type expression of a typeRef, or nil for no type. A typeRef is read as a type expression (number!, list<Employee>) with the item definitions as the names that exist; every node of it has the span of the element. A text that is not one stays a type name, which FEEL then says is unknown.

Functions

compile(expression, env, state, path)

The tree of an expression, with the state, at path in the element of the environment. nil is null.

declared(tree, type_ref, env, state, path)

The tree of a value that the model declares a type for (Feel.AST, "Declared values"): converted to the type and verified against its allowed values. Unchanged for no type; a type that FEEL cannot read is a diagnostic, and the value is not converted.

type_expression(span, type_ref, definitions)

@spec type_expression(
  Feel.Diagnostic.span(),
  String.t() | nil,
  Feel.ItemDefinitions.t()
) ::
  Feel.AST.type_expression() | nil

The type expression of a typeRef, or nil for no type. A typeRef is read as a type expression (number!, list<Employee>) with the item definitions as the names that exist; every node of it has the span of the element. A text that is not one stays a type name, which FEEL then says is unknown.