I have finally got round to implementing the proposed new implementations for IFMATCH and FILL in WSL.
The old versions had two serious problems:
VAR < B := < >, S1 ;= < >, S2 := < > >: IFMATCH Statement IF ~?B THEN ~*S1 ELSE ~*S2 FI THEN... ELSE... ENDMATCH ENDVAR
The new syntax is as follows:
Types are: @One_Pattern_Type?, @Many_Pattern_Type?, @Any_Pattern_Type?, @One_Int_Type?, @Any_Int_Type?, @One_Var_Type?, @Any_Var_Type?
Examples:
S := FILL Statement v := ~?(e) ENDFILL
Names for the types are T_Cond_Int_One and T_Cond_Val_One ie: T_{Stat,Expn,Cond,Defn,Lvalue,Assign,Guarded,Action}_{Int,Val}_{One,Any} plus T_Name_Int_One and T_Name_Val_One
IFMATCH Statement DO ~*S; ~*=S OD
will match against any DO loop whose body consists of a duplicated sequence of statements, eg:
DO x := x + 1; IF x > 3 THEN EXIT(1) FI; x := x + 1; IF x > 3 THEN EXIT(1) FI OD
IFMATCH Statement IF ~?B THEN ~*S ELSE ~*(S) FI THEN ... ELSE ... ENDMATCH
will match any binary IF statement whose ELSE body is given in the global variable S, while:
IFMATCH Statement IF ~?B THEN ~*S ELSE ~*=S FI THEN ... ELSE ... ENDMATCH
will match any IF statement whose ELSE body is the same as the THEN body.
Note: matches are "loose" with respect to Lvalues and Expressions, so that we can match an Lvalue against an Expression etc.
For example: IFMATCH Statement ~?v := ~?=v THEN ... ENDMATCH will match when the current statement is an assign or assignment statement whose LHS and RHS are the same.