Anatomy of a Configurator Rule Written in CDL

This topic provides an overview of how the syntax, semantics, and lexical structure of a rule written in CDL relate to one another.

This section contains the following:

  • Rule Definition

  • Rule Statements

  • Data Types

Rule Definition

A configurator rule has a name, associated model, rule text, other attributes such as rule class. The rule definition is written in CDL and consists of one or more individual statements that express the intent of the rule, along with optional comments.

When creating a Statement Rule in the Configurator Models work area, you enter the name and other attributes in input or selection fields and the rule definition in the text box provided for that purpose.

Rule Statements

Statements define the rule's intent, such as to add a value of 10 to Integer Feature X when Option A is selected.

Multiple statements in a rule definition must be separated from one another with semi-colons (;). CDL supports two kinds of statements: Explicit and Iterator.

CDL statements are parsed as tokens. Everything in CDL is a token, except white space characters and comments.

Statements consist of one or more clauses. Clauses consist of keywords and one or more expressions. Keywords are predefined tokens that determine CDL syntax and embody the semantics of the language. CONSTRAIN, COMPATIBLE, REQUIRES, IMPLIES, LIKE, NOT, and others are all examples of keywords.

An expression is the part of a statement that contains an operator and the operands involved in a rule operation. An operator is a predefined keyword, function, or character that involves the operands in logical, functional, or mathematical operations. REQUIRES and the plus sign (+) are examples of operators. An operand can be an expression, a literal, or an identifier. The literal or identifier operand can be present in the rule as a singleton or as a collection. Model nodes that are referred to in a rule are called rule participants.

Literals are tokens of a specific data type, such as Numeric, Boolean (True or False), or Text. The specific values of literals are equivalent to the notion of constants.

An identifier is a token that identifies model objects or formal parameters. When an identifier identifies a model object it, refers to a model node or attribute and the sequence of letters and digits starts with a letter. These kinds of identifiers are called references. When an identifier is a formal parameter, it identifies a local variable and is used in an iterator statement. Formal parameters are prefixed with an ampersand (&).

For greater readability and to convey meaning such as the order of operations, CDL supports separators. Separators are tokens that maintain the structure of the rule by establishing boundaries between tokens, grouping them based on some syntactic criteria. Separators are single characters such as the semi-colon between statements or the parentheses around an expression.

More information about these statements and the CDL elements they contain is described with CDL Statements.

Data Types

Following are valid data types when defining a rule in CDL:

  • INTEGER

  • DECIMAL

  • BOOLEAN

  • TEXT

  • Node types

Under certain circumstances, a data type of a variable isn't compatible with the type expected as an argument. The Configurator parser doesn't support explicit conversion or casting between the data types. The parser performs implicit conversion between compatible types. See the following table for details.

If a rule definition has the wrong data types, the parser returns a type mismatch error message. Invalid Collection shows a collection whose data types can't be implicitly converted to be compatible.

The following table shows which data type each source data type implicitly converts.

Source data type (or collection of the same type)

Implicitly converts to (or collection of the same type)

INTEGER

DECIMAL

NODE of type Standard Item, Option Class, Model, Option Feature, Option, or Boolean Feature

BOOLEAN

INTEGER

DECIMAL

Node type

NODE of type Integer Feature

INTEGER

DECIMAL

NODE of type Decimal Feature

DECIMAL

Unless specified otherwise, all references to matching types assume the implicit data type conversions.

Although TEXT is included as a data type here, it can only be used in a static context. You can't use a TEXT literal, reference, or expression in the actual body of a CONSTRAIN, ADD, or SUBTRACT expression. The Configurator compiler validates this condition when you compile the model.