6.5Abstract Syntax
The abstract syntax for Alf is a UML class model of the tree of objects synthesized from parsing an Alf text (as described above in Subclause 6.4). The Alf concrete syntax is context free and parsing based on this syntax results in a strictly hierarchical parse tree. The synthesized abstract syntax tree is an abstraction of the complete parse tree—for example, punctuation symbols are not included in the abstract syntax tree—but it is still a hierarchical tree structure.
Figure 6 1 Top-Level Syntax Element Classes
The nodes of an abstract syntax tree are objects known as syntax elements. Every syntax element class descends from the root abstract class SyntaxElement. Figure 6 -1 shows this root class and its top-level descendents. Note that certain of the classes shown in Figure 6 -1 are subclasses of the intermediate DocumentedElement class. These classes represent elements that may be annotated with documentation comments (see Subclause 7.4.2) that are preserved in the ultimate fUML model, as opposed to lexical comments (see Subclause 7.4.1), which are not so preserved.
While the abstract syntax tree synthesized from parsing an Alf text is strictly hierarchical, there are important non-hierarchical relationships and constraints between Alf elements that may be determined solely from static analysis of the abstract syntax tree. Such static semantic analysis is also common in the processing of a typical programming language, particularly for resolving names and type checking. However, the analysis for Alf is somewhat different than for the typical case, since it is used to gather additional information required for mapping to fUML, rather than generating machine code as in the case of a programming language.
6.6Mapping to Foundational UML
The final step in the processing of an Alf input text is the mapping of the abstract syntax tree for the text, completed with derived property values from static semantic analysis, to a representation in terms of the fUML abstract syntax; that is, as interrelated instances of the abstract syntax metaclasses specified in Clause 7 of the fUML Specification. The fUML abstract syntax representation can be built via a generally depth-first traversal of the Alf abstract syntax tree, with the static semantic information providing non-hierarchical relationships across the tree structure.
Concurrency
Most mainstream programming languages are based on an inherently sequential model of computation. Statements are executed sequentially, argument expressions are evaluated in lexical order, etc. In many cases, however, such specifically fined-grained sequential execution (especially in expressions) is entirely inessential to the computation being carried out and unnecessarily restricts the options for how the computation can be implemented. This has become a problem, for example, in implementing such languages in a way that takes advantage of the increasing amount of parallelism available in mainstream hardware platforms.
On the other hand, the execution semantics for activities in fUML are inherently concurrent. In general, the semantics of UML activities place no restriction on the concurrent execution of nodes within the activity, other than that imposed by the explicit object and control flows between those nodes, and the Alf mapping to fUML takes advantage of this concurrency in many places, particularly in the mapping of expressions. For example, the argument expressions in an operation invocation or an arithmetic expression are evaluated concurrently, rather than sequentially.
However, as noted in fUML Specification, Subclause 8.5.2.1 (under the Threading Model heading), the concurrency in the fUML semantics “does not require the implementation of actual parallelism in a conforming execution tool. It simply means that such parallelism is allowed and that the execution semantics provide no further restriction on the serialization of execution across concurrent [computations].”
Correspondingly, any place in the description of the Alf semantics that computations are specified to be concurrent, this should be understood to simply mean that there is no requirement that they be carried out in any particular sequential order. If desired, though, a conformant tool may still carry out the computations completely sequentially, in any desired order. Or it may actually carry out some or all of the computations in parallel, either virtually (e.g., in separate threads) or physically (on separate processors).
6.7Organization of the Specification
This Alf specification document is organized into five parts.
The first part comprises the initial clauses, through Clause 6. These clauses contain introductory material and an overview of how the Alf language is defined.
The second part contains a complete description of the Alf language. Clause 7 defines the lexical structure for Alf, which specifies how lexical analysis is to be carried out for an Alf input text. Clauses 8 through 10 provide the core description of Alf constructs in the syntactic areas of expressions, statements and units. Within these clauses, the subclause for each construct formally defines its concrete syntax and the synthesis of the abstract syntax from that. Each subclause also includes examples of the use of the construct and an informal description of the semantics of the construct. Clause 11 defines a standard model library that must be provided with any Alf implementation. This library includes the fUML Foundational Model Library (see Clause 9 of the fUML Specification) plus additional primitive types and primitive behaviors. It also includes a set of collection classes and the profile used in attaching Alf text to the models to which that text was mapped.
The third part provides the complete definition of the abstract syntax of Alf, including the formal specification of the static semantics for Alf in terms of additional derived properties and constraints. Each of the four clauses in this part correspond a package in the top-level decomposition of the Alf abstract syntax model.
The fourth part gives the formal mapping of the abstract syntax, as annotated during static semantic analysis, to the fUML subset of the UML abstract syntax. The four clauses in this part also correspond to the abstract syntax packages.
The fifth part comprises the annexes, all of which are informative, not normative. Annex A discusses the integration of Alf execution semantics with the non-fUML execution semantics of state machine and composite structure models. Annex B provides a number of extended examples of the use of Alf. Annex C provides a grammar for all of Alf, in a form better suited to automated processing than the productions used in the main body of the specification, which are intended for clarity of presentation rather than processing.
Share with your friends: |