Ad/2010-08-01 Concrete Syntax for a uml action Language for Foundational uml (Alf) Second Revised Submission



Download 1.74 Mb.
Page11/62
Date28.01.2017
Size1.74 Mb.
#9041
1   ...   7   8   9   10   11   12   13   14   ...   62

7.8Punctuation


The tokens below are considered to be punctuation.

NOTE. Some tokens below are made up of two symbols that may themselves individually be tokens. Nevertheless, the two-symbol token is not considered a combination of the individual symbol tokens. For example, “::” is considered a single token, not a combination of two “:” tokens. Input characters are grouped from left to right to form the longest possible sequence of characters to be grouped into a single token. Thus “a:::b” would analyzed into four tokens: “a”, “::”, “:” and “b”.

Grammar

Punctuation


= "(" | ")" | "{" | "}" | "[" | "]" | ";" | "," | "." | ":"
| ".." | "::" | "=>" | "->"

7.9Operators


The tokens below are considered to be operators.

Grammar

Operator


= "=" | ">" | "<" | "!" | "~" | "?" | "@" | "$"
| "==" | "<=" | ">=" | "!=" | "&&" | "||" | "++" | "--"
| "+" | "-" | "*" | "/" | "&" | "|" | "^" | "%"
| "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^=" | "%="
| "<<" | ">>" | ">>>" | "<<=" | ">>=" | ">>>="

8Expressions


An expression is a behavioral unit that evaluates to a (possibly empty) collection of values. Expressions may also have side effects, such as changing the value of an attribute of an object.

The full conformance level includes all kinds of expressions specified in this clause. However, the minimum conformance level only requires a subset of the full expression syntax. Therefore, in each of the concrete syntax grammar productions given in the subclauses of this clause, some portion of the production may be italicized. Only the italicized portions apply at the minimum conformance level. Unitalicized portions may be ignored for minimum conformance. (See also Subclause 2.1 on the definition of syntactic conformance.)


8.1Overview


This subclause describes the top-level syntax and semantics for expressions. The next level categorization of expressions syntactically is into conditional-test expressions (see Subclause 8.7) and assignment expressions (see Subclause 8.8). However, in the subclauses following this subclause, expressions are described in a traditional “bottom up” fashion, starting with the simplest forms of expressions and working back up to conditional-test and assignment expressions.

Syntax

Expression(e: Expression)
= ConditionalExpression(e)
| AssignmentExpression(e)


Figure 8 2 Base Abstract Syntax for Expressions



Cross References

  1. Syntax Element see Subclause 6.5

  2. ConditionalExpression see Subclause 8.7

  3. AssignmentExpression see Subclause 8.8

Semantics

Integration with UML

An Alf expression can be inserted into a UML model using an opaque expression (UML Specification, Subclause 7.3.35) in which the unprocessed text of the Alf expression is used as the body of the opaque expression and the corresponding language string is "Alf". Opaque expressions are kinds of value specifications (UML Specification, Subclause 7.3.54). Thus, an Alf expression may be used in a UML model any place that a value specification is allowed.

In addition, a special form of initialization expression may be for instance creation and sequence construction expressions acting as the specification of default values of properties or parameters. In such initialization expressions, an explicit description of the type of the expression does not need to be included, as is the case for normal instance creation and sequence construction expressions, since this can be inferred from the declared type of the property or parameter. (Instance creation expressions are described in Subclause 8.3.12 and sequence construction expressions are described in Subclause 8.3.15. The use of their special forms in initialization descriptions within Alf is discussed for local name declaration statements in Subclause 9.6 and for property initialization in Subclause 10.5.2.)

The execution semantics of an Alf expression are given formally by the mapping to UML activity graphs given in the following subclauses. An Alf expression can therefore always be compiled to a part or all of a UML activity model (which does not necessarily need to be the same as the formal mapping, but must have an equivalent effect to it—see Subclause 2.2). If the expression appears as part of a statement, then the compilation of the expression will be part of the compilation of the statement (see Clause 9). Otherwise, the compilation of the expression may be inserted as an activity that is the associated behavior of a corresponding opaque expression (see UML Superstructure 13.3.21) that is constructed as follows:


  • A single return parameter of the type of the Alf expression.

  • The activity nodes and edges resulting from the compilation of the Alf expression (semantically equivalent to the formal mapping as specified in the following subclauses).

  • A single activity parameter node associated with the return parameter, which becomes the target of an outgoing object flow from the result source element from the mapping of the Alf expression (see the definition of “result source element” given under Mapping below).

Indeed, the semantics of an opaque expression that only includes unprocessed Alf text in its body may be considered equivalent to an opaque expression with an associated behavior constructed strictly according to the formal fUML mapping for the Alf expression.

NOTE. Opaque expressions are not included at all in fUML, so the execution of such an expression, even one with a behavior conformant to the Alf subset, is still not fully defined within by the fUML standard.

    An expression either has a statically determined type or can be statically determined to be untyped. All values resulting from evaluation of the expression will be of the type of the expression, if it has one. If the expression is untyped, then the result values may have any type. For simplicity of terminology in this clause, an untyped expression will be referred to as having “type any”.

    An expression also has a statically determined multiplicity. The number of values resulting from the evaluation of the expression will be no smaller than the multiplicity lower bound and no higher than the multiplicity upper bound (or unbounded if the upper bound is the unbounded value “*”).



Local Names and Assigned Sources

The evaluation of an expression may depend on the values assigned to local names used in the expression. Local names are used in Alf to denote intermediate values in computations within a statement sequence (see Subclause 9.1). Alf is designed so, on the surface, local names can be assigned and reassigned in a similar way to variables in more traditional programming languages. However, the underlying fUML metamodel for actions and activities is fundamentally based on data flow, not on an implicit underlying store of variables. Therefore, the assignments of and references to local names in an Alf input text need to be mapped to appropriate object flow edges from the mapping of the appropriate assignment to the mapping of the reference that requires that assigned value.

Carrying out this mapping requires an analysis of the set of local names that are statically known to have assigned values during the execution of any Alf statement. The assigned source for a local name is the syntax element that, when executed, will provide the actual assigned value for that local name. If the assigned source for a local name is known, then a reference to the assigned value of that local name can be mapped to an object flow from the mapping of the assigned source. (See also the discussion of local names relative to statements in Clause 9.)

Since a local name may also be defined or reassigned within an expression, one can refer to the assignments (i.e., the statically determined assigned sources) for local names both before and after the evaluation of an expression. Most kinds of expressions do not actually themselves change the assigned source of a name. An assignment expression (see Subclause 8.8) is, of course, the main kind of expression that changes the assigned source for a name. However, invocation expressions (see Subclause 8.3.7) may assign names via out and inout parameters. Increment and decrement expressions also act as assignments (see Subclause 8.4).

Other than the kinds of expressions listed above, the only way that an assigned source may change in an expression is if it contains one of the above kinds of expression, directly or indirectly, as a subexpression. Unless otherwise stated, it can be assumed that the assigned source of a name before any subexpression of an expression is the same as the assigned source before the expression.

Further, in general, it is only legal to assign a name in at most one subexpression of any expression. Therefore, unless otherwise stated, the assigned source for a name after an expression is the same as after any subexpression. Specific assignment rules for various kinds of expressions are described in their respective subclauses.



NOTE. The above rule allows most subexpressions to be evaluated concurrently.


Download 1.74 Mb.

Share with your friends:
1   ...   7   8   9   10   11   12   13   14   ...   62




The database is protected by copyright ©ininet.org 2024
send message

    Main page