https://svn.lrde.epita.fr/svn/xrm/trunk
Index: ChangeLog
from SIGOURE Benoit <sigoure.benoit(a)lrde.epita.fr>
Extend real-eq.
* src/str/xrm-to-prism.str: Optimize traversals.
* src/str/reals.str: Extend real-eq.
reals.str | 11 ++++++-----
xrm-to-prism.str | 9 ++-------
2 files changed, 8 insertions(+), 12 deletions(-)
Index: src/str/xrm-to-prism.str
--- src/str/xrm-to-prism.str (revision 24)
+++ src/str/xrm-to-prism.str (working copy)
@@ -4,7 +4,7 @@
strategies
xrm-to-prism =
- topdown(repeat(xrm-to-prism-desugar))
+ topdown(try(xrm-to-prism-desugar))
; id // unroll static for loops here
; topdown(try(reorder-module-contents))
@@ -33,7 +33,7 @@
reorder-module-contents =
?Module(name, _)
; {| DeclarationList, CommandList:
- Module(id, map(try(fetch-module-content)))
+ Module(id, map(add-command <+ add-declaration))
; where(
bagof-DeclarationList
; ?dec-list
@@ -43,11 +43,6 @@
|}
; !Module(name, dec-list, cmd-list)
- // we're inside a Module(_, content)
- // each element is either a Command(_, _, _) or a declaration
- fetch-module-content =
- add-command <+ add-declaration
-
// if the current term is a Command, add it in the CommandList DR
add-command =
?Command(_, _, _)
Index: src/str/reals.str
--- src/str/reals.str (revision 24)
+++ src/str/reals.str (working copy)
@@ -3,7 +3,7 @@
strategies
// for some reason the following rules are only defined for integers
- // in the stratego-lib. Here is their equivalant for reals.
+ // in the stratego-lib. Here is their equivalent for reals.
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
@@ -15,13 +15,14 @@
/**
** tests whether two reals are equal
- ** => tests if there difference is less than 10^-7
+ ** => tests if there difference is less than the precision given in parameter
** operates on the input term (a, b)
- ** eg: <real-eq> ("0.42", "0.43") -> fail
+ ** eg: <real-eq(|0.00001)> ("0.42", "0.43") -> fail
*/
- real-eq =
+ real-eq(|precision) =
(string-to-real, string-to-real)
; subtr
; abs => difference
- ; <not(gtr)>(difference, 0.0000001)
+ ; <not(gtr)>(difference, precision)
+ real-eq = real-eq(|0.0000001)