Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 830 Bytes

TUTORIAL-ENUM.md

File metadata and controls

52 lines (40 loc) · 830 Bytes

TRLC Tutorial (Enumerations)

This is part of the TRLC Tutorial.

Enumerations

Creating user-defined enumerations is easy:

enum ASIL {
   QM "not safety releated"
   A
   B
   C
   D
}

Like with records, you can add description strings to none, some, or all of the members.

Enumerations members have to be unique for the enumeration they belong to, but it is possible to have the same name elsewhere:

enum Language {
   Ada
   C    // Does not conflict with ASIL.C
   Rust
}

Using enumerations

These new types can be used in records:

type Requirement {
   description String
   integrity   ASIL
}

And when writing requirements you assign enumerations qualified by with the enumeration name:

Requirement potato {
   description = "Potato"
   integrity   = ASIL.QM
}