expressions

Labs

Description

syside.experimental.expressions – expression templates and their model encoding.

An expression template is an immutable value describing an expression tree: literal() for a Python primitive, ref() for a reference to a model element, op() for an operator application, call() for a function invocation. Templates have no model identity, compare structurally and hash, so they can be built once and reused, compared, and used as dictionary keys.

Python operator aliases are provided where the token, the precedence and the meaning agree between Python and KerML: <, >, <=, >=, +, -, *, / and %. == is not among them – it stays Python’s structural comparison of two templates. The operators whose operands are expressions go through op(), and the body operators select (.?{}) and collect (.{}) through select() and collect() over a body() of parameter() values; the classification and metadata operators (istype, hastype, as, @, @@, meta, all), whose second operand is a type, go through op() too and build a TypeOperationTemplate.

instantiate() writes a template into a feature’s value position, creating fresh model elements; decode() reads such a subgraph back out as a template, raising UndecodableExpression for a subgraph no template describes.

Both syside.experimental.builder and syside.experimental.query build on this package – the constructors accept templates in expression positions, and the accessors return them – and both re-export the names above, so ordinary use needs no direct import from here.

Index

Classes

UndecodableExpression

Raised when an expression subgraph corresponds to no template.

ArrowInvocationTemplate

An arrow invocation: the template form of s->f(b), s->f(y=b), s->collect {in i; i + 1} or s->reduce g.

BodyParameterTemplate

A body parameter, in i : Integer, and every reference to it: built by parameter().

BodyTemplate

A body, {in i : Integer; i > 0}: parameters and one result expression.

CollectTemplate

A collection, s.{in i; i + 1}: body’s result for each value of source.

ConnectorEndTemplate

One end of a connector, [1] e1 ::> a: the feature the end references, the end’s multiplicity and its name, built by connector_end().

ConstructorTemplate

A constructor: the template form of new T(), new T(1, 2), new T(p = 1) or new a.b().

ExpressionTemplate

Base class of the immutable expression-template values.

FeatureChainExpressionTemplate

A feature chain read as a value: the template form of a.b or x.e.c.

FeatureChainTemplate

A feature chain a.b: the template form of naming a feature by joining two or more features, each a feature of the previous one’s type.

FunctionReferenceTemplate

A function named as an argument after ->: the RealFunctions::'+' of s->reduce RealFunctions::'+'.

InfinityTemplate

The unbounded literal: the template form of *.

InvocationTemplate

A function invocation: the template form of f(a, b) or f(x=a, y=b).

LiteralTemplate

A literal value: the template form of 3, 4.5, "a", true.

MetadataAccessTemplate

The metadata of a model element: the template form of a.metadata.

MultiplicityTemplate

A multiplicity [lower..upper] or [upper]: the template form of the bracketed clause of a feature declaration, built by bounds().

NullTemplate

The null expression: the template form of null (and of ()).

OperationTemplate

An operator application: the template form of 2 * 3, -x or if c ? a else b.

ReferenceTemplate

A reference to a model element: the template form of = x.

SelectTemplate

A selection, s.?{in i; i > 0}: the values of source for which body is true.

TriggerTemplate

A time or change trigger, at <time>, after <delay> or when <condition>, built by at(), after() and when().

TypeOperationTemplate

An operator whose last operand is a type: the template form of x istype T, x hastype T, x @ T, x as T, q @@ M, q meta M and all T.

Attributes

Functions

decode

Decode an expression element into the template describing it.

decode_multiplicity

Decode a MultiplicityRange into the bounds() template that writes it.

decode_trigger

Decode a TriggerInvocationExpression: the inverse of instantiate_trigger().

instantiate

Instantiate template as the feature_value of feature.

instantiate_argument

Instantiate template as the expression held directly in slot.

instantiate_member

Instantiate template as a new member of body, owned by a membership.

instantiate_multiplicity

Instantiate template as the multiplicity held in slot.

instantiate_trigger

Instantiate template as the feature_value of feature.

after

Return the trigger after <delay>: accept once the duration delay has passed, after(op("[", 5, s)) for after 5 [s].

arrow

Return the template for the arrow invocation <source>->function(...).

as_template

Convert a template-valued argument to an ExpressionTemplate.

at

Return the trigger at <time>: accept once the time instant time is reached.

body

Return the template for the body {in <parameters>; <result>}.

