Visual Specification and Parsing of a Statechart ... - Semantic Scholar

8 downloads 0 Views 52KB Size Report
superH subH incl. subP in. superP. = = Figure 2. A statechart alphabet. An alphabet poses some requirements on instances as, for example, link edges must be ...
Visual Specification and Parsing of a Statechart Variant using G EN GE D



Roswitha Bardohl and Claudia Ermel Department of Computer Science, Technical University of Berlin, Germany Email: frosi,[email protected] 1. Introduction In this paper we consider a simple kind of the statechart language which is supported by the CASE tool Rhapsody. This kind of statecharts is already modeled in [4] using graph transformation. In accordance to [4], we allow hierarchical composition (sub-states and super-states) and parallel composition (combination of states by conjunction). A sample statechart is shown by Figure 1. It models the behavior of a blower with High and Low ventilation mode and three different temperature modes. Important is the fact that transitions of the following kinds are not permitted: (1) transitions between states of different statecharts which are not nested inside each other (e.g. a transition from Low to Warm or from Standby to Cool), (2) transitions between a state and one of its super-states (e.g. a transition from Low to its super-state On or from Standby to NotOn), (3) transitions which enter sub-diagrams of parallel states (e.g. a transition from NotOn to High). On

NotOn on

Standby on

High up

off Off

down

Low

off plus

Warm

plus

minus minus Hot Cool

Figure 1. A sample statechart. In the following we show how to use G EN GE D [1] for the visual specification and (high-level) parsing of this statechart language. We briefly introduce the G EN GE D concepts and present some simple editing rules, however, the conditions mentioned above are not taken into account by these rules. In order to check the conditions we define a further parse grammar. The corresponding parsing algorithm is based on contextual layered graph transformation proposed in [4] and in [5]. However, in [4] low-level parsing (scanning) and high-level parsing is introduced: low Research is partially supported by the German Research Council (DFG), the TMR network GETGRATS, and the ESPRIT Basic Research Working Group APPLIGRAPH.

level parsing is used to build up a high-level abstract syntax graph; the resulting graph is then checked according to a high-level parse grammar. In G EN GE D we offer editing rules for building up high-level graphs such that low-level parsing is not regarded.

2. The G EN GE D Approach In G EN GE D, a visual language (VL) is defined by an alphabet and a grammar [1]. An alphabet establishes a type system for symbols and links, i.e. it defines the vocabulary of a VL. Figure 2 illustrates the symbols and links of our statechart vocabulary. The abstract syntax of symbols is represented by (graph) vertices, that of links by (graph) edges between vertices. We used the abbreviations S for State, SC for Statechart, P for Parallel, H for Hierarchy, and T for Transition. Note that we omit attribute symbols like a state name as well as we do not consider initial nor final state markings due to space limitations. The concrete syntax of symbols and links is given by graphics (defining vertex attributes) and by graphical constraints (for each edge, illustrated by dotted lines and arrows) between the corresponding symbol graphics. The graphics denoted by PH describe placeholder symbols which are non-visible rectangles. Such non-visible graphics are needed according to the visual definition approach of G EN GE D. incl

(PH)

overlap

H

Abstract Syntax

superH subH s S t

T =

superP in

P subP SC

incl =

(PH)

Figure 2. A statechart alphabet. An alphabet poses some requirements on instances as, for example, link edges must be defined [1]. An instance is given by the statechart of Figure 1; its high-level abstract syntax graph illustrated by Figure 3 satisfies the requirements. Figure 3 shows the high-level abstract syntax graph

of the statechart in Figure 1; the requirements are satisfied. The abstract syntax graph is built up by editing rules which are modeled as graph rules. in

in

SC

in

S t

S in superH superH s H H subH subH t S S s t T t s T

T

superP superP

T

P s

subP SC in

in S s

t S T

subP SC in in S s S t S s t T T t s t s T T in

T t

P

s

