Type declarations#
A type declaration is a type name and its optional definition. Type definitions are type expressions, enumerations, variants, and structures.
- class ansys.scadeone.core.swan.TypeDecl(id: Identifier, definition: TypeDefinition | None = None)#
Bases:
Declaration
Type declaration with its name and optional definition: type_decl ::= id [[ = type_def ]].
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property id: Identifier#
Language item identifier.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
Type definitions#
The class hierarchy of type definition is shown in the next figure:
Type definitions class diagram#
- class ansys.scadeone.core.swan.TypeDefinition#
Bases:
SwanItem
Base class for type definition classes.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- class ansys.scadeone.core.swan.ExprTypeDefinition(type: TypeExpression)#
Bases:
TypeDefinition
Type definition as a type expression: type_def ::= type_expr.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
Enumeration#
- class ansys.scadeone.core.swan.EnumTypeDefinition(tags: List[Identifier])#
Bases:
TypeDefinition
Type definition as an enumeration: type_def ::= enum { id {{ , id }} }.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
Variant#
A variant is represented by a VariantTypeDefinition
instance which contains
a list of VariantComponent
instances representing the variant cases:
a simple tag
a tag with a type expression
a complex tag with a list of fields
- class ansys.scadeone.core.swan.VariantTypeDefinition(tags: List[VariantComponent])#
Bases:
TypeDefinition
Type definition as a variant: type_def ::= variant {{ | variant }}.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- class ansys.scadeone.core.swan.VariantComponent(tag: Identifier)#
Bases:
SwanItem
Variant component: variant ::= id variant_type_expr.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- property tag#
Variant tag.
- class ansys.scadeone.core.swan.VariantSimple(tag: Identifier)#
Bases:
VariantComponent
Simple Variant
variant ::= ID {}
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- property tag#
Variant tag.
- class ansys.scadeone.core.swan.VariantTypeExpr(tag: Identifier, type: TypeExpression)#
Bases:
VariantComponent
Variant type expression:
variant ::= ID { type_expr }
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- property tag#
Variant tag.
- property type: TypeExpression#
Variant type expression.
- class ansys.scadeone.core.swan.VariantStruct(tag: Identifier, fields: list[StructField])#
Bases:
VariantComponent
Variant structure expression:
variant ::= ID struct_texpr
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property fields: list[StructField]#
Variant structure fields.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- property tag#
Variant tag.
Structures#
- class ansys.scadeone.core.swan.StructTypeDefinition(fields: List[StructField])#
Bases:
TypeDefinition
Type definition as a structure: type_expr ::= { field_decl {{, field_decl}}}.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property fields: List[StructField]#
List of fields.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- class ansys.scadeone.core.swan.StructField(id: Identifier, type: TypeExpression)#
Bases:
SwanItem
Structure field as: ID : type_expr.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property id: Identifier#
Field name.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- property type: TypeExpression#
Field type.
Type expressions#
A type defined by a type expression has its definition stored as
a ExprTypeDefinition
instance which contains the type expression
as a TypeExpression
instance. The TypeExpression
is the
base class for the type expressions given by the following figure:
Type expressions class diagram#
- class ansys.scadeone.core.swan.TypeExpression#
Bases:
SwanItem
Base class for type expressions.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
Predefined types#
PredefinedType
class is the base class for the classes:
- Signed integer types
Int8Type, Int16Type, Int32Type, Int64Type
- Unsigned integer types
Uint8Type, Uint16Type, Uint32Type, Uint64Type
- Floating point types
Float32Type, Float64Type
- Other types
BoolType, CharType
- class ansys.scadeone.core.swan.PredefinedType#
Bases:
TypeExpression
Predefined types.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
Sized types#
Definition of types like T = signed<<42>>
or T = unsigned<<42>>
.
- class ansys.scadeone.core.swan.SizedTypeExpression(size: Expression, is_signed: bool)#
Bases:
TypeExpression
Type with a size expression:
type_expr ::= signed << expr >>| unsigned << expr >>- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
Reference to other types and generic types#
- class ansys.scadeone.core.swan.TypeReferenceExpression(alias: PathIdentifier)#
Bases:
TypeExpression
Type reference to another type: type_expr ::= path_id.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property alias: PathIdentifier#
Returns aliased type name.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- class ansys.scadeone.core.swan.VariableTypeExpression(name: Identifier)#
Bases:
TypeExpression
Type variable expression: type_expr ::= ‘Id
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property name: Identifier#
Name of variable.
- property owner: Self#
Owner of current Swan construct.
Arrays#
- class ansys.scadeone.core.swan.ArrayTypeExpression(type: TypeExpression, size: Expression)#
Bases:
TypeExpression
Array type expression: type_expr := type_expr ^ expr.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected: bool#
Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.
- property size: Expression#
Array size.
- property type: TypeExpression#
Array cell type.
Protected type expression#
- class ansys.scadeone.core.swan.ProtectedTypeExpr(data: str)#
Bases:
TypeExpression
,ProtectedItem
Protected type expression, i.e., saved as string if syntactically incorrect.
- static set_owner(owner: Self, children: Self | Iterable[Self])#
Helper to set owner as the owner of each item in the Iterable items.
- property is_protected#
Tell if item is syntactically protected and provided as a string.
- property module: ModuleBase#
Module containing the item.
- Returns:
ModuleBase: module container, see
ModuleBody
andModuleInterface
- property owner: Self#
Owner of current Swan construct.