bounds

Return the template for the multiplicity [first] or [first..second].

call

Return the template invoking function on the given arguments.

chain

Return the template for the feature chain first.second (and on through rest).

collect

Return the template for the collection <source>.<body>.

connector_end

Return the template for one connector end, [<multiplicity>] <name> ::> <feature>.

dot

Return the template reading the feature chain source.feature (and on through rest).

function_ref

Return the template naming function as the argument of an arrow invocation.

literal

Return the template for the Python primitive value.

metadata_of

Return the template for the metadata of the model element element.

new

Return the template for the constructor new <type>(...).

op

Return the template applying KerML operator to operands.

parameter

Return the template for the body parameter in <name> : <type>.

ref

Return the template referencing the model element element.

select

Return the template for the selection <source>.?<body>.

sequence

Return the template for the sequence (first, second, ...).

when

Return the trigger when <condition>: accept once condition becomes true.


Attributes

INFINITY: syside.experimental.expressions.InfinityTemplate = None
NULL: syside.experimental.expressions.NullTemplate = None
SUPPORTED_OPERATORS: frozenset[str] = None

Functions

decode(expression: syside.Element) → syside.experimental.expressions.ExpressionTemplate

Decode an expression element into the template describing it.

Handles what both the parser and instantiate() produce: the four literal kinds, NullExpression, LiteralInfinity, FeatureReferenceExpression, OperatorExpression over an operator in SUPPORTED_OPERATORS (its IndexExpression subclass included), SelectExpression and CollectExpression over a body of one parameter and one result expression, FeatureChainExpression, InvocationExpression and MetadataAccessExpression, a body (a

FeatureReferenceExpression owning an Expression of parameters and one result expression) and the operators with a type operand. A reference to a

body’s parameter decodes as the parameter() that declares it. Anything else raises UndecodableExpression.

The operand walk uses OperatorExpression.operands, which contracts the ParameterMembership -> synthetic Feature -> FeatureValue chain the parser puts between an operator expression and each of its arguments. A body operand (_WRAPPED_OPERANDS) is unwrapped from its FeatureReferenceExpression; where the parser writes it as a plain argument (_PARSER_PLAIN_OPERANDS), the plain form decodes alike.

Kind tests go through the core’s own checked cast, try_cast, which returns the cast element or None.

param expression:

The expression element to decode.

returns:

The template describing expression.

raises UndecodableExpression:

If no template describes expression.

decode_multiplicity(multiplicity: syside.MultiplicityRange) → syside.experimental.expressions.MultiplicityTemplate

Decode a MultiplicityRange into the bounds() template that writes it.

Parameters:

multiplicity – The multiplicity to read, as declared_multiplicity returns it.

Returns:

The multiplicity’s template.

Raises:

UndecodableExpression – If the range has no bounds expression, or a bound is not an integer literal, * or a feature reference.

decode_trigger(expression: syside.Expression) → syside.experimental.expressions.TriggerTemplate

Decode a TriggerInvocationExpression: the inverse of instantiate_trigger().

The one argument’s value is the time or the delay; for when it is the body wrapping the condition, read through the wrapper. A parsed when writes the same wrapper.

Parameters:

expression – The payload parameter’s value.

Returns:

The TriggerTemplate describing it.

Raises:

UndecodableExpression – If expression is no trigger invocation, or its argument has a shape no template describes.

instantiate(feature: syside.Feature, template: syside.experimental.expressions.ExpressionTemplate) → syside.Expression

Instantiate template as the feature_value of feature.

Fresh model elements are created on every call: a template is a value, not a model fragment, so instantiating one twice yields two independent subgraphs. Any existing feature value is replaced.

Parameters:
  • feature – The feature whose feature_value is written.

  • template – The expression template to instantiate.

Returns:

The newly created top-level expression element.

instantiate_argument(slot: syside.experimental.expressions.ArgumentSlot, template: syside.experimental.expressions.ExpressionTemplate) → syside.Expression

Instantiate template as the expression held directly in slot.

Some expression positions of the abstract syntax hold the expression itself rather than a parameter feature carrying it as a value: the condition of an if or while, an until clause, a transition’s guard, an analysis case’s result expression (ArgumentSlot lists the slots). This is instantiate() for those slots. Fresh model elements are created on every call; any expression already in the slot is replaced.

