Forward expression#

A forward expression is stored as a Forward class. The class hierarchy is given in the following pictures:

../../../_images/forward.svg

Forward class diagram#

../../../_images/forward_return.svg

Forward return#

class ansys.scadeone.core.swan.Forward(state: ForwardState, dimensions: List[ForwardDim], body: ForwardBody, returns: List[ForwardReturnItem], luid: Luid | None = None)#

Bases: Expression

Forward expression:

fwd_expr ::= forward [[ luid]] [[ (( restart | resume )) ]] {{ dim }}+
fwd_body returns ( returns_group )
returns_group ::= [[ returns_item {{ , returns_item }} ]]
get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

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 model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.ForwardState(value)#

Bases: Enum

Forward state enumeration.

class ansys.scadeone.core.swan.ForwardBody(body: List[ScopeSection], unless_expr: Expression | None = None, until_expr: Expression | None = None)#

Bases: SwanItem

forward construct:

fwd_body ::= [[ unless expr ]] scope_sections [[ until expr ]]

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

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 model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

Dimensions#

class ansys.scadeone.core.swan.ForwardDim(expr: Expression | None = None, dim_id: Identifier | None = None, elems: List[ForwardElement] | None = None, protected: str | None = None)#

Bases: SwanItem

forward construct dimension:

dim ::= << expr >> [[ with (( << id >> | current_elt )) {{ current_elt }} ]]

Note that:

  • there may be no with part,

  • or it is an ID followed by a possible empty list,

  • or if no ID, at least one current_element.

The is_valid() method checks for that property.

Parameters:
expr: common.Expression

Dimension expression.

id: common.Identifier (optional)

with ID.

elems: List[ForwardElement] (optional)

with elements part.

protected: str (optional)

Content of the dimension if it syntactically incorrect. In that case, all other parameters are None.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property dim_id: Identifier | None#

forward dimension ID, or None.

property elems: List[ForwardElement] | None#

forward dimension elements or None.

property expr: Expression#

forward dimension expression.

property is_protected#

True when dimension is syntactically incorrect and protected.

property is_valid: bool#

Returns True when ID is given, or list of elements is not empty.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property protected: str#

Returns protected form as a string if dimension is syntactically invalid.

property value: str#

Protected dimension content.

class ansys.scadeone.core.swan.ForwardElement(lhs: ForwardLHS, expr: Expression)#

Bases: SwanItem

Forward current element:

current_elt ::= current_lhs = expr ;

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property expr: Expression#

Current element expression.

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 lhs: ForwardLHS#

Current element.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.ForwardLHS(lhs: Identifier | Self)#

Bases: SwanItem

forward construct:

current_lhs ::= id | [ current_lhs ]

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property is_id: bool#

True when current lhs is an ID.

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 lhs: Identifier | Self#

Returns current lhs as an Identifier or a ForwardLHS.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

Return#

class ansys.scadeone.core.swan.ForwardReturnItem#

Bases: SwanItem

Base class for returns_item.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

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 model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.ProtectedForwardReturnItem(data: str)#

Bases: ProtectedItem, ForwardReturnItem

forward construct: protected returns_item with {syntax% … %syntax} markup.

get_full_path() str#

Full path of Swan construct.

has_markup(markup: str) bool#

Check if protected data has the specified markup.

Parameters:
markupstr

String markup.

Returns:
result: bool

True when instance markup is same as parameter.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property data: str#

Protected data between markups.

Returns:
str

Protected data.

property is_protected#

Tell if item is syntactically protected and provided as a string.

property markup: str#

Protection markup.

Returns:
str

Markup string.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

Item clause#

class ansys.scadeone.core.swan.ForwardReturnItemClause(item_clause: ForwardItemClause)#

Bases: ForwardReturnItem

forward construct: returns_item ::= item_clause.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

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 item_clause: ForwardItemClause#

Item clause.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.ForwardItemClause(id: Identifier, last_default: ForwardLastDefault | None = None)#

Bases: SwanItem

forward construct:

item_clause ::= id [[ : last_default ]]

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property id: Identifier#

Item_clause 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 last_default: ForwardLastDefault | None#

Item_clause last default.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

class ansys.scadeone.core.swan.ForwardLastDefault(last: Expression | None = None, default: Expression | None = None, shared: Expression | None = None)#

Bases: SwanItem

forward construct: last_default.

last_default ::= last = expr
default = expr
last = expr default = expr
last = default = expr
Parameters:
last: common.Expression (optional)

last expression.

default: common.Expression (optional)

default expression.

shared: common.Expression (optional)

last and default share the same expression. shared cannot be used with last or default.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property default: Expression | None#

Returns default expression or shared one.

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 is_shared: bool#

True when last = default = expr.

property last: Expression | None#

Returns last expression or shared one.

property model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property shared: Expression | None#

Return shared expression.

Array clause#

class ansys.scadeone.core.swan.ForwardReturnArrayClause(array_clause: ForwardArrayClause, return_id: Identifier | None = None)#

Bases: ForwardReturnItem

forward construct:

returns_item ::= [[ id = ]] array_clause

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

property array_clause: ForwardArrayClause#

Array clause.

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 model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property return_id: Identifier | None#

Identifier of clause, or None.

class ansys.scadeone.core.swan.ForwardArrayClause(return_clause: ForwardItemClause | Self)#

Bases: SwanItem

forward construct:

returns_clause ::= (( item_clause | array_clause )) array_clause ::= [ returns_clause ]

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: Self, children: Self | Iterable[Self])#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem]]

Items to set owner.

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 model: Model#

Return model containing the Swan item.

property module: ModuleBase#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface

property owner: Self#

Owner of current Swan construct.

property return_clause: ForwardItemClause | Self#

Return array_clause content.