Part 4: RSDL Formal Definition
4.3 Static Semantics
4.3.9 Expression
4.3.9.1 Expression
Abstract Syntax
Expression = Constant-expression
| Active-expression
Constant-expression = Literal
| Operation-application
Active-expression = Variable-access
| Operation-application
| Imperative-expression
Imperative-expression = Now-expression
| Pid-expression
| Timer-active-expression
Please note, that the above definition could be simplified. This can be done by omitting the difference between active expressions and constant expressions. This difference does not show up at any place, so it could be simply dropped. It is provided here as is to preserve the similarity to the SDL definition.
Concrete Syntax
<constant expression> = <constant<expression>
<expression> = <operand>
<operand> = <operand0> | <operand gen operand>
<operand gen operand> :: <operand> <operand0> /* => */
<operand0> = <operand1> | <operand0 gen operand0>
<operand0 gen operand0> :: <operand0> {or | xor} <operand1>
<operand1> = <operand2> | <operand1 gen operand1>
<operand1 gen operand1> :: <operand1> <operand2> /* and */
<operand2> = <operand3> | <operand2 gen operand2>
<operand2 gen operand2> :: <operand2>
{ <greater than sign> | <greater than or equals sign> | <less than sign>
| <less than or equals sign> | <equals sign> | <not equals sign> } <operand3>
<operand3> = <operand4> | <operand3 gen operand3>
<operand3 gen operand3> :: <operand3> { <plus sign> | <hyphen> } <operand4>
<operand4> = <operand5> | <operand4 gen operand4>
<operand4 gen operand4> ::
<operand4> { <asterisk> | <solidus> | mod } <operand5>
<operand5> :: [ <hyphen> | not ] <primary>
<primary> =
<operation application>
/* | <literal> this is disabled because it is subsumed by <variable access> */
| <primary gen expression>
| <active primary>
<primary gen expression> :: <expression>
<active primary> = <variable access> | <imperative expression>
<imperative expression> =
<now expression> | <pid expression> | <timer active expression>
Transformations
<operand gen operand>(x, y) =3=> <operation application>(“=>”, <x, y>)
<operand0 gen operand0>(x, or, y) =3=> <operation application>(“or”, <x, y>)
<operand0 gen operand0>(x, xor, y) =3=> <operation application>(“xor”, <x, y>)
<operand1 gen operand1>(x, y) =3=> <operation application>(“and”, <x, y>)
<operand2 gen operand2>(x,<greater than sign>, y) =3=> <operation application>(“>”, <x, y>)
<operand2 gen operand2>(x,<greater than or equals sign>, y)
=3=> <operation application>(“>=”, <x, y>)
<operand2 gen operand2>(x,<less than sign>, y) =3=> <operation application>(“<”, <x, y>)
<operand2 gen operand2>(x,<less than or equals sign>, y)
=3=> <operation application>(“<=”, <x, y>)
<operand2 gen operand2>(x,<equals sign>, y) =3=> <operation application>(“=”, <x, y>)
<operand2 gen operand2>(x,<not equals sign>, y) =3=> <operation application>(“/=”, <x, y>)
<operand3 gen operand3>(x,<plus sign>, y) =3=> <operation application>(“+”, <x, y>)
<operand3 gen operand3>(x,<hyphen>, y) =3=> <operation application>(“-”, <x, y>)
<operand4 gen operand4>(x,<asterisk>, y) =3=> <operation application>(“*”, <x, y>)
<operand4 gen operand4>(x,<solidus>, y) =3=> <operation application>(“/”, <x, y>)
<operand4 gen operand4>(x, mod, y) =3=> <operation application>(“mod”, <x, y>)
<operand5>(<hyphen>, x) =3=> <operation application>(“-”, <x>)
<operand5>(not, x) =3=> <operation application>(“not”, <x>) An expression of the form
<expression> <infix operation name> <expression>
is derived syntax for
<infix operation name> ( <expression>, <expression> )
where <infix operation name> represents an Operation-name although the name would not be valid concrete syntax.
Similarly,
<monadic operation name> <expression>
is derived syntax for
<monadic operation name> ( <expression> )
where <monadic operation name> represents an Operation-name.
Mapping to Abstract Syntax
| <primary gen expression>(x) => Mapping(x)
| <operand5>(undefined, x) => Mapping(x)
The mappings above are used for those expression constructors that do not get transformed away. After the transformation only the two constructors above remain.
4.3.9.2 Literal
Abstract Syntax
Literal :: Literal-name
Conditions on Abstract Syntax
∀l ∈ Literal: l.s-Literal-name.s-TOKEN.isPredefLiteral Any literal must be a predefined literal.
Concrete Syntax
The concrete syntax of <literal> is subsumed within <variable access> (Section 4.3.9.4) and will be distinguished in the mapping of <identifier> (Section 4.3.2.2).
4.3.9.3 Operation Application
Abstract Syntax
Operation-application :: Operation-name Expression+
Conditions on Abstract Syntax
∀ o ∈ Operation-application: isPredefOperation(o.s-Name.s-TOKEN) ∧
< e.exprSort.s-TOKEN | e in o.s-Expression-seq > ∈ correctTypes(o.s-Name.s-TOKEN) The operation application must refer to a predefined operator and the argument types must be correct.
Concrete Syntax
<operation application> :: <operator<name> <expression list>
<expression list> = <expression>+
Mapping to Abstract Syntax
| <operation application>(name, params) =>
mk-Operation-application(Mapping(name), Mapping(params))
4.3.9.4 Variable Access
Abstract Syntax
Variable-access = Variable-identifier Concrete Syntax
<variable access> = <variable<identifier>
Conditions on Concrete Syntax
∀ v ∈ <identifier>: v.parentAS0 ∈ <operand5> ⇒ v.s-<identifier>.refersto0 ∈ <variable definition>
A variable access must refer to a variable.
Mapping to Abstract Syntax
This is already defined with the mapping of <identifier>.
4.3.9.5 Now Expression
Abstract Syntax
Now-expression :: ()
Concrete Syntax
<now expression> = now Mapping to Abstract Syntax
| now => mk-Now-expression()
4.3.9.6 Pid Expression
Abstract Syntax
Pid-expression = Self-expression
| Parent-expression
| Offspring-expression
| Sender-expression
Self-expression :: ()
Parent-expression :: ()
Offspring-expression :: ()
Sender-expression :: ()
Concrete Syntax
<pid expression> = self
| parent | offspring | sender
Mapping to Abstract Syntax
| self => mk-Self-expression()
| parent => mk-Parent-expression()
| offspring => mk-Offspring-expression()
| sender => mk-Sender-expression()
4.3.9.7 Timer Active Expression
Abstract Syntax
Timer-active-expression :: Timer-identifier Concrete Syntax
<timer active expression> :: <timer<identifier>
Conditions on Concrete Syntax
∀ t ∈ <timer active expression>: t.s-<identifier>.refersto0 ∈ <timer definition>
An identifier in a timer active expression must refer to a timer definition.
Mapping to Abstract Syntax
| <timer active expression>(id) => mk-Timer-active-expression(Mapping(id))
This following closing keyword of the case expression completes the definition of the mapping function.
endcase