If Then
Stratego -- Strategies for Program Transformation
Syntax
"if" Strategy "then" Strategy "end" -> Strategy
Description
The strategy
if s1 then s2 end
applies
s2
if
s1
succeeds. The result of
s1
is ignored. That is, if the condition
<s1> t
succeeds, then the result of
<if s1 then s2 end> t
is
<s2> t
On the other hand, if the condition fails, then the result is
t
.
Formatting
The if-then construct is usually formatted in the following way:
if s1 then
s2
end
Implementation
The if-then construct is sugar for a guarded left-choice. The strategy
if s1 then s2 end
translates into
where(s1) < s2 + id