Dmn.Compiler.Table (dmn v0.1.0)

Copy Markdown View Source

Maps a decision table to its node of FEEL's syntax tree (DMN 1.6, clause 8; Feel.AST, "Decision tables").

The node is the table as the model has it: the hit policy and the aggregation, the input expressions with the input values of their columns, the rules with an entry for each input and an output for each output, and for each output its name, its output values and its default. What the entries and outputs say is FEEL, parsed as the text it is. The rest is Feel.Runtime.DecisionTable (what a hit policy is) and the analyzer (the type of a table, and what is wrong with its entries), which are FEEL's own, so a table is typed, optimized and run on both backends as an expression is.

Of the modelIn the node
hitPolicy, aggregationthe policy :unique … :collect, and :sum, :count, :min, :max or nil
an input clause{expression, input_values}; the input values are unary tests
a rule{id, entries, results}; an entry is unary tests, or nil for - and for no text
an output clause{name, order, default}; the name is nil for a table of one output; the order is the output values read as a list

A text that cannot be read is a diagnostic of the table, and: for an expression null, for an input entry tests that nothing satisfies (a rule with an entry that cannot be read never matches), for input values and output values none.

What an output clause declares. The typeRef of an output clause is the type of what the column gives, and its output values are the values it may give (DMN 1.6, 8.2). Each output entry of a rule, and the default output entry, is a declared value of the column ({:declared, …}, Feel.AST): converted to the type, held to all the constraints of the type (Dmn.Compiler.Types), and to the output values, and null with an error when it is not. It is the entries that are held to them, and not what the table makes of them: a COLLECT aggregation (a sum, say) is not one of the output values. For the policies PRIORITY and OUTPUT ORDER the output values say the order (the third element of the output in the node), which Feel.Runtime.DecisionTable also holds the outputs of the rules to, so they are not a constraint of those entries too. The default output entry is not a rule's output and is not in that order, so the run does not look at it, and it is held to the output values for every policy: it is one of them (DMN 1.6, 8.2.12, where it is underlined in the list of output values). A type that FEEL cannot read is an error of the table, and the column is not converted.

Summary

Functions

The node for a decision table, with the state, at path in the element of the environment.

Functions

compile(table, env, state, path)

The node for a decision table, with the state, at path in the element of the environment.