wiki:Doc/panc/statements

Version 5 (modified by /C=FR/O=CNRS/OU=UMR8607/CN=Michel Jouvin/emailAddress=jouvin@…, 17 years ago) (diff)

--

Statements

Table of Contents

  1. include
  2. assignment

include

The include statement acts as if the contents of the named template were included literally at the point the include statement is executed. Two variants of the include statement are permitted:

include template-name;
include {dml};

The first variant includes the named template; the template is written as a token without quotes. The second variant executes the given DML block. The block must evaluate to a string, undef, or null. If the result is undef or null, the include statement does nothing; if the result is a string, the named template is loaded and executed. Any other type will generate an error. The braces in the second variant are required.

Ordinary templates may be included multiple times, but loops are not permitted. Templates marked as 'declaration' or 'unique' templates will be only included once where first encountered.

There are some restrictions on what types of templates can be included. Object templates cannot be included. Structure templates can only include and be included by other structure templates. Declaration templates can only include other declaration templates. All other situations are allowed.

assignment

Assignment statements are used to modify a part of the configuration tree by replacing the subtree identified by its path by the result of the execution a DML block. This result can be a single property or a resource holding any number of elements. There are conditional and unconditional assignments:

[ final ] path ?= dml;
[ final ] path = dml;

where the path is represented by a string literal. Single-quoted strings are slightly more efficient, but double-quoted strings work as well. The conditional form (?=) will only execute the DML block and assign a value if the named path does not exist or contains the undef value.

The assignment will create parents of the value that do not already exist.

If a value already exists, the pan compiler will verify that the new value has a compatible type. If not, it will terminate the processing with an error.