Capítulo 2. Marco Teórico
2.3 Perfil y prácticas del director exitoso
on t1te recognition of a rule's right-hand side, rather than predicting the organization and then verifying it by trying to match the right-hand side at the predicted location.
We now consider recognizing flow graphs i the less restrictive formalism in which there still are no aggregate port types on terminal nodes, but the type Any is a nion type of aggregate and non-aggregate types. Recognition involves a special-case simplification of compositions of residual Makes (or Spreads) with the nested Spreads (or Makes) that are
"inserted" dring reduction. Recall that to perform partial recognition, in which parts of an aggregate port type used in the input graph are ignored, we need to "break up" te residual Spreads (or Makes) so that recognizable portions of the flow graph are separated from -unrecognizable portions.
This is simulated in the state of the parser, using operations on the location pointers of items. Residual Spreads and Makes are removed from the iput flow graph. They are replaced with fan-out and fan-'in, respectively.
(As is discussed in Section 42.3, some of the information found in residual Spreads and Makes is useful for generating documentation about which data structure cliche's were found in a program and how their parts relate to user-defined structures' parts. This information is placed in attributes on the fan-out or fan-in edges that replace a Spread or Make.)
In the combination operation, a -nested tuple of location pointers "inserted" during reduction of a rule's right-hand side may be compared with a flat, unordered set of location pointers, representing the fan-ont or fan-in edges that replaced a residual Make or Spread.
The combination is valid if for each Est L of location pointers in the fringe of the tree formed by the nested tuple, at least one location ointer in L is a member of the flat set of location pointers. Not all of the pointers in the flat set of location pointers need to be members of some list of location pointers within the nested tuple.
For example, the input flow graph generated from the example of Figure 328 is sown in Figure 338. In creating a complete item representing the recognition of S, the flat set of location pointers representing the residual Spread, 2 3 4 51, is compared with te tuple of location pointers, < 23 > representing the aggregation of types x and y into A's input port type P. (See Figure 3-38b.) Likewise, the tuple < 6 7 > is compared with the flat set of pointers 6 7 8 9. Both comparisons succeed.
2 6
1 10
(a)
1 10
v 2:v M+ 10 v 9 2:P h :v
, 45} <2,3> <6,7> 16,7,8,91
0
(b)
Figure 338: Simulating the break up of residual Spreads ad Makes.
of non-terminals that are connected to A at ports I and 3 in the partial item's rule. The constraint requires that these adjacent non-terminals be located at edpoints of the same edge. The st-thru essentially imposes a constraint that the non-terminals connected to A at ports and 3 be connected to each other. (See Figure 340.)
St-thrus differ based on whether or not they are structurally constrained and whether or not they are optional. A st-thru is structurally constrained if the embedding relation restricts it to matching edges that fan out (or in) with edges coming into (or out of) an isomorphic occurrence of a right-hand side. In other words, a st-thru is constrained if one or both of the two corresponding left-hand side ports also correspond to some right-hand side port.
Structurally unconstrained st-thrus are not restricted in this way. They exist when two left-hand side ports correspond to each other and no other right-hand side port. These types of st-thrus often arise when a right-hand side with Spreads and Makes is translated to a non-aggregated right-hand side. If te otput of a boundary Spread connects directly to an input of a boundary Make and neither port connects any other ports, a structurally unconstrained st-thru arises.
We refer to structurally constrained st-thrus as simply "constrained" st-thrus (and struc-turally unconstrained ones as "unconstrained"), with the understanding that this is refer-ring only to structural constraints. Most st-thrus including unconstrained ones, have non-structural constraints (in the form of attribute conditions) imposed upon them by their
114
(C p
Figure 339: Grammar containing a rule with a st-thru.
0...4
I;--- I -
-IIII
i
i 0
I 00 1I
-0.(
1+ 000
II...
Actual constraint:
...
---'6 ...
Figure 340: Constraint on combination imposed by st-thrus.
115
(C p
M* 1 A4 D
(u.,x)
M* Do
p 8
0 00
-0.(
m+011is.
0*#.
- Mh---i
rule.
Constrained and unconstrained st-thrus are both matched to a set of edges, which is then narrowed down, based on the context in which its rule's right-hand side is reduced to its left-hand side. An unconstrained st-thru iitially matches the set of all edges, while the constrained st-thru. matches the subset of edges that satisfy the restrictions imposed by the embedding relation. These sets of matching edges are shrunk as non-structural constraints are checked and the reduction of higher-level non-terminals in the parse tree occurs.
For example, suppose a Circular Indexed Sequence Insert and a Circular Indexed Se-quence Extract non-terminal were recognized in the input graph, as sown in Figure 341.
When the locations of the Insert and Extract non-terminals are compared during combina-tion, the location pointer tples are compared element-by-element. The First part of te output of CIS Insert represents an unconstrained st-thru and is initially matched to all edges (shown pictorially by a wild-card *). During combination, this First part is matched with the Frst part of the input to the CIS Extract instance. This arrows down its matching set of edges to those indicated by location pointers 10 and 13. The Size part of the CIS Insert output also comes straight through CIS Insert's right-1-tand side, but because it fans out with te iput to MOD, it is constrained to be matched to a small number of edges (those 'indicated by location pointers and 6.
Global constraints represented by the st-thru are imposed by propagating reductions in sets of matching edges across non-terminals and across edges. For example, once the item for CIS Extract extends the partial item of Figure 341, the wild-card matches can be reduced to a small set of matches. Figure 342 shows the result of propagation of st-thru match reduction. Now CIS Extract's output constrains the location of its Last part (to location 9 restricting the location at which the second CIS Insert should be found.
Constrained ad unconstrained st-thrus can additionally be described as either optional or required. Required st-thrus must be assigned a match, while optional st-thrus need not.
Optional st-thrus are useful in the program recognition domain, where it is often the case that there is no edge matching a st-thru. This occurs if no operation makes use of the data represented by the st-thru. For example, the edge indicated by the location pointer 8 in Figure 341 might not exist if no operation foRowing the CIS Extract uses the Base part of the output CIS. St-thrus representing data structure parts are optional. An example of a required st-thru 'is that of the rule representing the Negate-if-Negative implementation of the Absolute Value cliche'. (See Figure 39.)
The only difference this designation makes is in what it means if the reduction of sets of matching edges results 'in a empty set of possible matches. If the st-thru 'is required, this empty set means the recognition of the rule's left-hand side failed. Otherwise the set of possible matches of an optional st-thru can become empty without causing the recognition t o fail.
116
<B, , L, S, C> <B, , L, S, FC>
14 <(17,18),*,9,(5,6),2> <(17,18),(10,13),*,(5,6),2> 19
ert rac
<16,*,(15,7),(4,5,6),I> <18,12,* 3>
1 <B, , L, S, FC> I I <Bl , L, S, FC> I
lb-11
It, 11I
2
IIs
.1
Partial item:
a ...
1
II NI.,
Is
.01-
ol
<16,*,(15,7),(4,-"' 1
6...
---Complete Items for non-terminals found in input graph:
See Next Figure
4%
,;p *4
0 I
0
I I
1 -.0
i-.
0 0
0* 14 lb
q,
11
3 No
5
117
Input Graph
Figure 341: Constrained and unconstrained st-thrus.
:...
I I
SS
11-0, II
<16,*,(15,7),(41
1 i
'L ... :
<B, , L, S, FC>
<17,18),(10,13),*,(5,6),2> 19
- Ex rac
<18,12,* 3>
<B, , L, S, FC>
d...
0 4
9 14 <17,18),(10,13), I,0 a
"Is
II., 0 ( 6 I .
af N
A 9I
11-11
,Q),z;
IN
110 19 a
MD..;
n
.01, < I Zs, I Z,9,:),i > -,
< 16,(10,13),(15,7),(4,5,6), 1 > 11,
...
Compare Sort Derivations:
<17,18), *, 9,(5,6),2>
1 1 1 1 1
<17,18),(10,13),*)(5,6))2>
Resulting partial item. Notice that the location pointers have been propagated to replace the wild-cards.
Figure 342: Propagating matches of st-thrus.
118