Figure 3. Sample abstract syntax graph. Editing rules (and parse rules of a parse grammar) are represented by graph rules consisting of a left and a righthand side (L ! R) over typed graphs. Parts of both rule sides are related to each others. The related parts are preserved during a graph transformation. All non-related graph objects of L are deleted, all non-related objects of R are created. Moreover, a rule may contain a set of negative application conditions (NACs) specifying exactly those fractions of matching situations that must not exist for a rule to be applicable. As we will show, NACS are used in parse rules; they are not needed in the (languagegenerated) editing rules shown in Figure 4. InsertState L 1:SC

Initial Graph SC

InsertHierarchy L 1:SC in 2:S

1:SC in 2:S R

R

1:SC in 2:S superH H subH S in

InsertParallelState L 1:SC in 2:S

superP 3:P subP SC 1:SC in 2:S superP 4:P subP SC

R

graphical constraints: 3:P.ne = 4:P.nw; 3:P.se = 4:P.sw; 2:S.nw = 3:P.nw; 2:S.se = 4:P.se;

ExtendParallelState L superP subP 1:SC

in

2:S

3:P

1:SC

SC

in

superP 2:S superP

3:P subP SC 4:P

subP

R SC

graphical constraints: 3:P.ne = 4:P.nw; 3:P.se = 4:P.sw; 2:S.nw = 3:P.nw; 2:S.se = 4:P.se;

InsertTransition L in 1:SC

2:S

3:SC

in

4:S

1:SC

in

R s T t 3:SC in 4:S

2:S

Figure 4. Language-generating editing operations.

The editing rules shown in Figure 4 are used to build up abstract syntax graphs needed for high-level parsing: based on an initial graph, it is possible to insert states into one statechart (rule InsertState), and then to insert substates (rule InsertHierarchy). A state can be defined to be a parallel state (rule InsertParallelState); thereby, two substatecharts are generated. Moreover, a parallel state can be extended by further sub-statecharts (rule ExtendParallelState). It is obvious that transition symbols are inserted arbitrarily into a diagram by applying the rule InsertTransition. This means, it is not clear whether the inserted transition is allowed or not. Therefore, we introduce a parse grammar which is a contextual layered graph grammar (CLGG). In general, CLGGs combine layered graph grammars [7] and conditions for rules like NACs. Thus, critical pair analysis is available to optimize the parsing process. The parse grammar for our statechart variant is shown by Figure 5. It is derived from the high-level grammar proposed in [4] and [5]. Hence, also the NACs are drawn dashed, and we use complex edge predicates for the deletion of transitions. Furthermore, the stop graph contains a single statechart symbol (SC-vertex). As our abstract syntax allows to distinguish hierarchical composition (vertex H) from parallel composition (vertex P), we use this distinction also in our parse grammar. We omit the concrete syntax level because the parser needs the abstract syntax only. Nevertheless, the parse grammar can be defined using the visual means of the VL given by the alphabet. In the parsing process, transitions have to be treated at first. Rules 1–3 deal with their deletion in different contexts. Hence, these rules belong to layer 1, i.e. they have be applied before the rules 4–7 from layer 2 (deletion of states and statecharts which might be composed hierarchically or parallel) are applied. The rules 2 and 3 from layer 1 ensure the satisfaction of our conditions 1–3 from Section 1. The complex edge predicate superH+ in the two NACs of rule 2 mean that these edges may be mapped to a path in the host superH superH subH    superH H . H ! S graph of the form S The predicate superP+ in rule 3 analogously stands for a superP subP P path of the form S ! SC in S superP

   superP

P . Rule 2 ensures condition 1 and 3 because the in edges of two states belonging to different, not nested statecharts aim at different SC vertices. Thus, the rule cannot be applied to the (forbidden) case of a transition between two such states. The NACs of rule 2 ensure condition 2 as the rule cannot be applied to a transition between states with hierarchy vertices in-between (i.e. states at different levels of a hierarchical composition). Rule 3 is not applicable to a transition between states belonging to parallel statecharts (condition 3 for the case of parallel states).

1: Delete transition loop L s in 1:SC

2:S

T

t

in

1:SC

2: Delete transition in hierarchy L 1:SC in

superH+ subH t

H T

3:S

3: Delete transition between non-parallel states superP+ superP L P S P subP

