diff --git a/test/manual-suite.spt b/test/manual-suite.spt index 860fe9c..b3edad2 100644 --- a/test/manual-suite.spt +++ b/test/manual-suite.spt @@ -161,3 +161,42 @@ test sec6_2_dnf_exercise_ex [[ p = q ]] run better-dnf to Or(And(Not(Atom("p")),Not(Atom("q"))), And(Atom("q"),Atom("p"))) + +/** md +### Chapter 7 + +The content and style of chapter 7 are similar to chapter 6. Again, there is a +`trans/chap7.str` Stratego file defining several of the rules used in the examples +from the chapter. As before, the examples with a different signature are recast +into the SPL signature. Specifically, `Z` becomes `False`, `S(x)` becomes +`Impl(True(), x)`, and `P` becomes `Or`. +**/ + +test sec7_2_b_ex [[ + (1 -> 0) | 0 +]] run B to Or(False(), Impl(True(), False())) + +test sec7_2_b_a_ex [[ + (1 -> 0) | 0 +]] run BthenA to Impl(True(), False()) + +test sec7_2_b_b_fails [[ + (1 -> 0) | 0 +]] run Btwice fails + +test sec7_2_local_choice_fails [[ + (1 -> 0) | 0 +]] run maybeB-id-thenB fails + +test sec7_2_seq_no_dist_over_choice_ex [[ + (1 -> 0) | 0 +]] run maybeBtwice-idthenB to Or(False(), Impl(True(), False())) + +test sec7_3_repeat_small_ex [[ + (1 -> 0) | 0 +]] run repeatmaybeAB to Impl(True(), False()) + +test sec7_3_repeat_big_ex [[ + (1 -> (1 -> (1 -> (1 -> 0)))) | 0 +]] run repeatmaybeAB to Impl(True(), Impl(True(), Impl(True(), + Impl(True(), False())))) diff --git a/trans/chap7.str b/trans/chap7.str new file mode 100644 index 0000000..367b679 --- /dev/null +++ b/trans/chap7.str @@ -0,0 +1,15 @@ +module chap7 +imports libstrategolib signatures/- + +rules + + A : Or(False(), x) -> x + B : Or(Impl(True(),x), y) -> Or(x, Impl(True(), y)) + +strategies + + BthenA = B; A + Btwice = B; B + maybeB-id-thenB = (B <+ id); B + maybeBtwice-idthenB = Btwice <+ (id; B) + repeatmaybeAB = repeat(A <+ B) diff --git a/trans/spoofax_propositional_language.str b/trans/spoofax_propositional_language.str index c6d03a3..4ddeb43 100644 --- a/trans/spoofax_propositional_language.str +++ b/trans/spoofax_propositional_language.str @@ -14,6 +14,7 @@ imports prop-eval2 prop-desugar chap6 + chap7 rules // Debugging