Parameters:
  • slot – The expression-parameter slot to write.

  • template – The expression template to instantiate.

Returns:

The newly created top-level expression element.

instantiate_member(body: syside.NamespaceBody, membership: type[syside.experimental.expressions.MembershipT], template: syside.experimental.expressions.ExpressionTemplate) → tuple[syside.experimental.expressions.MembershipT, syside.Expression]

Instantiate template as a new member of body, owned by a membership.

Some body members of the abstract syntax are a membership owning an expression directly, with no feature between them: a package’s filter member is one. This is instantiate() for those positions. Fresh model elements are created on every call, and the membership is appended after any the body already holds.

The membership kind is passed as a class rather than derived, because the created expression’s kind comes from template and the pair must be created in one call.

Parameters:
  • body – The children of the element to add the member to.

  • membership – The membership element-kind to create.

  • template – The expression template to instantiate as its member.

Returns:

The new membership and the newly created top-level expression.

instantiate_multiplicity(slot: syside.OwnedMultiplicityAccessor, template: syside.experimental.expressions.MultiplicityTemplate) → syside.MultiplicityRange

Instantiate template as the multiplicity held in slot.

Creates the MultiplicityRange and its bounds expression: a .. operator expression over the two bounds, or the one bound alone – what the core parses [1..*] and [4] to. Fresh model elements are created on every call; any multiplicity already in the slot is replaced.

Parameters:
  • slot – The feature’s declared_multiplicity_member.

  • template – The multiplicity, built by bounds().

Returns:

The newly created MultiplicityRange.

instantiate_trigger(feature: syside.Feature, template: syside.experimental.expressions.TriggerTemplate) → syside.TriggerInvocationExpression

Instantiate template as the feature_value of feature.

The value is the TriggerInvocationExpression an accept action’s payload parameter holds for accept at <time>, after <delay> or when <condition>. Its one argument is a ParameterMembership -> Feature -> FeatureValue, as any argument’s; a when argument’s value is the body SysML 2.1 validateTriggerInvocationExpressionWhenArgument requires (the grammar’s ArgumentExpressionMember): a FeatureReferenceExpression owning the condition, as _append_branch() writes a branch. Fresh model elements are created on every call; any existing feature value is replaced.

Parameters:
  • feature – The payload parameter whose feature_value is written.

  • template – The trigger, built by at(), after() or when().

Returns:

The created TriggerInvocationExpression.