subP 1:SC in 3:S

s

2:SC in 4:S

t

T

4: Delete sub-state in hierarchy L S in 1:SC in 2:S subH

in

in

2:S

3:S

1:SC

2:SC

in 3:S

in 4:S

in

1:SC

4:SC

R

2:S

R

6: Delete parallel state (more than two parallel states) L 1:S 2:P subP

R

superH

H

5: Delete state in parallel composition L S 1:SC in 1:SC

superP

R

1:SC

in

subH superH+ s

2:S

R

2:S

superP 3:P subP 5:SC

superP

SC

subP

R

superP 3:P

2:P

P subP

1:S

superP

subP

4:SC

5:SC

7: Delete parallel states (exactly more than two parallel states) L 1:S superP

superP P

superP

P subP SC

subP SC

subP SC

P

R 1:S

Figure 5. Parse grammar.

3. Conclusion In this paper we have proposed the visual specification of a combination of syntax-directed and free-hand editing (based on parse rules) for a statechart variant. We defined conditions for transitions in our notion of statecharts and illustrated their realization by a contextual layered parse graph grammar. This kind of parsing facilities have been recently integrated in the A GG environment [6]. Because in G EN GE D the transformation of the abstract syntax is done by AGG, i.e., G EN GE D uses AGG, parsing is now available in G EN GE D [3]. Concerning simulation and animation of visual process models like statecharts (or Petri nets [2]), an extension of the G EN GE D environment is just being under consideration. We use graph rewrite rules of the same type as the syntax rules described in this paper to specify the operational semantics of a visual process model. Active states should be modeled by marking them, e.g. by loop edges in statecharts as in [5]. (In our notion of statecharts as presented in this paper, we do not yet include symbols and

concrete layout for the marking of active states.) The lefthand side of a behavior rule then contains a part of a model before a transition is taking place, and the right-hand side of the rule contains the transformed model part (e.g. the statechart with changed marking loops). The application of behavior rules simulates the statechart behavior. Work is in progress to extend G EN GE D in order to define different concrete layouts for the same abstract syntax of a VL diagram. Thus, the behavior of a statechart on the one hand could be modeled as the change of marking loops at state nodes. On the other hand, defining a new concrete layout for states and transitions, the behavior should be visualized in a more domain-oriented layout which hides the underlying structure of the formal statechart model. This approach towards animation of visual process models has been described for Petri nets in [2], and we plan also to apply it to statecharts.

References [1] R. Bardohl. Visual Definition of Visual Languages based on Algebraic Graph Transformation. PhD thesis, TU Berlin, 1999. Verlag Dr. Kovac, 2000. [2] R. Bardohl, C. Ermel, and H. Ehrig. Generic Description, Behaviour and Animation of Visual Modeling Languages. In Proc. Integrated Design and Process Technology (IDPT’2000), USA, June 2000. [3] R. Bardohl, T. Schultzke, and G. Taentzer. Visual Language Parsing in G EN GE D. In Proc. 2nd International Workshop on Graph Transformation and Visual Modeling Techniques (GT-VMT’01), 2001. [4] P. Bottoni, A. Sch¨urr, and G. Taentzer. Efficient Parsing of Visual Languages based on Critical Pair Analysis and Contextual Layered Graph Transformation. Si2000-06, University of Rom, 2000. [5] P. Bottoni and G. Taentzer. Parsing and Semantics of a Statechart Variant by Contextual Layered Graph Transformation. Special Session at Visual Languages and Formal Methods (VLFM’01), 2001. [6] C. Ermel, M. Rudolf, and G. Taentzer. The AGGApproach: Language and Tool Environment. In H. Ehrig, G. Engels, J.-J. Kreowski, and G. Rozenberg, editors, Handbook of Graph Grammars and Computing by Graph Transformation, Volume 2: Applications, Languages and Tools, pages 551–604. World Scientific, 1999. [7] J. Rekers and A. Sch¨urr. Defining and Parsing Visual Languages with Layered Graph Grammars. Journal of Visual Languages and Computing, 8(1):27–55, 1997.

Suggest Documents