This example, uses a propagation which specifies a simple traversal directive and has no return value. As always, the first step is to have a class dictionary, here we use the same cd.cd as in the class dictionary examples:
C = "club" <head> A.
A = "has" <members> MemberList [<suba> SubAList].
MemberList ~ "members" "(" Member {Member} ")".
Member : Regular|Officer *common* <salary> Salary.
Regular = "regular" <r> DemIdent.
Officer = "officer" <o> DemIdent.
Salary = "salary" <s> DemReal.
SubAList ~ "subs" "(" {SubA} ")".
SubA : Whole|Partial *common* <a> A.
Whole = "whole" <w> DemString.
Partial = "partial" <p> DemString.
This propagation pattern specifies a traversal directive which starts from the class C and goes to the class Officer. There is no return value void and a line of C++ code is executed when the directive reaches Officer, which prints the officers name.
*operation* void officer_list()
*traverse*
*from* C *bypassing* -> SubA,a,A *to* Officer
*wrapper* Officer
*suffix* (@ cout << "Officer "<< this -> get_o() << endl; @)
The demeter-input file used is also the same as the one used in the class dictionary case:
club has members
( regular Fred salary 35.15
officer Simon salary 225.00
officer Allison salary 279.12 )
subs ( whole "demeter" has members
( regular Mark salary 42.97
officer Matt salary 122.10 )
partial "isthmus" has members
( regular Doug salary 44.52
officer Laura salary 214.84
officer Phil salary 257.32 )
)
Then, since main.tcl is almost all automatically generated, and will look exactlly like the one created in the class dictionary example, the only section which is included here is the part which may be modified by the user:
#------------------------------------ #Your code follows after this #------------------------------------ # Here is the call to the propagation pattern puts "Propagation Pattern Output" $nC officer_list: #------------------------------------
This is the output which is produced by typing run, edited, so that the only output given below is the output which is actually generated by the call to the propagation pattern:
Propagation Pattern Output
>> void C::officer_list(), "1-DEM.C", line 9
>> void A::officer_list(), "1-DEM.C", line 31
>> void MemberList::officer_list(), "1-DEM.C", line 51
>> void Member::officer_list(), "1-DEM.C", line 79
>> at Regular , *** PREMATURELY TERMINATED *** , "1-DEM.C", line 81
<< at Regular , *** PREMATURELY TERMINATED *** , "1-DEM.C", line 81
<< void Member::officer_list(), "1-DEM.C", line 79
>> void Officer::officer_list(), "1-DEM.C", line 90
Officer Simon
<< void Officer::officer_list(), "1-DEM.C", line 90
>> void Officer::officer_list(), "1-DEM.C", line 90
Officer Allison
<< void Officer::officer_list(), "1-DEM.C", line 90
<< void MemberList::officer_list(), "1-DEM.C", line 51
<< void A::officer_list(), "1-DEM.C", line 31
<< void C::officer_list(), "1-DEM.C", line 9