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


ABSTRACT SYNTAX 12Common Abstract Syntax



Download 1.74 Mb.
Page35/62
Date28.01.2017
Size1.74 Mb.
#9041
1   ...   31   32   33   34   35   36   37   38   ...   62

ABSTRACT SYNTAX

12Common Abstract Syntax


Parsing an Alf text synthesizes an abstract syntax tree (see Subclause 6.4). Static semantic analysis then adds associated with the syntax elements in the abstract syntax tree (see Subclause 6.5). Such information is formally specified using derived attributes and associations in the UML abstract syntax model. Thus, a syntax element class will generally have two kinds of properties: synthesized properties, whose values are determined during parsing, and derived properties, whose values are determined during static semantic analysis. The specification for each derived property includes a constraint that defines its derivation.

In addition, the specification of a syntax class includes various constraints that must be checked during the course of static semantics analysis. If any of these constraints are violated, then the input text is not legal and must be rejected. The specification of the class may also include helper operations that can be used in both the class constraints and property derivations.

Clauses 8, 9 and 10 described the synthesized abstract syntax for Alf expressions, statements and units. This clause extends that abstract syntax model to include the derived properties and constraints that specify the static semantics of Alf. Clauses 16 through 19 then specify the mapping from the Alf abstract syntax, after static semantic analysis, to the fUML subset of the UML abstract syntax.

The UML model of the Alf abstract syntax is contained within the package Alf::Syntax. It comprises four subpackages: Common, Expressions, Statements and Units. The content of each of these packages is described in this and the following three clauses.


12.1Overview


The Alf::Syntax::Common package contains the root abstract classes SyntaxElement and DocumentedElement. It also contains common ElementReference and AssignedSource classes that are used throughout the rest of the abstract syntax model. Element reference and assigned source objects are not themselves syntax elements but, rather, represent certain relevant information determined during the static semantic analysis of an abstract syntax tree and associated with elements of that tree.

The mapping of common elements to UML is given in Clause 16.



Element References

As discussed in Subclauses 8.2 and 10.2, a name resolves to the model element that it names. If this model element is defined outside the context of the Alf text in which the reference to its name appears, then the resolution is straightforward. However, the situation is more complicated if the element being referenced is defined within the same Alf text as the reference itself. This is because the name must be resolved during static semantic analysis, but, at that point, the Alf representation of the element being referenced has not yet been mapped to UML.

In order to handle this in a general way, the Alf abstract syntax uses a generic concept of element reference. Such a reference may be an external element reference, meaning that it is a reference to a model element defined in the UML model external to the Alf text. Or it may be an internal element reference, meaning that it is a reference to the syntax element in the Alf text which will ultimately be mapped to the desired model element. The necessary properties of a referenced element required for static semantic analysis may be obtained from either an external or internal element reference.

Assigned Sources

As discussed in Subclauses 8.1 and 9.1, the assigned source for a local name is the statically determined 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.

During static semantic analysis, it is necessary to know what names have assigned sources before and after each expression node and each statement node within the abstract syntax tree. Information on the assigned source includes not only the source element itself, but also the statically determined type and multiplicity of the value produced by that source.



Figure 12 79 Syntax Elements



Figure 12 80 Element References



Figure 12 81 Assigned Sources


12.2Class Descriptions

12.2.1AssignedSource


An assignment of a source element that gives the value of a local name, along with a record of the defined type (if any) and multiplicity of the local name.

Generalizations

None


Synthesized Properties

  • lower : Integer

The multiplicity lower bound for the name.



  • name : String

The local name for which this is the assigned source.



  • source : SyntaxElement

The syntax element that is to be the source for the assigned value of the given local name.



  • type : ElementReference [0..1]

A reference to the element that gives the type for the local name (if any).



  • upper : UnlimitedNatural

The multiplicity upper bound for the local name.

Derived Properties

None
Constraints

None
Helper Operations

None

12.2.2DocumentedElement


A syntax element that has documentation comments associated with it.

Generalizations

  • SyntaxElement

Synthesized Properties

  • documentation : String [*]

The documentation text to be associated with a syntax element. Each string is intended to be mapped to the body of a comment element in the target UML model.

Derived Properties

None
Constraints

None
Helper Operations

None

12.2.3ElementReference


A reference to a model element, either directly or via its Alf abstract syntax representation. (NOTE: The definitions of all the helper operations of ElementReference are specific to its subclasses.)

Generalizations

None


Synthesized Properties

None
Derived Properties

None
Constraints

None
Helper Operations

None

12.2.4ExternalElementReference


A direct reference to a UML model element.

Generalizations

  • ElementReference

Synthesized Properties

  • element : Element

The referenced model element.

Derived Properties

None
Constraints

None
Helper Operations

None

12.2.5InternalElementReference


A direct reference to a UML model element.

Generalizations

  • ElementReference

Synthesized Properties

  • element : SyntaxElement

The Alf syntax element that represents the referenced model element.

Derived Properties

None
Constraints

None
Helper Operations

None

12.2.6SyntaxElement


A syntax element synthesized in an abstract syntax tree, along with any additional information determined during static semantic analysis.

Generalizations

None


Synthesized Properties

None
Derived Properties

None
Constraints

None
Helper Operations

None



Download 1.74 Mb.

Share with your friends:
1   ...   31   32   33   34   35   36   37   38   ...   62




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

    Main page