The CONVECS team is pleased to announce
that version 3.12 of the TRAIAN compiler for LOTOS NT is available.
In October 2023, TRAIAN became part of the CADP toolbox, where it provides a full-fledged compiler front-end for the LNT language, allowing to catch mistakes not detected by the "lightweight" approach of the LNT2LOTOS translator.
With TRAIAN 3.12, the convergence between LOTOS NT and LNT with respect to incorrect LNT programs has progressed, meaning that TRAIAN became stricter in order to be aligned on LNT2LOTOS, and that the error and warning messages emitted by TRAIAN have been enhanced. Also, the C code generated by TRAIAN has improved in many respects.
TRAIAN 3.12 brings eight static-semantics changes, seven compiler changes, sixteen code-generation changes, seven library changes, one release change, and twelve bug fixes (see below their description).
synchronized event E1 not accessed in 1st "par" branch synchronized event E2 not accessed in 4th "par" branchSame as done by LNT2LOTOS to avoid redundant warnings, this warning may supersede more general warnings such as:
hidden event E1 never accessed event parameter E2 never accessedthat would be also applicable, though less informative. See item 571 in the HISTORY.txt file.
event E synchronized in only one "par" branch"See item 573 in the HISTORY.txt file.
superfluous pattern(s) after the 7th patternwere computed during TRAIAN's code-generation phase, and thus not displayed when TRAIAN was invoked (namely, from CADP by the LNT.OPEN shell script) with its "-analysis" option. This issue was addressed by performing the checks earlier, during TRAIAN's pattern-checking phase, so that the warnings are now displayed by the "-analysis" option.
multiple occurrences of variable X in patternbut no longer attempts to check pattern exhaustiveness. Consequently, the following warning:
incomplete patterns in "case" instructionis no longer emitted in presence of non-linear patterns, as it was usually misleading.
See item 577 in the HISTORY.txt file.
infix operator "Xor" has a different priority than built-in "xor"and:
missing parentheses to disambiguate priority between "AND" and "OR"only when these operators are used in expressions where operator precedence really matters. For instance, no warning will be emitted for a sub-expression such as "p OR q OR r". See item 581 in the HISTORY.txt file.
V.Xor
V .[E] Xis rejected if the type of the expression is declared without a "with get" clause. In such case, TRAIAN now emits the following error message:
type T lacks "with get" to enable field accessesThis change is not backward compatible, as it may be required to introduce "with get" clauses in existing LOTOS NT programs to have them accepted by TRAIAN 3.12.
For instance, the two files "demos/demo_03/scsi.lnt" and "demos/demo_04/simproc.lnt" have been modified to insert "with get" clauses where needed. See item 584 in the HISTORY.txt file.
V.{X1->V1, ..., Xn->Vn}or:
V .[E] {X1->V1, ..., Xn->Vn}is rejected if the type of the expression is declared without a "with set" clause. In such case, TRAIAN now emits the following error message:
type T lacks "with set" to enable field updatesThis change is not backward compatible, as it may be required to introduce "with set" clauses in existing LOTOS NT programs to have them accepted by TRAIAN 3.12. See item 585 in the HISTORY.txt file.
From now on, TRAIAN 3.12 only accepts such "with" clauses, and generates the corresponding C code for the "range" types and, among types defined by their list of constructors, for enumerations and cascade types. For other types, such "with" clauses are now rejected.
A side effect of this change is that certain verifications concerning pragmas, which were previously done during C code generation, e.g.:
error: forbidden pragma !pointer for enumeration type Tare now done much earlier (in the function-binding phase of TRAIAN) and are thus performed when TRAIAN is invoked from CADP with its "-analysis" option. See item 595 in the HISTORY.txt file.
type T1 lacks function "string" needed by "string" for type T2See item 596 in the HISTORY.txt file.
clause "with INSERT" in type T2 requires function "==" for type T1 clause "with INSERT" in type T4 requires function "<" for type T3have been replaced with:
type T1 lacks function "==" needed by set type T1 type T3 lacks function "<" needed by sorted list type T4See item 556 in the HISTORY.txt file.
./test.lnt:4: limitation: processes not yet fully implementednow displays as:
test.lnt:4: limitation: processes not yet fully implementedSee item 570 in the HISTORY.txt file.
variable parameter X never usedemitted by TRAIAN was enhanced. From now on, this warning displays under three, more precise, forms, namely:
"in" parameter X never used "in var" parameter X never used "in out" parameter X never usedSee item 572 in the HISTORY.txt file.
variable parameter X never usedwas replaced by:
"in" parameter X never used
dead code after "stop" behaviourwas replaced by:
unreachable behaviour (dead code) after "stop"
"in out" parameter X overwritten before used (should be an "out var" parameter)or:
"in var" parameter X overwritten before used (should be a local variable)
See item 580 in the HISTORY.txt file.
"in out" parameter X never usedhas been replaced by a more informative warning:
"in out" parameter X never used nor assignedSee item 583 in the HISTORY.txt file.
"in" parameter X modified (should be an "in var" parameter)which is now replaced by a more precise warning:
"in" parameter X modified before used (should be a local variable)The former warning is now used only if X is used and then modified. See item 594 in the HISTORY.txt file.
TRAIAN_EQ_<type> TRAIAN_NE_<type> TRAIAN_LT_<type> TRAIAN_LE_<type> TRAIAN_GT_<type> TRAIAN_GE_<type> TRAIAN_GET_<type>_<field> (for ordinary types only).See item 552 in the HISTORY.txt file.
#ifndef TRAIAN_POINTER_<type> ... #endifand:
#if !defined (TRAIAN_POINTER_<type>) && !defined (TRAIAN_HASH_<type>) #define TRAIAN_STAR_<type>(TRAIAN_0) (TRAIAN_0) #else ... #endifSee item 553 in the HISTORY.txt file.
if (TRAIAN_EQ_T (V, C ())) ...but invokes the matching function:
if (TRAIAN_MATCH_C (V)) {This change, which was required in order to enable equality functions "==" to be defined by LOTOS NT code in scheme files without causing an infinite recursion, should be invisible to TRAIAN users, except the fact that the generated C code is now faster. See item 554 in the HISTORY.txt file.
This change is not backward compatible, and may require a few manual patches in the ".fnt" or ".tnt" files to define the C functions implementing external "==" functions. See item 561 in the HISTORY.txt file.
This comparison function is now invoked, instead of the equality function, in the C code generated by TRAIAN, e.g., in the lookup functions used to search for values stored in hash tables.
The library file "incl/lotosnt_predefined.h" has been extended with comparison macro-definitions for the predefined types: ADT_CMP_BOOL, ADT_CMP_NAT, ADT_CMP_INT, ADT_CMP_REAL, ADT_CMP_CHAR, and ADT_CMP_STRING. See item 562 in the HISTORY.txt file.
This change is not backward compatible: existing LOTOS NT programs may need to be updated by adding "with ==" and/or "with !=" clauses where necessary. Also, a few ".tnt" files may have to be updated manually. See item 564 in the HISTORY.txt file.
In file "incl/lotosnt_predefined.h", the comparison functions ADT_EQ_*, ADT_NE_*, ADT_LT_*, etc. defined for the predefined types have been simplified in the same way.
Finally, the C code generated by TRAIAN for the comparison functions "<", "<=", ">", and ">=" defined over singleton types has been optimized. See item 567 in the HISTORY.txt file.
See item 568 in the HISTORY.txt file.
if (ADT_TRUE ()) ...or
goto TRAIAN_CASE_LABEL_...;This removes "statement not reached" warnings emitted by the C compiler on the C code produced by TRAIAN. See item 575 in the HISTORY.txt file.
fprintf (stdout, "%s:%d:error: unexpected case in pattern matching\n", "FILE.lnt", LINE); fflush (stdout); raise (15);intended to report cases not covered by any pattern. Measured on our LOTOS NT test suite, this change eliminates 1.6% of the 5.5 million lines of C code generated by TRAIAN. See item 578 in the HISTORY.txt file.
Measured on our LOTOS NT test suite, this change eliminates 8.9% of the 5.5 million lines of C code generated by TRAIAN. This justifies the decision of making "with set" clauses explicit and mandatory. See item 587 in the HISTORY.txt file.
Measured on our LOTOS NT test suite, this change eliminates 2.1% of the 5 million lines of C code generated by TRAIAN. See item 591 in the HISTORY.txt file.
Consequently, TRAIAN now generates C code to implement these functions. Notice that, from a model-checking perspective, the implementation prioritizes space over time, in order to be memory efficient.
Also, these new functions come with hidden dependencies:
Therefore, TRAIAN now uses these definitions to generate C code for implementing these functions. This new code is more efficient than the one formerly generated by TRAIAN 3.11, since it uses iteration rather than recursion. For instance,nsome LOTOS NT programs handling large lists (9.9 million elements) now execute normally, whereas the code generated by TRAIAN 3.11 could cause stack overflows.
Notice that, if type T2 is defined as a list (or sorted list, or set) of another type T1, then the clause "with ==" (resp. "=", "!=", or "<>") in T2 now requires the presence of the same clause "with ==" (resp. "=", "!=", or "<>") in T1, as TRAIAN 3.12 no longer implements "==" and "!=" automatically.
For sorted lists and sets, this constraint was already there, because the INSERT function requires the "==" function.
TRAIAN 3.12 will report missing definitions by issuing error messages such as:
type T1 lacks function "==" needed by clause "with ==" of type T2See item 566 in the HISTORY.txt file.
result of comparison of constant 128 with expression of type 'signed char' is always true [-Wtautological-constant-out-of-range-compare]and
illegal character encoding in character literal [-Winvalid-source-encoding]See item 576 in the HISTORY.txt file.
This change is not backward compatible, as all occurrences of ZERO should be replaced by "0". Notice, however, that the name ZERO was not officially documented in the reference manuals of TRAIAN and LNT2LOTOS.
Besides increasing compatibility between LNT2LOTOS and TRAIAN, this change enables a more precise analysis of patterns. For instance, given the following definition:
function F (N : NAT) : BOOL is case N in 0 -> return false | SUCC (any) -> return true end case end functionTRAIAN no longer emits the following (spurious) warning:
possibly incomplete patterns in "case" instruction some values of type NAT, namely those of the following form: ZERO might not be matched by the given constants (an "any" pattern might be necessary to match the missing cases)Also, given the following definition:
function G (N : NAT) : BOOL is case N in 0 -> return false | 2 -> return true end case end functionTRAIAN 3.12 now emits a more informative warning:
possibly incomplete patterns in "case" instruction some values of type NAT, namely those of the following form: SUCC (X : NAT) might not be matched by the given constantsSee item 582 in the HISTORY.txt file.
See item 551 in the HISTORY.txt file.
type T is !card 4 C1 (B: BOOL), C2 (N: NAT) with ==, != end typeTo implement the "!=" operation of such types, TRAIAN 3.11 generated a macro-definition and a function, both of which were named TRAIAN_NE_T(). This caused a syntax error when the C compiler reached the function definition:
"test.c", line 641: syntax error before or at: ( "test.c", line 641: identifier redeclared: ADT_BOOL etc.See item 555 in the HISTORY.txt file.
warning: implicit function declaration: TRAIAN_MEMBER_TI identifier redeclared: TRAIAN_MEMBER_TIthat could be emitted by the C compiler, depending in which order types and functions were declared. See item 557 in the HISTORY.txt file.
"test.c", line 9: warning: implicit function declaration: TRAIAN_MATCH_TRAIAN_FUNCTION_NIL_167 Undefined first referenced symbol in file TRAIAN_MATCH_TRAIAN_FUNCTION_NIL_167 test.oSee item 560 in the HISTORY.txt file.
TRAIAN_UPDATE_<type>_<field> -- single underscoreshave been renamed to:
TRAIAN_UPDATE_<type>__<field> -- double underscores
TRAIAN_GET_<type>_<field> -- single underscoreshave been renamed to:
TRAIAN_GET_<type>__<field> -- double underscores
TRAIAN_GET_<type>_<constructor>_<field> -- single underscoreshave been renamed to:
TRAIAN_GET_<type>__<constructor>__<field> -- double underscores
Consequently, in file "incl/lotosnt_predefined.h", the following macro-definitions:
TRAIAN_GET_ADT_NAT_SUCC_X TRAIAN_GET_ADT_INT_NEG_X TRAIAN_GET_ADT_INT_POS_Xhave been renamed to:
TRAIAN_GET_ADT_NAT__SUCC__X TRAIAN_GET_ADT_INT__NEG__X TRAIAN_GET_ADT_INT__POS__XSuch changes are not backward compatible, and it might be necessary to modify handwritten C files, such as ".fnt" and ".tnt" files, if they contain such identifiers. See item 588 in the HISTORY.txt file.
type T is C (X: BOOL, Y: INT), C (X: BOOL, Z: REAL), D end typeIn such case, the C code generated by TRAIAN was incorrect, as it defined two different macros named TRAIAN_GET_T__C__X, which caused warnings from the C preprocessor:
macro redefined: TRAIAN_GET_T__C__XFrom now on, in presence of overloaded constructors, TRAIAN generates unique names for the macro-definitions. These are now named TRAIAN_GET_T__C__N__X, where N ≥ 1 is the index of the constructor (here, 1 or 2) in the type definition. See item 589 in the HISTORY.txt file.
type T1 lacks function "==" needed by "==" for type T2 type T1 lacks function "<" needed by "<" for type T2 etc.In such case, TRAIAN 3.11 generated C code that did not compile properly, as it contained references to undefined comparison functions, causing warnings from the C compiler:
warning: implicit function declaration: TRAIAN_EQ_T1This change is healthy, but may require to manually update existing LOTOS NT programs to insert missing "with ==", etc. clauses. For instance, file "demos/demo_01/DATA_IEEE_1394.lnt" was modified accordingly. See item 593 in the HISTORY.txt file.
See item 597 in the HISTORY.txt file.
See item 599 in the HISTORY.txt file.
For many years, TRAIAN has been used to develop compilers, including those of the CADP toolbox.
At present, TRAIAN is also part of the CADP toolbox, in which it serves to analyze formal specifications of concurrent systems.
We plan to pursue the progressive unification of the LOTOS NT and LNT
languages, and to increase the co-operation between the LNT2LOTOS and TRAIAN
compilers.
TRAIAN 3.12 can be freely downloaded from the TRAIAN Web Page located at: