Logo BCDDLogo CSC
BCDDBehavioural Contract-Driven Design
version 1.0-beta
ITEN

4. The grammar of declarations

Every rule describes an entire declaration, from the first word to the last, even if it spans several lines. A declaration is recognised only if all its tokens respect the rule, with nothing more.

4.1 Blocks

No. Rule Example
G1 IntestazioneCsc = "CSC" Nome "VERSION" Versione ; CSC LuceScale VERSION 0.1
G2 IntestazioneVista = "REFINEMENT" "VIEW" Nome ; is not a declaration of the language: it serves only to read the name of the withdrawn block in the report (section 4.8) REFINEMENT VIEW LuceParti
G3 Fine = "END" ; END

The ENTITY block has its own header G31 (section 4.9); the BINDING, VERIFICATION, PROFILE and EXTENSION blocks have the headers G40, G48, G49 and G50 (section 4.11). All of them end with G3.

4.2 Header of the CSC

No. Rule Example
G4 StatoCsc = "STATUS" Stato ; STATUS RATIFIED BY D-125
G5 Stato = "HYPOTHESIS" | "RATIFIED" "BY" Decisione ; HYPOTHESIS
G6 Scopo = "PURPOSE" Stringa ; PURPOSE "Switches on the staircase light"
G39 ImportaProfilo = "IMPORT" "PROFILE" Nome "VERSION" Versione ; IMPORT PROFILE Segnale VERSION 0.3

The header lines. In a CSC the header zone runs from the CSC line to the first declaration that does not begin with STATUS, IMPORT or PURPOSE (comments and blank lines do not count). There STATUS (G4), IMPORT PROFILE (G39) and PURPOSE (G6) stand in any order:

The same zone in the other blocks. Every block imports profiles for itself. The header zone, with the same rules, also exists in an entity (STATUS HYPOTHESIS, IMPORT PROFILE, PURPOSE; section 4.9), in a BINDING (STATUS, IMPORT PROFILE), in a VERIFICATION (IMPORT PROFILE; a STATUS is error E39) and in a PROFILE (STATUS, PURPOSE; IMPORT PROFILE is unrecognised there, because a profile does not import other profiles). The rules of the BINDING, VERIFICATION and PROFILE blocks are in section 4.11.

The imported profile. IMPORT PROFILE P VERSION v is a citation: bcdd looks for the block PROFILE P as it looks for a cited CSC (section 9.4), and finds it only with the written version v (same text). A profile found with another version is not found: the report lists it in section 7, with the version found. Of the profile found bcdd reads the extensions (section 4.14). Two lines that import the same profile with the same version are not an error and count as one; if two lines of the same block import the same profile with different versions, the second in the order of the file is not recognised, because the same extension name would have two meanings. The line registers no name in the list of names of the block.

A deliberate exception to G5: STATUS RATIFIED followed by anything other than BY and a Decisione (up to the colon in a contractual line, up to the end in the header) is recognised, with error E04. A badly written approval must not disappear among the unrecognised lines: it is precisely the error that the check must show. STATUS followed by a word other than HYPOTHESIS and RATIFIED, by contrast, is not recognised.

4.3 Inputs, outputs, states, constants

No. Rule Example
G7 Capacita = "CAPABILITY" Nome [ Parametri ] [ "AUTONOMOUS" ] ; CAPABILITY Check(file: String)
G8 Evento = "EVENT" ( "IN" | "OUT" ) Nome [ Parametri ] ; EVENT IN pressione
G9 Parametri = "(" [ Parametro { "," Parametro } ] ")" ; (file: String, riga: Optional String)
G10 Parametro = Nome ":" Tipo ; accettata: Boolean
G11 StatoOsservabile = "STATE" Nome ":" Tipo "INITIAL" Valore [ "FOLLOWS" Nome "." Nome ] | "STATE" Nome "[" Nome "]" ":" Tipo "INITIAL" Valore ; STATE accesa : Boolean INITIAL false, STATE clipCount[Ch] : Integer [0 ..] INITIAL 0, STATE volume : Integer [0 .. 100] INITIAL 50 FOLLOWS imposta.livello
G12 Definizione = "DEFINE" Nome [ ParametriDefine ] [ "DETAILS" Id [ "STATUS" Stato ] ] ":=" ( "UNDECIDED" | Espr ) | "DEFINE" "EVENT" Nome ":=" Espr ; DEFINE ATTESA_MAX_LLM := UNDECIDED, DEFINE vicino(a: Real, b: Real) := ABS(a - b) <= 0.01, DEFINE EVENT riavvio := accepted(Avvio)
G12a ParametriDefine = "(" Parametro { "," Parametro } ")" ; (a: Real, b: Real)

G7 declares a request; G12 a named constant, a function with parameters or a derived event.

Indexed states and states that follow an event (G11).

Constants, functions and derived events (G12).

A constant with its value. The most common case is a Valore of section 4.7: a number, with or without a sign and with or without a unit, a string, true, false or a value of a list of values. The unit stands on the same line as the number (G27). Examples, for the staircase light:

DEFINE DURATA_LUCE := 60 s        -- recognised: number and unit
DEFINE DURATA_LUCE := 60s         -- recognised: the space can be omitted
DEFINE RITARDO_MAX := 250 ms      -- recognised
DEFINE PIANI := 4                 -- recognised: plain number, without unit
DEFINE LAMPEGGIO := UNDECIDED     -- recognised: goes into section 3 of the report
DEFINE ATTENUAZIONE_MIN := -40    -- recognised: signed number
DEFINE DURATA_LUCE := 1 min       -- unrecognised: min is not a unit of the language
DEFINE LIVELLO_MAX := 90 dB       -- unrecognised: the only units are s and ms;
                                  --   one writes DEFINE LIVELLO_MAX_DBA := 90
DEFINE DURATA_LUCE := 60          -- recognised, but the next line, which begins with “s”,
                      s           --   opens a new declaration, unrecognised (U2)
DEFINE DURATA_AVVISO := DURATA_LUCE - 5 s   -- recognised: an expression, of type Duration
DEFINE DOPPIA := DURATA_LUCE * 2  -- recognised: a duration times a number is a duration
DEFINE STRANA := DURATA_LUCE + 2  -- recognised, with error E25: a duration plus a plain number

check checks the type of the expression (section 4.13), not the value: it does not know whether 120 s is a lot or a little, and a constant name written inside a string (VERBAL "switches off after DURATA_LUCE") is only text.

From UNDECIDED to a value. UNDECIDED denotes an undecided number: check lists it in section 3 of the report as long as it is present. When the number is decided, the value is written in place of UNDECIDED, by hand: no command does it. What is needed depends on the CSC:

4.4 Types

No. Rule Example
G13 Tipo = "Boolean" | "String" | "Duration" | ( "Integer" | "Real" ) [ Intervallo ] | "Sequence" "of" Tipo | "Optional" Tipo | TipoRecord | TipoNonDichiarato ; Sequence of String
G14 Intervallo = "[" NumeroConSegno ".." NumeroConSegno "]" | "[" NumeroConSegno ".." "]" | "[" ".." NumeroConSegno "]" ; Real [0.0 .. 1.0], Integer [-40 .. 0], Integer [0 ..], Integer [.. 10]
G15 TipoNonDichiarato = Nome ; different from the seven words Boolean String Duration Integer Real Sequence Optional Testo

| G30 | TipoDescritto = "TYPE" Nome ":=" "VERBAL" Stringa ; inside a CSC block; Nome is not one of the seven base types | TYPE Testo := VERBAL "the content of a file, line by line" | | G37 | TipoEnumerato = "TYPE" Nome ":=" "{" Nome { "," Nome } "}" ; inside a CSC block; the Nome of the type is not one of the seven base types | TYPE Fase := {inattiva, armata, in_corso} | | G41 | TipoConNome = "TYPE" Nome ":=" Tipo ; inside a CSC block; Nome is not one of the seven base types | TYPE Percentuale := Integer [0 .. 100], TYPE Campione := Record {L: Real, R: Real} | | G42 | TipoRecord = "Record" "{" Campo { "," Campo } "}" ; with Campo = Nome ":" Tipo ; | Record {L: Real, R: Real} |

An undeclared type is admitted: it is not an error, and it appears in section 6 of the report with the lines where it is used, so that it does not remain hidden. Sequence without of, or Optional without a type, are not recognised. check does not compare the limits of a range with each other: Real [20.0 .. -20.0] is recognised (section 14). A range with an omitted limit does not have that limit: Integer [0 ..] is a non-negative integer with no maximum; [ .. ], with neither limit, is not a range and makes the declaration unrecognised.

Named types (G41) and Record (G42).

Types described in words (G30):

Example: STATE contenuto : Testo INITIAL "" with TYPE Testo := VERBAL "the content of a file" in the same block: Testo does not appear in section 6.

Lists of values (G37). A list of values is a type made of a closed set of named values; a value of that type is one of them. Example:

TYPE Fase := {inattiva, armata, in_corso, accettata, rifiutata}
EVENT OUT stato(fase: Fase)
STATE fase_ora : Fase INITIAL inattiva
What Rule
The name of the type as G30: it enters the list of names of the block (E01 if repeated) and leaves section 6 UNDECLARED TYPES, throughout the block
The values they are names (L7) and enter the same list of names of the block: a value equal to a state, an event, a request, a constant, a short name or a value of another list of values is E01 on the second, in the order of the file (line, then column). A value repeated in the same list is E01 on the second. Line and column of the error: those of the value
A name as a value (G26) in INITIAL, GIVEN, assignments and arguments, and in a DEFINE whose value is a single name. In a CSC block, if the name is not a value of a list of values of the same block (and, in a DEFINE, not another name of the block either): E03 name not declared as a value of TYPE: X. In an entity scenario section 4.6 applies. In a wider expression section 4.13 applies
The type of the value is checked (section 4.13): STATE fase_ora : Fase INITIAL rifiutata is recognised without errors; STATE accesa : Boolean INITIAL armata (with armata a value of Fase) is recognised with error E25 value not of type Boolean: armata
It is not a guarantee no VERIFY, no E13, as G30. A VERIFY line after a TYPE opens a new declaration, unrecognised (U4)
Unrecognised, with no names registered TYPE X := {}, TYPE X := {a b}, TYPE X := {a,}, TYPE Boolean := {a, b} (base type), TYPE X := {"a", "b"}, TYPE X := {1, 2}
TYPE X := {a, a} recognised, with E01 on the second a
In the JSON a declaration of type TYPE, as G30; the values are not declarations of their own: they are in its testo

The lifecycle names (requested …), true, false and _ are reserved and cannot be values of a list of values (L7).

4.5 Contractual lines

No. Rule Example
G16 RigaContrattuale = ( "GUARANTEE" | "ASSUME" ) Id [ "DETAILS" Id ] [ "STATUS" Stato ] ":" Proprieta ; GUARANTEE g2a DETAILS g2 STATUS HYPOTHESIS: VERBAL "…" VERIFY BY JUDGEMENT "…"
G17 Proprieta = "VERBAL" Stringa Verifica | Formula ; (Formula: G55, section 4.12) VERBAL "Check never modifies the file" VERIFY BY INSPECTION "the file", WHENEVER pressione THEN accesa WITHIN 1 s
G18 Verifica = "VERIFY" "BY" ( "JUDGEMENT" | "INSPECTION" ) Stringa ; VERIFY BY JUDGEMENT "the operator"

A contractual line is a guarantee (GUARANTEE) or an assumption (ASSUME). It is read in two parts. The line header runs from the first word to the colon; the property comes after the colon.

The same holds for G12: in DEFINE LIMITE := DURATA * * 2 the name LIMITE exists, but the line is unrecognised because the expression does not respect section 4.12.

The missing verification (error E13). A deliberate exception to G17, like that of G5: if after the colon the property is exactly VERBAL followed by a closed string, and the declaration ends there, the line is recognised, its degree is verbal and there is error E13. Example: GUARANTEE g2: VERBAL "without verification". The reason: every guarantee and every assumption must state how it is verified. A guarantee that does not state it is not a form that bcdd cannot read: bcdd reads all of it and sees that a mandatory item is missing. Classifying it among the unrecognised lines, with outcome 0 without --strict, would let a guarantee with no way of checking it pass as valid. It is the same reasoning as E04 (an approval without a decision).

E13 is narrow on purpose. If after the string there is anything else, the rule remains G17: for example VERBAL "…" VERIFY BY MAGIC "…" declares a mode of verification that the language does not provide for, and is unrecognised, without E13. In the steps of scenarios the element VERBAL "…" (G22) is an assertion in words, not a property: it does not require VERIFY and never gives E13.

Which unrecognised declarations register a name. A registered name exists for the check: it can be named (DETAILS, steps), and it counts for E01. Only the following register one:

CAPABILITY, EVENT, STATE, SCENARIO and TYPE register nothing unless they are recognised in full. The reason for the difference: the short name of a contractual line serves the chain of DETAILS and the approval status (section 7), and the line header is read on its own, before the colon. For the other declarations the part that matters (parameters, type, GIVEN) is precisely the part that has not been read. The consequence: a step that names an event or a request whose declaration is not recognised gives E03 (name not declared as …). The error indicates the point to correct, and the badly written declaration is in section 5 of the report in any case.

4.6 Scenarios

No. Rule Example
G19 Scenario = "SCENARIO" Id [ "DETAILS" Id [ "STATUS" Stato ] ] [ "GIVEN" Assegnazione { "," Assegnazione } ] "EXPECT" ( "ADMITTED" | "REJECTED" ) ; SCENARIO s1 GIVEN accesa = false EXPECT ADMITTED, SCENARIO s1a DETAILS s1 STATUS HYPOTHESIS GIVEN accesa = false EXPECT ADMITTED
G20 Assegnazione = Nome [ "[" Valore "]" ] "=" Valore ; accesa = true, clipCount[L] = 2
G21 Passo = "@" Numero [ Unita ] [ Elemento { [ "," ] Elemento } ] ; @100 s pressione(tasto: 1) accesa = true
G22 Elemento = "VERBAL" Stringa | Ciclo | Assegnazione | Occorrenza ; VERBAL "the light has been off for a short time"
G23 Ciclo = ( "requested" | "accepted" | "rejected" | "completed" | "failed" ) "(" Nome ")" ; requested(Refine)
G24 Occorrenza = Nome [ "(" Argomento { "," Argomento } ")" ] ; risposta(proposta: "g2a", accettata: false)
G25 Argomento = Nome ":" ( Valore | "_" ) ; tasto: _
G36 NomeQualificato = Nome "." Nome ; only in scenarios and in entity formulas: the first name is a CSC of the entity, the second one of its elements Sessione.pronta, Abbinamento.abbina
G47 Ripetizione = "REPEAT" ( "FOREVER" | Intero ".." Intero ) "EVERY" Numero Unita ; REPEAT FOREVER EVERY 1 s, REPEAT 2..5 EVERY 100 ms

A scenario begins with SCENARIO (G19) and continues with its steps (G21). How one element of a step is distinguished from another, looking at most at the next token:

The comma between two elements may be written or omitted; a comma at the end of the step leaves the declaration open (U5): if the next line begins with @ the step remains unrecognised. The unit after the number of the step holds only if it is on the same line.

Indices in scenarios (G20). x[v] = w assigns the element v of an indexed state: v is a value of the type of the index (E29 otherwise), w a value of the type of the state. An indexed state written without an index, or a state without an index written with an index, is error E29.

Details of a scenario (G19). SCENARIO id DETAILS parent [STATUS …] details another scenario of the same block (E02 if parent is not a scenario). The status of the detailed scenario follows section 7.1. A scenario without DETAILS has no STATUS: SCENARIO s1 STATUS HYPOTHESIS EXPECT ADMITTED is not recognised.

Repetitions (G47). A REPEAT line stands among the steps of a scenario and holds until its end: the steps that follow it are the repeated ones. REPEAT FOREVER EVERY d repeats the steps without end; REPEAT m..n EVERY d from m to n times. Each repetition begins d after the previous one, and the times @t of the repeated steps count from the start of the repetition. Example:

SCENARIO lampeggio EXPECT ADMITTED
  @0 s     accendi
  REPEAT FOREVER EVERY 1 s
  @0 s     spegni
  @0.5 s   accendi
Case Outcome
a second REPEAT line in the same scenario E30 REPEAT repeated in the scenario: the first is at line N, on the second
REPEAT m..n with m > n or n = 0 E30 invalid repetitions: m..n. Write REPEAT minimum..maximum, with the maximum at least 1 and not smaller than the minimum
a repeated step with time t greater than or equal to d E30 the step @t is not shorter than the period of REPEAT: every repeated step has a time smaller than EVERY d
a REPEAT line with no steps after it E30 REPEAT without steps: the repeated steps are written after the REPEAT line
a scenario with steps without units and a REPEAT … EVERY d line E30 REPEAT … EVERY requires a scenario with time units
REPEAT FOREVER without EVERY, REPEAT 2..5 EVERY 1 (without unit), REPEAT -1..2 EVERY 1 s it is not G47: the line is not recognised
E12 it holds in the steps before REPEAT as at present, and among the repeated steps themselves, with the relative times; the first repeated step is not compared with those before REPEAT

A REPEAT line is not a step: it neither opens nor closes the scenario (section 5).

Known limitation: in @0 s pressione the word s is the time unit. An event named s or ms therefore cannot be the first element of a step without a unit.

Entity scenarios. In an ENTITY block SCENARIO (G19) and the steps (G21-G25) hold as in the CSC, with a single difference: the names of states, events and requests are qualified (G36). NomeQualificato is written in place of Nome in these three rules, and only in them:

G20e  Assegnazione = NomeQualificato "=" Valore ;
G23e  Ciclo        = ( "requested" | "accepted" | "rejected" | "completed" | "failed" ) "(" NomeQualificato ")" ;
G24e  Occorrenza   = NomeQualificato [ "(" Argomento { "," Argomento } ")" ] ;

G20e holds in the GIVEN and in the steps. The arguments (G25) remain simple names: they are the parameters of the event. A simple name in an entity scenario is read with G20, G23, G24 as in the CSC, and gives E03 (an entity does not have elements of its own). Example, in the entity Processore that provides Abbinamento, Sessione and Pulsanti:

SCENARIO comandoDopoAbbinamento GIVEN Sessione.pronta = true EXPECT ADMITTED
  @0 s   Abbinamento.abbina(codice: "AB12")
  @1 s   Pulsanti.premi(pulsante: "flat", acceso: true)

Meaning: as a scenario of a CSC, an open, timed trace that the entity admits or rejects, observed on several boundaries of the same entity. It is not part of the contract: it is not approved, and it indicates neither an order among the parts, nor a priority, nor a channel. What check checks:

Case Outcome
X.y, X is a recognised OFFERS or USES of the entity without E01, the CSC X is found (section 9.4) and has y of the right kind: STATE in assignments, EVENT in occurrences, CAPABILITY in lifecycle phases; every argument is a parameter of the event no error
as above, but y is not there, or is not of the right kind E03 name not declared as EVENT: X.y (and likewise STATE, CAPABILITY)
as above, but an argument is not a parameter of the event E03 name not declared as a parameter of X.y: a
X is not among the OFFERS and USES of the entity (recognised and without E01) E20 X.y: E neither provides nor uses connector X; a scenario can cite only the connectors of E, with E the name of the entity (? if it cannot be read)
X belongs to the entity but the CSC X is not found no error: the check of y and of its arguments is suspended, as E14 with a part not found; the citation is already in section 7
a simple name (pronta) E03, as in the CSC without that name: name not declared as STATE: pronta
a value that is a name (fase: armata) it is accepted as a value, without a check: the values of the lists of values of a cited CSC are not read (section 14)
a written value (number, string, true, false, ABSENT) for a state or a parameter of X.y it is checked against the type read in the block found, if it is a base type (Boolean, String, Duration, Integer, Real, with their range, also inside Optional): E25 if it is not of the type. A type that is not a base type (a list of values, a named type, a type described in words of the cited CSC) is not checked
X.y in a CSC (also with X equal to the CSC itself), in a GIVEN, in an assignment, in an occurrence, in a lifecycle phase or in a phase of a formula (section 4.12) E20 X.y: in a CSC, names are not written with the connector in front. The order of two connectors is written in a SCENARIO of the entity. The declaration is read with G20e, G23e, G24e only to give the error
X.y outside a scenario (for example DEFINE N := X.y, STATE s : X.T INITIAL …, OFFERS X.y) it is not a form: the declaration is not recognised

Line and column of E20 and of E03 on a qualified name: those of X. A declaration with E20 or E03 remains recognised (the form is right, the name is not), as with E03 in the CSC. With several versions of the same CSC provided or used (section 5) it is enough for y to be present in one of the blocks found for that name. If y is not present in any of the blocks found, but at least one of the OFFERS or USES lines with that name has not been found, the check of y and of its arguments is suspended, without E03: the missing version might have y, and an error is reported only when it is certain. E03 is written only when all the lines with that name are found. A line found only through the fallback (, expected VERSION w, section 9.4) does not count as found for this check: it is like a line not found, and the check of y is suspended, without E03 on the block of another version; in the report the line has expected in any case. E12 holds in entity scenarios as in the CSC. The short name of an entity scenario enters the list of names of the entity (section 5).

4.7 Values

No. Rule Example
G26 Valore = Stringa | NumeroConSegno [ Unita ] | "true" | "false" | "ABSENT" | Nome ; where Nome is a value of a list of values (section 4.4) 180 s, "", false, -40, armata, ABSENT
G27 Unita = "ms" | "s" ; on the same line as the number, with or without a space 250 ms, 50ms

4.8 The parts list, and the withdrawn view

No. Rule Example
G28 ElencoParti = "COMPOSED" "OF" ; COMPOSED OF
G29 Parte = Nome ":" Nome ; held only in views, which have been withdrawn from the language: it holds nowhere archivio : Archivio

G28 holds in the entity (section 4.9). LINK, MAP and REFINED BY are not read: they are unrecognised lines.

The view has been withdrawn. A decomposition is written with ENTITY. A REFINEMENT VIEW is treated as follows:

Why an error, and not an unrecognised line or a warning. check has no warnings: a section of the report would be needed for a single case. An unrecognised line denotes a form that bcdd cannot read, and without --strict it does not change the code: the view would pass in silence, and whoever wrote it would believe they had declared a decomposition. Here, by contrast, bcdd can read the form and knows that it is wrong, because it has been withdrawn: this is the definition of an error in section 8, and the same reasoning as E04 and E13. The message states what to write in its place.

Why the lines of the block are not recognised. Reading the parts of a view would mean continuing to give a meaning to a form that no longer has one. The lines all remain visible in section 5, with their number. The block remains a block, with its END, because otherwise END would give E08 and COMPOSED OF and the parts would appear to be written out of place.

4.9 Entities

An entity is recognised by the boundaries on which it stands: the CSCs it provides and those it uses. The provider of a CSC keeps its guarantees (GUARANTEE), the consumer satisfies its assumptions (ASSUME). An entity can be made of other entities, its parts. It has no elements of its own (events, states, requests): those stand in the CSCs, and a declaration of an element of its own in an entity is error E18 (section 5). An entity has scenarios with the qualified names (section 4.6).

No. Rule Example
G31 IntestazioneEntita = "ENTITY" Nome "VERSION" Versione ; ENTITY LuceScale VERSION 0.2
G32 Offerta = "OFFERS" Nome [ "VERSION" Versione ] ; the name is a CSC OFFERS Pressione VERSION 0.1
G33 Uso = "USES" Nome [ "VERSION" Versione ] ; the name is a CSC USES Comando
G34 ParteEntita = Nome ":" Nome [ "VERSION" Versione ] [ Molteplicita ] ; the first is the name of the part, the second an entity pulsante : Pulsante VERSION 0.1, telefono : Misuratore [1 .. 4]
G35 Molteplicita = "[" Numero ".." Numero "]" ; [1 .. 4], [2 .. 2]

The multiplicity of a part (G35). telefono : Misuratore [1 .. 4] states that the entity is made of at least m = 1 and at most n = 4 copies of the part. Every copy is bound in full by the CSCs that the part provides and uses. The multiplicity does not state when a copy is present or leaves, how the copies are distinguished or which comes first, nor where they are located. Without a multiplicity a part counts as [1 .. 1].

