
"SIGOURE" == SIGOURE Benoit <sigoure.benoit@lrde.epita.fr> writes:
AddZero: - Plus(e, Int("0")) -> e + |[ e + 0 ]| -> |[ e ]|
Cool !
EvalPlus: - Plus(Int(i), Int(j)) -> Int(<addS>(i, j)) - EvalPlus: - Plus(Double(i), Int(j)) -> Double(<addR>(i, j)) - EvalPlus: - Plus(Int(i), Double(j)) -> Double(<addR>(i, j)) - EvalPlus: - Plus(Double(i), Double(j)) -> Double(<addR>(i, j)) + |[ d1 + d2 ]| -> |[ r ]| where <addR>(d1, d2) => r
Très cool.
Index: src/str/reals.str --- src/str/reals.str (revision 0) +++ src/str/reals.str (revision 0) @@ -0,0 +1,27 @@ +module reals + +strategies + + // for some reason the following rules are only defined for integers + // in the stratego-lib. Here is their equivalant for reals.
equivalent. Emacs dispose de correction orthographique des chaînes et des commentaires, je suppose de vim aussi.
+ addR = (string-to-real, string-to-real); addr; real-to-string + subtR = (string-to-real, string-to-real); subtr; real-to-string + mulR = (string-to-real, string-to-real); mulr; real-to-string + divR = (string-to-real, string-to-real); divr; real-to-string + gtR = where((string-to-real, string-to-real); gtr) + geqR = where((string-to-real, string-to-real); ?(x,x) <+ gtr) + ltR = where((string-to-real, string-to-real); not(?(x,x) <+ gtr)) + leqR = where((string-to-real, string-to-real); not(gtr))
Pourquoi des where dans la seconde partie ?
+ /** + ** tests whether two reals are equal + ** => tests if there difference is less than 10^-7 + ** operates on the input term (a, b) + ** eg: <real-eq> ("0.42", "0.43") -> fail + */
Ce sont des commentaires xDoc ça ?