after(delay: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.TriggerTemplate

Return the trigger after <delay>: accept once the duration delay has passed, after(op("[", 5, s)) for after 5 [s].

SysML 2.1 validateTriggerInvocationExpressionAfterArgument requires the argument’s result to be a Quantities::ScalarQuantityValue with a duration unit, which no literal is (after 5 has no unit), so a literal is refused here rather than built.

Parameters:

delay – The duration, in any form as_template() accepts.

Returns:

The TriggerTemplate.

Raises:

ValueError – If delay is a literal.

arrow(source: syside.experimental.expressions.ExpressionLike, function: syside.Type, *arguments: syside.experimental.expressions.ExpressionLike | syside.experimental.expressions.FunctionReferenceTemplate, **named: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.ArrowInvocationTemplate

Return the template for the arrow invocation <source>->function(...).

arrow(s, f, b) is s->f(b), arrow(s, f, y=b) is s->f(y = b), arrow(s, collect_fn, body(i, result=i + 1)) is s->collect {in i; i + 1} and arrow(s, reduce_fn, function_ref(g)) is s->reduce g. source is the invocation’s first argument, given before the arrow (KerML 7.4.9.3); the others bind the remaining input parameters as in call(), either positionally or by name.

Parameters:
  • source – The first argument, canonicalized with as_template().

  • function – The invoked type.

  • arguments – The arguments after the function, canonicalized likewise, or one function_ref().

  • named – The named arguments, keyed by input-parameter name.

Returns:

The ArrowInvocationTemplate.

Raises:
  • TypeError – If function is not a syside.Type.

  • ValueError – If both positional and named arguments follow the function, a function_ref() is not the sole argument, or a keyword names no input parameter of function.

as_template(value: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.ExpressionTemplate

Convert a template-valued argument to an ExpressionTemplate.

A template is returned unchanged, a bare model element becomes ref(), a Python primitive becomes literal(), and a feature chain becomes dot() from a reference to its first feature. Every function taking a ExpressionLike applies this first, so the forms are interchangeable at a call site and build the same model.

Parameters:

value – A template, a bare model element, a Python primitive, or a feature chain.

Returns:

The equivalent ExpressionTemplate.

Raises:

TypeError – If value is of no accepted type.

at(time: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.TriggerTemplate

Return the trigger at <time>: accept once the time instant time is reached.

SysML 2.1 validateTriggerInvocationExpressionAtArgument requires the argument’s result to conform to Time::TimeInstantValue, which no literal does, so a literal is refused here rather than built.

Parameters:

time – The time instant, in any form as_template() accepts.

Returns:

The TriggerTemplate.

Raises:

ValueError – If time is a literal.

body(*parameters: syside.experimental.expressions.BodyParameterTemplate, result: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.BodyTemplate

Return the template for the body {in <parameters>; <result>}.

Instantiating it creates the parameters, in order, then the result expression, in which each parameter() references the parameter of the nearest enclosing body declaring its name. A name no enclosing body declares raises TypeError at instantiation, not here: the enclosing bodies are known only then.

Parameters:
  • parameters – The body’s in parameters, built by parameter().

  • result – The result expression, canonicalized with as_template().

Returns:

The BodyTemplate, an expression wherever one is accepted, and the body select() and collect() take.

Raises:
  • TypeError – If a parameter is not a BodyParameterTemplate.

  • ValueError – If two parameters have one name.

bounds(first: syside.experimental.expressions.BoundLike, second: syside.experimental.expressions.BoundLike | None = ...) → syside.experimental.expressions.MultiplicityTemplate

Return the template for the multiplicity [first] or [first..second].

bounds(4) is [4], bounds(INFINITY) is [*], bounds(1, INFINITY) is [1..*] and bounds(0, n) is [0..n]. One bound is the upper bound, as in the textual syntax. Each bound is canonicalized to a template here, so the result compares equal to what syside.experimental.query.get_multiplicity reads back.

Parameters:
  • first – The lower bound, or the only bound.

  • second – The upper bound, or None for the one-bound form.

Returns:

The MultiplicityTemplate over the canonicalized bounds.

Raises:
  • TypeError – If a bound is not an int, a syside.Feature, INFINITY, or a literal or reference template of one.

  • ValueError – If an integer bound is negative.

call(function: syside.Type, *arguments: syside.experimental.expressions.ExpressionLike, **named: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.InvocationTemplate

Return the template invoking function on the given arguments.

Positional arguments bind the function’s input parameters in order, as f(a, b) does; keyword arguments name them, as f(x=a, y=b) does, and are resolved here against function’s input parameters (inputs). The textual syntax has one form or the other, so mixing them is refused.

Parameters:
  • function – The invoked type, a calculation definition or another syside.Type with input parameters.

  • arguments – The positional arguments, canonicalized with as_template().

  • named – The named arguments, keyed by input-parameter name and canonicalized likewise.

Returns:

The InvocationTemplate for the call.

Raises:
  • TypeError – If function is not a syside.Type.

  • ValueError – If both positional and named arguments are given, or a keyword names no input parameter of function (the message lists the parameters it has).

chain(first: syside.Feature, second: syside.Feature, *rest: syside.Feature) → syside.experimental.expressions.FeatureChainTemplate

Return the template for the feature chain first.second (and on through rest).

Two features are the least a chain has, which the signature enforces: a chain of one would be the feature itself, and is passed as such.

Parameters:
  • first – The feature the chain starts from.

  • second – A feature of first’s type.

  • rest – Further features, each of the previous one’s type.

Returns:

The FeatureChainTemplate over the features, in order.

Raises:

TypeError – If an argument is not a syside.Feature.

collect(source: syside.experimental.expressions.ExpressionLike, body: syside.experimental.expressions.BodyTemplate) → syside.experimental.expressions.CollectTemplate

Return the template for the collection <source>.<body>.

collect(s, body(i, result=i + 1)) is s.{in i; i + 1}: the body’s result for each value of s.

Parameters:
  • source – The sequence collected over, canonicalized with as_template().

  • body – The expression evaluated per value, built by body(), with one parameter.

Returns:

The CollectTemplate.

Raises:
  • TypeError – If body is not a BodyTemplate.

  • ValueError – If body has other than one parameter.

connector_end(feature: syside.Feature, *, multiplicity: syside.experimental.expressions.MultiplicityTemplate | None = ..., name: str | None = ...) → syside.experimental.expressions.ConnectorEndTemplate

Return the template for one connector end, [<multiplicity>] <name> ::> <feature>.

connector_end(a) is a and connector_end(a, multiplicity=bounds(1), name="e1") is [1] e1 ::> a. A list of them is an n-ary connector’s ends=: connect (a, b, d).

Parameters:
  • feature – The feature the end references. It keeps its own owner.

  • multiplicity – The end’s multiplicity, built by bounds().

  • name – The end’s declared name.

Returns:

The ConnectorEndTemplate.

Raises:

TypeError – If feature is not a syside.Feature, multiplicity not a MultiplicityTemplate, or name not a str.

dot(source: syside.experimental.expressions.ExpressionLike, feature: syside.Feature, *rest: syside.Feature) → syside.experimental.expressions.FeatureChainExpressionTemplate

Return the template reading the feature chain source.feature (and on through rest).

dot(a, b) is a.b; dot(a, e, c) is a.e.c. The source is any expression, canonicalized with as_template(); the path is one or more features, each a feature of the previous one’s type.

Parameters:
  • source – The expression the path starts from.

  • feature – The first feature followed from it.

  • rest – Further features along the path.

Returns:

The FeatureChainExpressionTemplate for the chain.

Raises:

TypeError – If a path entry is not a syside.Feature.

function_ref(function: syside.experimental.expressions.FunctionKind) → syside.experimental.expressions.FunctionReferenceTemplate

Return the template naming function as the argument of an arrow invocation.

arrow(s, reduce, function_ref(plus)) is s->reduce RealFunctions::'+': the argument evaluates an anonymous expression typed by function.

Parameters:

function – The function named.

Returns:

The FunctionReferenceTemplate, accepted by arrow() as its sole argument.

Raises:

TypeError – If function is not a FunctionKind.

literal(value: syside.experimental.expressions.LiteralValue) → syside.experimental.expressions.LiteralTemplate

Return the template for the Python primitive value.

bool, int, float and str are accepted; they instantiate as LiteralBoolean, LiteralInteger, LiteralRational and LiteralString respectively.

Parameters:

value – The Python primitive to wrap.

Returns:

The LiteralTemplate carrying value.

Raises:

TypeError – If value is of any other type.

metadata_of(element: syside.Element) → syside.experimental.expressions.MetadataAccessTemplate

Return the template for the metadata of the model element element.

Instantiating it produces a MetadataAccessExpression naming the element, which is what a.metadata parses to.

Parameters:

element – The model element whose metadata is accessed.

Returns:

The MetadataAccessTemplate naming element.

Raises:

TypeError – If element is not a syside.Element.

new(type: syside.Classifier | syside.Feature | syside.experimental.expressions.FeatureChainTemplate, *arguments: syside.experimental.expressions.ExpressionLike, **named: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.ConstructorTemplate

Return the template for the constructor new <type>(...).

new(T) is new T(), new(T, 1) is new T(1), new(T, p=1) is new T(p = 1) and new(chain(a, b)) is new a.b(). It evaluates to one new instance of type (KerML 7.4.9.4). Positional arguments bind the type’s public features in order, owned features first; keyword arguments name them, resolved here against the features of type (of the chain’s last feature for a chain). The textual syntax has one form or the other, so mixing them is refused.

Parameters:
  • type – The instantiated classifier or feature, or a feature chain.

  • arguments – The positional arguments, canonicalized with as_template().

  • named – The named arguments, keyed by feature name and canonicalized likewise.

Returns:

The ConstructorTemplate.

Raises:
  • TypeError – If type is no classifier, feature or feature chain.

  • ValueError – If both positional and named arguments are given, or a keyword names no feature of type (the message lists the features it has).

op(operator: syside.experimental.expressions.TypeAloneOperator, type_: syside.Type, /) → syside.experimental.expressions.TypeOperationTemplate

Return the template applying KerML operator to operands.

Only the operators in SUPPORTED_OPERATORS are accepted, each with the operand count the grammar has for it, so an unsupported operator or a wrong operand count fails here rather than producing an expression subgraph that cannot be read back. The operands are in textual order: op("if", c, a, b) is if c ? a else b, and op("-", x) is the unary -x.

The operators whose last operand is a type build a TypeOperationTemplate: op("istype", x, T) is x istype T, op("istype", T) is istype T (self istype T, KerML 7.4.9.2; also hastype and @), op("as", x, T) is x as T, op("all", T) is all T, and op("@@", q, M) and op("meta", q, M) are q @@ M and q meta M, whose first operand is the element whose metadata is tested, a syside.Element or its metadata_of().

Parameters:
  • operator – The operator’s surface string (e.g. "*", "and", "if", "istype").

  • operands – The operands, canonicalized with as_template(), so plain literals and bare elements may be passed directly; a type operand is passed as the syside.Type itself.

Returns:

The OperationTemplate applying operator, or the TypeOperationTemplate for an operator with a type operand.

Raises:
  • ValueError – If operator is unsupported (the message names the accepted set) or if the operand count is not one the operator admits.

  • TypeError – If a type operand is not a syside.Type, or the first operand of @@ or meta is not a syside.Element or a MetadataAccessTemplate.

op(operator: syside.experimental.expressions.OperandAndTypeOperator, operand: syside.experimental.expressions.ExpressionLike, type_: syside.Type, /) → syside.experimental.expressions.TypeOperationTemplate
op(operator: syside.experimental.expressions.MetadataOperator, element: syside.Element | syside.experimental.expressions.MetadataAccessTemplate, type_: syside.Type, /) → syside.experimental.expressions.TypeOperationTemplate
op(operator: syside.experimental.expressions.PlainOperator, *operands: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.OperationTemplate
op(operator: str, *operands: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.OperationTemplate | syside.experimental.expressions.TypeOperationTemplate
parameter(name: str, type: syside.Type | None = ...) → syside.experimental.expressions.BodyParameterTemplate

Return the template for the body parameter in <name> : <type>.

The one value serves both roles the name has in the text: passed to body() it declares the parameter, and inside the body’s result it references it, so i = parameter("i", Integer) then body(i, result=i > 0) is {in i : Integer; i > 0}.

Parameters:
  • name – The parameter’s name.

  • type – The parameter’s type, or None for an untyped parameter.

Returns:

The BodyParameterTemplate.

Raises:
  • TypeError – If name is not a str or type is neither a syside.Type nor None.

  • ValueError – If name is empty.

ref(element: syside.Element) → syside.experimental.expressions.ReferenceTemplate

Return the template referencing the model element element.

Instantiating it produces a FeatureReferenceExpression naming the element, which is what = x parses to.

Parameters:

element – The model element to reference.

Returns:

The ReferenceTemplate naming element.

Raises:

TypeError – If element is not a syside.Element.

select(source: syside.experimental.expressions.ExpressionLike, body: syside.experimental.expressions.BodyTemplate) → syside.experimental.expressions.SelectTemplate

Return the template for the selection <source>.?<body>.

select(s, body(i, result=i > 0)) is s.?{in i; i > 0}: the values of s for which the body is true.

Parameters:
  • source – The sequence selected from, canonicalized with as_template().

  • body – The condition, built by body(), with one parameter.

Returns:

The SelectTemplate.

Raises:
  • TypeError – If body is not a BodyTemplate.

  • ValueError – If body has other than one parameter.

sequence(first: syside.experimental.expressions.ExpressionLike, second: syside.experimental.expressions.ExpressionLike, *rest: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.OperationTemplate

Return the template for the sequence (first, second, ...).

A sequence is the , operator over two or more items, which is what the signature enforces: a sequence of one is the item itself, and () is the null expression, which no template describes. sequence(a, b, c) is op(",", a, b, c).

Parameters:
  • first – The first item, canonicalized with as_template().

  • second – The second item, likewise.

  • rest – Further items.

Returns:

The OperationTemplate applying ,.

when(condition: syside.experimental.expressions.ExpressionLike) → syside.experimental.expressions.TriggerTemplate

Return the trigger when <condition>: accept once condition becomes true.

SysML 2.1 validateTriggerInvocationExpressionWhenArgument requires the argument to be a Boolean-valued expression. Instantiation writes it as the body the constraint asks for (a FeatureReferenceExpression to an expression whose result is condition); pass the condition itself. A literal other than True or False is refused here rather than built.

Parameters:

condition – The Boolean condition, in any form as_template() accepts.

Returns:

The TriggerTemplate.

Raises:

ValueError – If condition is a literal that is not a bool.