What Rule
Order only one: first the version (of the named entity), then the multiplicity (of the part). telefono : Misuratore [1 .. 4] VERSION 0.1 does not respect G34: it is not recognised and is not a part
Correct limits two integers (L13) with 0 <= m <= n and n >= 1: m = 0 makes the part optional (section 4.10)
E19 the form G35 is present, but a limit has a dot ([1.5 .. 4]), or m > n ([4 .. 1]), or n = 0 ([0 .. 0]). Line of the part, column of [
The part with E19 remains a part: it is looked for, it appears under the entity, it counts in the closure (E14, E16, E17) and in section 8 as if the multiplicity were correct. A wrong limit gives a single error, not a cascade of errors. It counts as a fixed part (present in every composition), even with m = 0
Not G35 [1 .. ], [1, 4], [-1 .. 4] (-1 is not a Numero, L11), [1 .. 4 : the declaration does not respect G34, is not recognised and is not a part (like every declaration that does not respect G34, section 5)
Closure and section 8 the line remains one part; the match does not change (9.4). The OFFERS X of a part does not satisfy its own USES X even with m >= 2: the copies of the same part do not serve one another. Two nodes that serve each other are two parts (a : Nodo, b : Nodo)
In the report the citation line is written without the multiplicity, as without the version (9.4)
In the JSON the PART citation has the field molteplicita: {"min": m, "max": n} with the two limits as numbers, or null if the line does not write one. With E19 the field is present all the same, with the limits as written if they are integers; if a limit has a dot the field is null

An entity with parts must be closed: every public boundary is kept by a part on the same side (E16), and every boundary provided by a part is used by another part or provided by the entity (E17). Closure is checked in every composition (section 4.10).

The example of the staircase light (the CSCs Pressione, Luce, Comando and the entities Pulsante, Lampada are in the same folder, one file each):

ENTITY LuceScale VERSION 0.2
  PURPOSE "The staircase light"
  OFFERS Pressione
  OFFERS Luce
  COMPOSED OF
    pulsante : Pulsante
    lampada  : Lampada
  GUARANTEE g1: VERBAL "A press with the light off switches on the light within 1 s"
                VERIFY BY JUDGEMENT "the operator, pressing the button"
END

The staircase light provides Pressione and Luce to the person on the stairs; inside, the lamp uses Comando, which the button provides. The report of this file is in section 9.4.

4.10 Variants, optional parts and compositions

An entity can state that one of its functions is performed by one device or another (variants), and that a part can be missing (optional part). It then holds for each of its compositions, and check checks all of them.

No. Rule Example
G38 Variante = "VARIANT" Nome "=" Nome ; the first name is the choice group, the second the choice VARIANT sensore = di

The segments. In an ENTITY block a G38 line opens a segment, which ends at the next VARIANT line or at END. The lines before the first segment are the common lines. In a segment the following hold: OFFERS (G32), USES (G33), COMPOSED OF (G28, once per segment: a second one in the same segment is not recognised, without effect), the parts (G34, optional ones included), GUARANTEE (G16, with DETAILS) and SCENARIO (G19) with the steps. The segments with the same choice group are the choices of that group and exclude one another; they need not stand one after the other. The choice groups and the choices have names of their own: they do not enter the list of names of the entity (section 5).

Case Outcome
VARIANT in a CSC block E21; unrecognised
VARIANT in an entity that does not respect G38 (VARIANT sensore, VARIANT sensore = di microfono) E21; unrecognised; it opens a segment all the same, without a choice group: its lines are read (names, short names, degrees), but the entity has no compositions: no E22, E23, E14, E16, E17 for it, no entry in sections 8, 9 and 10
VARIANT outside a block, in a withdrawn block unrecognised, without error
PURPOSE in a segment E21; unrecognised and it does not count for E10
STATUS in a segment unrecognised, without error (like every STATUS outside the header zone)
ASSUME, CAPABILITY, EVENT, STATE, DEFINE, TYPE in a segment E18, as in the rest of the entity
a choice group with a single choice E22 on its VARIANT; the group counts as a factor of 1
the same choice written twice E22 on the second line; the lines of the second segment count as lines of the same choice
a segment without any recognised declaration (lines with E01 count; comments, blank lines, unrecognised lines and a COMPOSED OF on its own do not count) E22 on its VARIANT: an empty choice is written with a part [0 .. 1]

The optional part. parte : E [0 .. n] (G35 with m = 0, section 4.9) means “without the part, or with from 1 to n copies”: two compositions, each fixed for the whole trace. In the composition “with” the part counts as [1 .. n]; in the composition “without” it does not provide, does not use and does not count in the closure. It is always looked for. It can stand among the common lines or in a segment (it is then present only with that choice).

The factors. A factor is what is chosen when the entity is composed:

Factor Values, in order Name of a value
a choice group of the entity the choices, in the order of the first line of each D = S
an optional part (without E19) present, then absent with P, without P
a choice group of a found part whose block has recognised G38 lines (the choices of the part are lifted to the entity) the choices, in the order of the block of the part P.D = S

The factors are ordered by line in the checked file: a choice group at the line of its first VARIANT, a part at its line; the choice groups of a part in the order of its block. A factor inside a segment exists only in the compositions of that choice; the factors of an optional part only in the compositions “with”. The optional parts of a part are not lifted: they do not change its OFFERS and USES lines, the only ones that are read of a part (9.4, a single depth).

The compositions. A composition has a value for every factor that exists in it. They are listed in lexicographic order on the factors (the first changes most slowly). The name is the list of the values, in order, separated by , : sensore = di, with di. An entity without factors has one composition without a name. In every composition:

The limit (E23). The number of compositions is counted before they are listed, with the formula on the factors, and counting stops as soon as it exceeds 64. Beyond that: E23 on the header, column 0; no closure for the entity, no entry in section 8.

Closure in every composition. E14, E16 and E17 (sections 8 and 9.4, with the match of 9.4) are checked in every composition that has at least one part present, with or without COMPOSED OF. In a composition without any part present (for example when the only part is optional and absent) closure is not checked, as in an entity without parts. If a part of the entity, in any segment, is not found, E14, E16 and E17 are suspended for the whole entity. The same error (code, line, column, message) of several compositions is written once, with the suffix (in: …) of section 9.5.

The declared absence. Let C be a composition with at least one absent optional part, A the absent parts and C+ the same composition with all the parts of A present. An error E14, E16 or E17 of C that is not present in C+ is not an error: it is a declared absence, in section 10 of the report. The named part (without P) is every p of A such that the error is not present in C with p alone put back; if none suffices on its own, all those of A, in line order, separated by , . No other error is ever an absence. The same error can be an absence in one composition and an error in another: it appears in both places.

Names, details and scenarios in segments. Two lines can stand together if they do not stand in two different choices of the same group. E01 between two parts, or between two OFFERS (or two USES), holds only between lines that can stand together (section 5); the short names of guarantees and scenarios remain unique throughout the entity. The line named by a DETAILS must stand among the common lines or in the same choice as the detail, otherwise E02. In an entity scenario X.y is checked per composition: a scenario of a segment holds with that choice, a common one in all of them; E20 with the suffix (in: …) where X is not a boundary of the composition. E03 does not depend on the composition.

A line in a segment is written in the report like the others (citation lines, sections 2-7). The guarantees of a segment are approved by short name like the others; the VARIANT lines are not approved (section 12).

4.11 Concrete forms, verification plan, profiles and extensions

A BINDING block contains the concrete forms of a boundary, a VERIFICATION block the verification plan, a PROFILE block the extensions of a field of use, each in an EXTENSION block. BINDING, VERIFICATION and PROFILE are blocks like CSC and ENTITY: they stand outside every other block, they end with END (G3), and their header, appearing inside an open block, closes that block with error E07 (section 5). EXTENSION stands only inside a PROFILE.

No. Rule Example
G40 IntestazioneBinding = "BINDING" Nome "VERSION" Versione [ "AS" Nome ] ; the first name is the bound CSC BINDING Comando VERSION 0.1, BINDING Pressione VERSION 0.1 AS filo
G48 IntestazioneVerification = "VERIFICATION" Nome "VERSION" Versione ; the name is the bound CSC VERIFICATION Luce VERSION 0.1
G49 IntestazioneProfilo = "PROFILE" Nome "VERSION" Versione ; PROFILE Segnale VERSION 0.3
G50 IntestazioneEstensione = "EXTENSION" Nome ; EXTENSION FADE
G51 Legame = "BIND" Elemento [ "STATUS" Stato ] ":" "VERBAL" Stringa ; with Elemento = Nome [ "." Nome ] ; BIND accesa: VERBAL "the ceiling light emits full light", BIND chiuso.motivo: VERBAL "the text on the display"
G52 Mezzo = "MEANS" Nome "OBSERVES" Elemento { "," Elemento } "RESOLUTION" Numero Unita [ "USING" Nome ] ; MEANS telecamera OBSERVES accesa RESOLUTION 40 ms
G53 StoriaTradotta = "SCENARIO" Id "TRANSLATES" Id ; followed by its steps SCENARIO s1-filo TRANSLATES s1
G43 CampoKind = "KIND" Parola ; KIND PATTERN
G44 CampoLevel = "LEVEL" Parola ; LEVEL CSC
G45 CampoParams = "PARAMS" "(" [ ParametroEst { "," ParametroEst } ] ")" [ ":" Tipo ] ; with ParametroEst = Nome ":" ( Tipo | Categoria ) ; and Categoria = "Name" | "Type" | "Event" | "Condition" | "Expression" | "Duration" | "Property" ; PARAMS (s: Expression, d: Duration), PARAMS (x: Real, a: Real, t: Real) : Boolean
G46 CampoVerify = "VERIFY" ( "V1" Controllo { "," Controllo } [ ";" "V2" Stringa ] | "BY" ( "JUDGEMENT" | "INSPECTION" ) Stringa ) ; with Controllo one of the words C1 … C8 VERIFY V1 C1 ; V2 "measurement of s over time"
G54 CampoTesto = ( "FORM" | "MEANING" | "SOURCE" ) Stringa | "REDUCES" "TO" RiduzioneEst ; FORM "FADE s WITHIN d"

Parola in G43 and G44 is any word (L3), reserved ones included: the value is checked afterwards (E33), so that a badly written value does not disappear among the unrecognised lines. V1, V2 and C1 … C8 are read as such only in G46 (section 2.3).

The BINDING block

BINDING Luce VERSION 0.1
  STATUS HYPOTHESIS
  BIND accesa: VERBAL "the ceiling light emits full light"
  BIND modo:   VERBAL "the indicator light on the button: green with the light off, off with the light on"
END

The VERIFICATION block

VERIFICATION Luce VERSION 0.1
  MEANS telecamera OBSERVES accesa, modo RESOLUTION 40 ms
  MEANS registratore OBSERVES pressione RESOLUTION 1 ms
  SCENARIO s1-sonda TRANSLATES s1
    @0 s     VERBAL "the finger presses the button"
    @0.5 s   VERBAL "the ceiling light is on"
END

The PROFILE block and the extensions

PROFILE Segnale VERSION 0.3
  PURPOSE "Quantities that vary continuously, measurements on samples, response over time"
  STATUS HYPOTHESIS

  EXTENSION FADE
    KIND     PATTERN
    LEVEL    CSC
    PARAMS   (s: Expression, d: Duration)
    FORM     "FADE s WITHIN d"
    MEANING  "s decreases without rising again and without jumps, and is 0 within d of the first step of the scope"
    VERIFY   V1 C1 ; V2 "recording of s over time"
    SOURCE   "the staircase light, guarantee g10"
  END
END

An extension. Between the line EXTENSION Nome and its END stand the fields, in any order, each at most once. KIND, LEVEL, PARAMS, FORM, MEANING, VERIFY and SOURCE are mandatory; REDUCES TO is optional. Every other declaration is unrecognised. What check checks:

Case Outcome
a mandatory field is missing, or its line is not recognised E33 field K is missing in EXTENSION X, on the EXTENSION line, column 0
a field written twice E33 field K repeated in EXTENSION X: the first is at line N, on the second
KIND with a value other than PATTERN, SCOPE, FUNCTION, DECLARATION, RELATION, SCENARIO-FORM E33 value of KIND not admitted: V
LEVEL with a value other than CSC, ENTITY, BINDING, VERIFICATION E33 value of LEVEL not admitted: V
KIND FUNCTION without the type of the result after PARAMS ( … ) E33 EXTENSION X has KIND FUNCTION: after PARAMS the result type is needed, PARAMS (…) : Type
the first word of FORM is not the name of the extension E33 FORM must begin with the name of the extension: X
a parameter of PARAMS that does not appear in FORM, or appears in it more than once E33 the parameter p must appear once in FORM
VERIFY V1 with a word other than C1 … C8 E33 VERIFY V1 names a check that does not exist: W
two extensions with the same name in the same profile E34 extension name already used at line N: X, on the second
the name of the extension is a keyword or reserved word (section 2.3) E34 the name of the extension is a word of the language: X; the line is recognised as a header, with no name registered
REDUCES TO names a word that is neither of the language, nor a parameter of the extension, nor another extension of the same profile (the units s and ms after a number are part of the number, G27, and are not names) E35 REDUCES TO names X: it is not a word of the language, a parameter or an extension of PROFILE P
the extensions of the same profile refer to one another circularly through REDUCES TO E35 circular REDUCES TO: A -> B -> A, on the member of the cycle that comes first in the file
REDUCES TO, with the parentheses around a single element removed, is a single construct of rules G55-G63 (a pattern, a scope, a function, a history expression, a phase, IF, an operator such as NOT, AND, +, <=), or a single use of another extension, whose operands and places are all parameters, each once, in any order, even when the construct begins with a place (p PRECEDES q, (p) PRECEDES q, x REQUIRES c, ABS(x), MAX(x, y), COUNT(p) IN LAST d, requested(x), NOT c, x + y, (IF c THEN a ELSE b)). Two extensions with the same reduction apart from the names of the parameters are not reported in this version (section 14) E36 EXTENSION X repeats a form that the language already has: F (with F the first word or the symbol of the construct, for example NEVER, PRECEDES, FOR AT LEAST, ABS, COUNT, requested, NOT, +, IF), or EXTENSION X repeats EXTENSION Y

The lines

The lines of these blocks are recognised, comments, blank or unrecognised as in every other block. In the blocks: line of the report a BINDING, a VERIFICATION and a PROFILE count as blocks; an EXTENSION does not, because it stands in its profile. A file that contains only BINDING, VERIFICATION or PROFILE blocks does not have E11.

No block of the language remains unread: section 11 of the report, which listed them, no longer exists, and its number is not used.

4.12 Formulas

A formula is a property written in a form that bcdd reads in full (G55): an optional scope and a pattern, with the expressions that compose them. It stands after the colon of a GUARANTEE or of an ASSUME (G17); expressions also stand in the value of a DEFINE (G12) and in the REDUCES TO of an extension (G54).

G55  Formula      = { "FOR" "ALL" Nome "IN" Nome ":" } [ Ambito ":" ] Pattern ;
G56  Ambito       = "WHILE" Espr
                  | "AFTER" Evento [ "UNTIL" Evento ]
                  | "BEFORE" Evento
                  | "BETWEEN" Evento "AND" Evento
                  | UsoEstensione ;                                   (KIND SCOPE)
G57  Pattern      = "ALWAYS" Espr
                  | "EVENTUALLY" Espr [ "WITHIN" Espr ]
                  | "WHENEVER" Espr "THEN" Espr [ "WITHIN" Espr | "AT" "ONCE" ]
                  | "NEVER" Espr
                  | Espr "PRECEDES" Espr
                  | Espr "FOR" "AT" "LEAST" Espr
                  | "ACCEPTS" Nome "ONLY" "WHILE" Espr
                  | Nome "REQUIRES" Espr
                  | Nome "ENSURES" Espr
                  | "RESOLVES" Nome "WITHIN" Espr
                  | "TRANSITION" Nome ":" Transizione { "," Transizione }
                  | UsoEstensione ;                                   (KIND PATTERN)
G58  Transizione  = Nome "->" Nome "ON" Evento [ "WHEN" Espr ] ;
G59  Espr         = "FOR" "ALL" Nome "IN" Nome ":" Espr | Implicazione ;
     Implicazione = Logica [ "IMPLIES" Logica ] ;
     Logica       = Negazione { "AND" Negazione } | Negazione { "OR" Negazione } ;
     Negazione    = "NOT" Negazione | Confronto ;
     Confronto    = Somma [ ( "=" | "<>" | "<" | "<=" | ">" | ">=" ) Somma
                          | "IN" "{" Valore { "," Valore } "}" ] ;
     Somma        = Prodotto { ( "+" | "-" ) Prodotto } ;
     Prodotto     = Meno { ( "*" | "/" ) Meno } ;
     Meno         = "-" Meno | Potenza ;
     Potenza      = Postfisso [ "^" Postfisso ] ;
     Postfisso    = Primario { "[" Espr "]" | "." Nome } ;
G60  Primario     = NumeroConSegno [ Unita ] | Stringa | "true" | "false" | "ABSENT"
                  | Nome | "(" Espr ")" | "(" "IF" Espr "THEN" Espr "ELSE" Espr ")"
                  | Funzione | Storia | Fase | Chiamata | "(" Evento ")"
                  | UsoEstensione ;                                   (KIND FUNCTION)
     Funzione     = ( "ABS" | "LOG10" | "ROUND" | "FLOOR" | "CEIL" | "PREV" | "PRESENT" | "CHANGED" ) "(" Espr ")"
                  | ( "MIN" | "MAX" ) "(" Espr "," Espr { "," Espr } ")" ;
G61  Storia       = "COUNT" "(" Evento [ "SINCE" Evento ] ")" [ "IN" "LAST" Postfisso ]
                  | "TIME" "SINCE" Evento
                  | "LAST" "(" Evento ")"
                  | "ONCE" Evento ;
G62  Evento       = RifEvento [ "WITH" Espr ] ;
     RifEvento    = Nome | Fase | "(" Evento ")" ;
     Fase         = ( "requested" | "accepted" | "rejected" | "completed" | "failed" ) "(" Nome [ "." Nome ] ")" ;
G63  Chiamata     = Nome "(" Nome ":" Espr { "," Nome ":" Espr } ")" ;
G64  UsoEstensione = Nome { Elemento } ;      (read according to the FORM of the extension, section 4.14)

How it is read. The rules of section 4 also hold here: a formula is recognised only if all its tokens respect G55, with nothing more. Some choices are made by looking one token ahead:

Precedence, from the strongest binding to the weakest:

Level Operators Associativity
1 x[i], x.campo left to right
2 ^ none: a ^ b ^ c is error E26
3 - in front of a value right to left
4 *, / left to right
5 +, - left to right
6 =, <>, <, <=, >, >=, IN none: a <= b <= c is error E26
7 NOT right to left
8 AND and OR the same operator is repeated (a AND b AND c); AND and OR mixed without parentheses are error E26
9 IMPLIES none: a IMPLIES b IMPLIES c is error E26
10 FOR ALL i IN T: the body extends to the end of the expression that contains it; inside another expression it stands within parentheses

Thus NOT a AND b is (NOT a) AND b, a AND b IMPLIES c is (a AND b) IMPLIES c, -x ^ 2 is -(x ^ 2) and x + y * 2 is x + (y * 2). e WITH c takes as its condition the whole expression that follows, up to SINCE, ), : or the end of the formula: TIME SINCE (frame WITH ch = L) > 5 s is written with the parentheses, because without them the condition would be ch = L > 5 s, a chained comparison (E26). IF … THEN … ELSE always stands within parentheses: DEFINE soglia := (IF notte THEN 10 ELSE 30); without parentheses the line is not recognised.

IN LAST binds more tightly than every operator. The duration of COUNT( … ) IN LAST d is a Postfisso (G61): a number with a unit, a name, a function, a call or an expression within parentheses. Thus ALWAYS COUNT(accendi) IN LAST 0.2 s <= 1 is (COUNT(accendi) IN LAST 0.2 s) <= 1, and COUNT(frame) IN LAST EVAL / (fs * EVAL) divides the count. A computed duration is written within parentheses: COUNT(e) IN LAST (2 * DURATA) > 3.

A phase with the qualified name. Fase (G62) admits Nome "." Nome for entity formulas, where the first name is a connector (section 4.9): requested(Sessione.Abbina). In a CSC a phase with the qualified name is error E20 with the message for the CSC (section 4.6), even when the first name is a request of the CSC itself. After a phase, WITH stands only where an event stands (G62) or inside the parentheses of "(" Evento ")": ALWAYS requested(Pulizie) WITH f = "x" is not recognised, like ALWAYS e WITH c.

Errors of form. A formula that bcdd reads in full and that violates a rule of the language gives an error; the declaration remains recognised, as with E13:

Case Error
AND and OR at the same level without parentheses E26 AND and OR together without parentheses: write (a AND b) OR c, or a AND (b OR c), on the first operator that changes
IMPLIES after IMPLIES without parentheses E26 IMPLIES after IMPLIES without parentheses: write a IMPLIES (b IMPLIES c), on the second
a comparison after a comparison without parentheses E26 chained comparisons: write a <= b AND b <= c, on the second
^ after ^ without parentheses E26 ^ after ^ without parentheses: write (a ^ b) ^ c, on the second
a pattern word (ALWAYS, EVENTUALLY, WHENEVER, NEVER, ACCEPTS, RESOLVES, TRANSITION) where an expression stands, or PRECEDES, FOR AT LEAST, REQUIRES, ENSURES inside the operand of another pattern E27 K inside another form: the language does not nest ALWAYS, EVENTUALLY, WHENEVER and their shorthands, with K the nested word
a second scope after the first (WHILE c: AFTER e: …) E27 a property has a single scope: K is the second
WITHIN … AT ONCE in the same pattern E27 WITHIN and AT ONCE in the same property: choose one
X REQUIRES c in a GUARANTEE E27 REQUIRES is used only in an ASSUME: in a GUARANTEE write ALWAYS (requested(X) IMPLIES c)

Every other form that does not respect G55-G64 (for example ALWAYS p WITHIN 1 s, WHENEVER p without THEN, an extra parenthesis, MIN(x) with a single argument) is not recognised, without error. Line and column of E26 and E27: those of the word or symbol indicated. A formula with E26 or E27 does not give E25: the types of a formula of wrong form are not certain. The names are checked in it all the same (E24, E29).

The BASE forms. In the language specification BASE is the set of the shorthands (manual, chapter 23): NEVER, AFTER, BEFORE, AFTER … UNTIL, BETWEEN … AND, PRECEDES, FOR AT LEAST, ACCEPTS … ONLY WHILE, REQUIRES, ENSURES, RESOLVES, ONCE, CHANGED, TRANSITION, FOLLOWS (G11), the indices (G11, G20), FOR ALL and REPEAT m..n (G47). Their meaning is the expanded form of the manual. check reads them as forms in their own right and checks their names and types; it does not write the expanded form. TRANSITION s: A -> B ON e [WHEN c], … is a single guarantee on a closed set of transitions of the state s: s is a STATE with a list of values as its type, A and B are values of that list, e is an event, c a condition.

FOR ALL i IN T. T is a finite type (the same as in section 4.3 for indices: E29 otherwise); i holds in the body and must not be a name of the block (E01). At the head of a formula (G55) it quantifies the whole property; inside an expression (G59) it quantifies the condition that follows.

4.13 Names and types

check statically checks the names and the types of formulas, of the expressions of DEFINEs, of declarations (G11) and of the values of scenarios. It computes no value: it knows that COUNT(e) is an integer, not what it amounts to.

Names. A name in a formula of a CSC is, in order: a variable of a FOR ALL that contains it; a parameter of the DEFINE that contains it; a parameter of the event of e WITH c, inside c; a name of the block (section 5); the name of an extension of the imported and found profiles (section 4.14). Otherwise, if the block imports a profile not found, the declaration is not recognised, with the reason (section 4.14); if not, it is error E24 name not declared: X. A name written only in an unrecognised declaration (for example EVENT IN pressione FACE utente) is not a name of the block (section 4.5): a formula that uses it gives E24, as a step gives E03. The error indicates the line to correct; the badly written declaration is in section 5 of the report. Every position requires a kind:

Position Kind required Error if the name is of another kind
an event: AFTER, BEFORE, UNTIL, BETWEEN … AND, ON, COUNT( … ), SINCE, TIME SINCE, LAST( … ), ONCE, to the left of WITH an EVENT, a DEFINE EVENT or a phase of a request E24 X is not an event: an EVENT, a DEFINE EVENT or a phase of a CAPABILITY is needed
a request: inside a phase (requested(X) …), ACCEPTS X, X REQUIRES, X ENSURES, RESOLVES X a CAPABILITY E24 X is not a CAPABILITY
a state: the state of TRANSITION, the argument of PREV and of CHANGED a STATE (also with an index or with a field) E24 X is not a STATE
a value or a condition: every other position a STATE, a DEFINE without parameters, a variable or a parameter, a value of a list of values, an event (only as a condition), a name given by an extension E24 X is a CAPABILITY: it is named with a phase (requested(X), …) or in ACCEPTS, REQUIRES, ENSURES, RESOLVES, for a request; a type, a scenario or a short name give X is not a value
a field: x.c, LAST(e).c a field of the Record of x, or a parameter of e E24 name not declared as a field of T: c
a call name(p: a, …) a DEFINE with parameters; every p one of its parameters, each once E24 X is not a DEFINE with parameters; name not declared as a parameter of X: p; the argument p is missing in the call to X. If an argument has a name that is not a parameter, the call gives only that error, without the argument … is missing: a wrong name is a single error. Two arguments with the same name are E01
an index: x[i] a value of the type of the index of x, or a variable of FOR ALL over that type E29 index of X not of type T: v, even when v is not declared: the message states what is needed

Line and column of E24: those of the name. With a qualified name (in an entity, section 4.9) those of X.

Types. Every expression has a type: Boolean, Integer, Real, Duration, String, a list of values, a Record, Sequence of T, Optional T, or an unknown type. An unknown type is that of an undeclared type, of a type described in words (G30), of an UNDECIDED constant, of a name given by an extension, and, in an entity formula, of every element X.y of a cited CSC (section 4.9). An expression of unknown type is accepted in every position, and the result of an operation on it has an unknown type: check does not give errors that are not certain.

Expression Type
a number without a dot, without a unit Integer
a number with a dot, without a unit Real
a number with s or ms Duration
a string String
true, false; a comparison; NOT, AND, OR, IMPLIES; IN { … }; PRESENT(x); CHANGED(x); ONCE e; an event used as a condition (true in the step in which it occurs) Boolean
ABSENT Optional of any type
a value of a list of values that list
a state, a constant, a parameter, a field its type; with a name given by G41, the named type; Integer [a .. b] and Real [a .. b] count as Integer and Real (the limits do not propagate)
COUNT( … ), with or without IN LAST Integer
TIME SINCE e Duration
LAST(e).p the type of the parameter p
PREV(x) the type of x
(IF c THEN x ELSE y) the type of x and of y, which must have the same type (Integer and Real give Real)
a + b, a - b Integer if both are Integer, Real if they are numbers, Duration if both are Duration
a * b as + for two numbers; Duration for a duration and a number, in either order
a / b Real for two numbers; Duration for a duration divided by a number; Real for two durations
a ^ b, LOG10(a) Real; the operands are numbers
- a, ABS(a) the type of a, number or duration
ROUND(a), FLOOR(a), CEIL(a) Integer; the operand is a number
MIN( … ), MAX( … ) the common type of the arguments, all numbers or all durations
a call name( … ) the type of the expression of the DEFINE; every argument has the type of its parameter
a use of an extension of KIND FUNCTION the type of the result in PARAMS
Position Type required
condition: WHILE, ALWAYS, EVENTUALLY, WHENEVER and THEN, NEVER, the two parts of PRECEDES, the left part of FOR AT LEAST, ONLY WHILE, REQUIRES, ENSURES, WHEN, WITH, the condition of IF, the operands of NOT, AND, OR, IMPLIES, the body of FOR ALL inside an expression, the value of a DEFINE EVENT Boolean
duration: WITHIN, IN LAST, the right part of FOR AT LEAST, RESOLVES … WITHIN Duration
= and <> two operands of the same type: two numbers, two durations, two strings, two Booleans, two values of the same list; Optional T with T or with ABSENT
<, <=, >, >= two numbers or two durations
x IN {v, …} every v is a value of the type of x
x[i] x has an index, and i is a value or a variable of FOR ALL of the type of the index (E29)
PRESENT(x) x of type Optional

In every other position an expression Optional T counts as T: check does not track whether the value is present. Thus, with c of type Optional Campione and Campione a Record, c.L is the field L of the record.

An expression of the wrong type is error E25 inconsistent type: A needed, B found, with A and B written as in the table (Boolean, Duration, a number, a number or a duration, the name of a list of values, …; an event in a value position is written an event). Line and column: those of the first token of the expression. Examples: EVENTUALLY accesa WITHIN 60 gives inconsistent type: Duration needed, Integer found; ALWAYS COUNT(pressione) gives inconsistent type: Boolean needed, Integer found; WHENEVER pressione THEN fase = accesa, with accesa from another list of values, gives inconsistent type: Fase needed, Modo found.

Written values. The same types are compared with the written values (G26) in INITIAL (G11), in the GIVEN and in the assignments of scenarios (G20) and in the arguments of events in steps (G25):

Declared type Admitted values
Boolean true, false
String a string
Duration a number with s or ms
Integer [a .. b] a number without a dot and without a unit, between the written limits (inclusive; an omitted limit does not limit)
Real [a .. b] a number without a unit, between the written limits
a list of values E a value of E
Optional T ABSENT, or a value admitted for T
Record, Sequence of T none: in steps _ is written
an unknown type any value

A value not admitted is error E25 value not of type T: V, with T the type as written in the declaration and V the value as written; line and column those of the value. A name that is not a value of any list of values of the block remains error E03 (section 4.4), without an additional E25. _ is always admitted in arguments. In an entity scenario the rule of section 4.6 applies.

4.14 The use of extensions

A block uses the extensions of the profiles that it imports in its header zone (section 4.2), and only those: an extension of a profile that is not imported does not exist for the block, even if the profile stands in the same file.

Where a use is recognised. A name is a use of an extension when it is the name of an extension of an imported and found profile, and stands in the position that its KIND provides for:

KIND Position
PATTERN the place of the pattern in a formula (G57)
SCOPE the place of the scope in a formula (G56), followed by :
FUNCTION the place of a Primario in an expression (G60)
DECLARATION the first word of a declaration of the block
RELATION the first word of a declaration of an entity
SCENARIO-FORM the place of an element of a step (G22)

The block must be of the LEVEL of the extension: CSC in a CSC, ENTITY in an entity, BINDING in a BINDING, VERIFICATION in a VERIFICATION. An extension used in a block of another level, or in a position of another KIND, is error E37 X has LEVEL L: it is not used in a B block or X has KIND K: it is not used in this position.

How a use is read. The tokens that follow the name are compared with the FORM: every fixed token must be present, identical; every place of a parameter takes an argument, which is read up to the next fixed token of the FORM (or, for the last place, up to the end of the position: the end of the formula, of the declaration or of the step element; within parentheses, the ) or the , at the same level that closes or separates what contains the use). Thus MAX(SQ r, 1.0) and (SQ r) > 1.0 are read, whereas SQ r > 1.0 gives SQ the argument r > 1.0. A FORM of KIND FUNCTION that ends with a fixed token ("NEAR ( x , a , t )") does not have this problem. The argument must be of the category or of the type of the parameter:

The parameter The argument
Name a name of the block; in a use of KIND DECLARATION, the first Name place of the FORM is instead the name declared by the line (see below)
Type a type (G13)
Event an event (G62)
Condition a Boolean expression
Expression an expression
Duration a Duration expression
Property a property (G55)
a type an expression of that type; an undeclared type accepts any expression

A use that does not respect the FORM is error E37 use of X that does not respect FORM "F", on the name; an argument of a wrong category gives E24 or E25 as in a formula. Example, with the profile Segnale of section 4.11 imported: GUARANTEE g10: WHILE modo = spenta: FADE luminosita WITHIN 2 s uses FADE, with s = luminosita and d = 2 s.

Names declared by an extension. In a use of KIND DECLARATION (for example SIGNAL needle[Ch] : Real [0.0 .. 1.0], with FORM "SIGNAL nome[I] : T"), the argument of the first Name place is a new name of the block: it enters the list of names (E01 if repeated) and is used in formulas as a value or as a condition, with an unknown type and with or without an index, without a check. It is neither an event nor a request. A use of KIND DECLARATION that does not respect the FORM is error E37 on the name of the extension: the declaration remains recognised (section 8) but registers no name, because it is not known which token is the name; where that name is used there is E24, as for a name written only in an unrecognised declaration (section 4.13). The name of an extension of KIND PATTERN, SCOPE or FUNCTION as the first word of a declaration is error E37 X has KIND K: it is not used in this position, and the declaration remains recognised.

The degree. The extensions that a formula uses are all those that appear in it, also inside the argument of another use (DURING (NEAR r TO 1.0): … uses DURING and NEAR), plus those used, at any depth, by the DEFINEs that the formula names (constants, calls, DEFINE EVENT): with DEFINE K := SQ r, ALWAYS K > 0.0 uses SQ. This set counts for the degree, for section 15 of the report (section 9.7) and for the status (point 0a of section 7.1). A formula that uses at least one extension without a recognised REDUCES TO is of degree declared extension; if all the extensions it uses have a recognised REDUCES TO it is formal (section 6).

The uses that this version does not read. bcdd 1.0-beta does not read the uses of extensions of KIND RELATION and KIND SCENARIO-FORM. An entity declaration that begins with the name of a RELATION extension, and a step with an element that is a use of a SCENARIO-FORM extension, are not recognised and appear in section 5 of the report (with --strict, code 3). These uses declare no names, so they leave no errors in the lines that follow (section 14).

A profile not found. If a block imports a profile that bcdd does not find (section 4.2), or a profile with an extension that has errors in its file, a declaration of the block that contains a name that does not resolve otherwise (a name that section 4.13 would give as E24, or the first word of a declaration that no rule of section 4 accepts) is not recognised, with the reason in section 5 of the report: (profile P VERSION v not found) or (EXTENSION X of PROFILE P with errors). It is not an error: the name might come precisely from that profile, and an error is reported only when it is certain. With --strict the line makes the program exit with code 3.

The status. A contractual line that uses an extension of a profile pending approval is pending approval, even in an approved CSC (section 7.1).

Total: 13 rules of the words (L1-L13), 5 rules of division (U1-U5), 64 rules of declarations (G1-G64, with G12a and the variants G20e, G23e, G24e of entity scenarios). G30, G37, G41 and G42 are in section 4.4; G36 and G47 in 4.6; G31-G35 in 4.9; G38 in 4.10; G39 in 4.2; G40, G43-G46 and G48-G54 in 4.11; G55-G64 in 4.12. G2 serves only the report of a withdrawn block and G29 holds nowhere (section 4.8); the numbering is preserved.