
https://svn.lrde.epita.fr/svn/xrm/trunk Index: ChangeLog from SIGOURE Benoit <sigoure.benoit@lrde.epita.fr> Add constant propagation for builtins. Some C code was needed to implement easily and efficiently some operations on reals. The --pp-prism|-P option of xrm-front was removed and replaced by --add-pos|-P. The reason for this is that xrm-front takes PRISM code as input and was producing PRISM AST as output, which is a bit inconsistent. So the default is now to produce PRISM source code. addPosInfo is now only invoked with --add-pos|-P because it is very inefficient and introduces a big memory/time penalty. On big inputs it will even get killed by the system. * src/lib/xrm/Makefile.am: Remove useless include. * src/lib/Makefile.am: Ditto. * src/lib/prism/Makefile.am: Ditto. * src/syn/Makefile.am: Ditto. * src/lib/native: New. * src/lib/native/floor.c: New. * src/lib/native/libstr-reals.h: New. * src/lib/native/Makefile.am: New. * src/lib/native/ceil.c: New. * src/lib/native/power.c: New. * src/str/xrm-front.str: Change the -P option to be --add-pos. * src/str/Makefile.am: Use libstr-reals. * src/str/prism-desugar.str: Add builtins desugarisation. * src/str/reals.str: Add more new strategies using libstr-reals. * src/syn/prism/PRISM-MetaVars.sdf: Update the meta-var `a*'. * src/Makefile.am: Build the `lib' subdir before `str'. * tests/test-pp-prism.sh.in: Save the reason of the failing tests. * tests/test-xrm-front.sh.in: Ditto. * tests/test-parse-xrm.sh.in: Ditto. * tests/test-parse-prism.sh.in: Ditto. * tests/test-pp-xrm.sh.in: Ditto. * tests/xrm/desugar_builtins.pm: New. * configure.ac: Add src/lib/native/Makefile's generation. * bootstrap (svn:executable): Mark as executable. configure.ac | 3 +- src/Makefile.am | 4 +- src/lib/Makefile.am | 6 +--- src/lib/native/Makefile.am | 30 +++++++++++++++++++++ src/lib/native/ceil.c | 23 ++++++++++++++++ src/lib/native/floor.c | 22 +++++++++++++++ src/lib/native/libstr-reals.h | 41 +++++++++++++++++++++++++++++ src/lib/native/power.c | 37 ++++++++++++++++++++++++++ src/lib/prism/Makefile.am | 4 -- src/lib/xrm/Makefile.am | 4 -- src/str/Makefile.am | 9 ++++-- src/str/prism-desugar.str | 39 ++++++++++++++++++++++++++++ src/str/reals.str | 52 ++++++++++++++++++++++++++++++++++++- src/str/xrm-front.str | 54 ++++++++++++++++----------------------- src/syn/Makefile.am | 4 -- src/syn/prism/PRISM-MetaVars.sdf | 2 - tests/test-parse-prism.sh.in | 9 +++++- tests/test-parse-xrm.sh.in | 6 ++++ tests/test-pp-prism.sh.in | 12 +++++++- tests/test-pp-xrm.sh.in | 12 +++++++- tests/test-xrm-front.sh.in | 29 ++++++++++---------- tests/xrm/desugar_builtins.pm | 29 ++++++++++++++++++++ 22 files changed, 360 insertions(+), 71 deletions(-) Index: src/lib/xrm/Makefile.am --- src/lib/xrm/Makefile.am (revision 32) +++ src/lib/xrm/Makefile.am (working copy) @@ -5,9 +5,7 @@ ## Mail <sigoure.benoit@lrde.epita.fr> ## ## Started on Wed May 10 19:27:12 2006 SIGOURE Benoit -## Last update Fri May 12 05:20:11 2006 SIGOURE Benoit +## Last update Thu May 25 18:44:02 2006 SIGOURE Benoit ## -include $(top_srcdir)/config/toplevel.mk - SUBDIRS = pp Index: src/lib/native/floor.c --- src/lib/native/floor.c (revision 0) +++ src/lib/native/floor.c (revision 0) @@ -0,0 +1,22 @@ +/* +** floor.c for str-reals in /home/tsuna/work/xrm/trunk/src/lib/native +** +** Made by SIGOURE Benoit +** Mail <sigoure.benoit@lrde.epita.fr> +** +** Started on Thu May 25 16:32:59 2006 SIGOURE Benoit +** Last update Thu May 25 18:57:46 2006 SIGOURE Benoit +*/ + +#include <math.h> +#include "libstr-reals.h" + +ATerm STR_REALS_floor(ATerm t) +{ + double r; + + if(ATgetType(t) != AT_REAL && ATgetType(t) != AT_INT) + return NULL; + NUMERIC_ATERM_TO_REAL(r, t); + return (ATerm) ATmakeReal(floor(r)); +} Index: src/lib/native/libstr-reals.h --- src/lib/native/libstr-reals.h (revision 0) +++ src/lib/native/libstr-reals.h (revision 0) @@ -0,0 +1,41 @@ +/* +** libstr-reals.h for str-reals in /home/tsuna/work/xrm/trunk/src/lib/native +** +** Made by SIGOURE Benoit +** Mail <sigoure.benoit@lrde.epita.fr> +** +** Started on Thu May 25 16:32:27 2006 SIGOURE Benoit +** Last update Thu May 25 20:10:05 2006 SIGOURE Benoit +*/ + +#ifndef LIBSTR_REALS_H_ +# define LIBSTR_REALS_H_ + +# include <srts/stratego.h> + +/** +** Transform an ATerm which is either an AT_REAL or an AT_INT into a double. +** @param dst destination double (itself, not a pointer to it) +** @param term term to transform in double. +** @warning the caller MUST ensure that @a term is of type AT_REAL or AT_INT. +*/ +# define NUMERIC_ATERM_TO_REAL(dst, term) \ + do { \ + if(ATgetType(term) == AT_REAL) \ + { \ + dst = ATgetReal((ATermReal) term); \ + } \ + else /* (ATgetType(term) == AT_INT) */ \ + { \ + dst = ATgetInt((ATermInt) term); \ + } \ + } while(0) + +ATerm STR_REALS_ceil(ATerm t); +ATerm STR_REALS_floor(ATerm t); +ATerm STR_REALS_powi(ATerm base, ATerm power); +ATerm STR_REALS_powr(ATerm base, ATerm power); +ATerm STR_REALS_modi(ATerm lhs, ATerm rhs); +ATerm STR_REALS_modr(ATerm lhs, ATerm rhs); + +#endif /* !LIBSTR_REALS_H_ */ Index: src/lib/native/Makefile.am --- src/lib/native/Makefile.am (revision 0) +++ src/lib/native/Makefile.am (revision 0) @@ -0,0 +1,30 @@ +## +## Makefile.am for xrm in /home/tsuna/work/xrm/trunk/src/lib/native +## +## Made by SIGOURE Benoit +## Mail <sigoure.benoit@lrde.epita.fr> +## +## Started on Wed May 10 19:27:12 2006 SIGOURE Benoit +## Last update Thu May 25 20:19:00 2006 SIGOURE Benoit +## + +include $(top_srcdir)/config/toplevel.mk + +lib_LTLIBRARIES = libstr-reals.la +include_HEADERS = libstr-reals.h + +libstr_reals_la_SOURCES = $(include_HEADERS) \ + ceil.c \ + floor.c \ + power.c + +# FIXME: Detect in configure whether -lm needs to be used. +libstr_reals_la_LIBADD = $(SSL_LIBS) -lm + +BUILT_SOURCES = import-libstr-reals.c + +import-libstr-reals.c: Makefile + echo "/* code generated; used for strc --C-include \"'$@'\" */" > $@ + for f in $(libstr_reals_la_SOURCES); do \ + echo "#include \"$$f\"" >> $@; \ + done Index: src/lib/native/ceil.c --- src/lib/native/ceil.c (revision 0) +++ src/lib/native/ceil.c (revision 0) @@ -0,0 +1,23 @@ +/* +** ceil.c for str-reals in /home/tsuna/work/xrm/trunk/src/lib/native +** +** Made by SIGOURE Benoit +** Mail <sigoure.benoit@lrde.epita.fr> +** +** Started on Thu May 25 16:32:50 2006 SIGOURE Benoit +** Last update Thu May 25 19:19:48 2006 SIGOURE Benoit +*/ + +#include <math.h> +#include <stdio.h> +#include "libstr-reals.h" + +ATerm STR_REALS_ceil(ATerm t) +{ + double r; + + if(ATgetType(t) != AT_REAL && ATgetType(t) != AT_INT) + return NULL; + NUMERIC_ATERM_TO_REAL(r, t); + return (ATerm) ATmakeReal(ceil(r)); +} Index: src/lib/native/power.c --- src/lib/native/power.c (revision 0) +++ src/lib/native/power.c (revision 0) @@ -0,0 +1,37 @@ +/* +** power.c for str-reals in /home/tsuna/work/xrm/trunk/src/lib/native +** +** Made by SIGOURE Benoit +** Mail <sigoure.benoit@lrde.epita.fr> +** +** Started on Thu May 25 16:33:04 2006 SIGOURE Benoit +** Last update Thu May 25 20:07:23 2006 SIGOURE Benoit +*/ + +#include <math.h> +#include "libstr-reals.h" + +ATerm STR_REALS_powi(ATerm base, ATerm power) +{ + int ibase; + int ipower; + + if(ATgetType(base) != AT_INT || ATgetType(power) != AT_INT) + return NULL; + ibase = ATgetInt((ATermInt) base); + ipower = ATgetInt((ATermInt) power); + return (ATerm) ATmakeReal(pow(ibase, ipower)); +} + +ATerm STR_REALS_powr(ATerm base, ATerm power) +{ + double rbase; + double rpower; + + if((ATgetType(base) != AT_REAL && ATgetType(base) != AT_INT) || + (ATgetType(power) != AT_REAL && ATgetType(power) != AT_INT)) + return NULL; + NUMERIC_ATERM_TO_REAL(rbase, base); + NUMERIC_ATERM_TO_REAL(rpower, power); + return (ATerm) ATmakeReal(pow(rbase, rpower)); +} Index: src/lib/Makefile.am --- src/lib/Makefile.am (revision 32) +++ src/lib/Makefile.am (working copy) @@ -5,9 +5,7 @@ ## Mail <sigoure.benoit@lrde.epita.fr> ## ## Started on Wed May 10 19:27:12 2006 SIGOURE Benoit -## Last update Fri May 12 05:34:10 2006 SIGOURE Benoit +## Last update Thu May 25 18:55:45 2006 SIGOURE Benoit ## -include $(top_srcdir)/config/toplevel.mk - -SUBDIRS = prism xrm +SUBDIRS = prism xrm native Index: src/lib/prism/Makefile.am --- src/lib/prism/Makefile.am (revision 32) +++ src/lib/prism/Makefile.am (working copy) @@ -5,9 +5,7 @@ ## Mail <sigoure.benoit@lrde.epita.fr> ## ## Started on Wed May 10 19:27:12 2006 SIGOURE Benoit -## Last update Wed May 10 19:39:03 2006 SIGOURE Benoit +## Last update Thu May 25 18:43:55 2006 SIGOURE Benoit ## -include $(top_srcdir)/config/toplevel.mk - SUBDIRS = pp Index: src/str/xrm-front.str --- src/str/xrm-front.str (revision 32) +++ src/str/xrm-front.str (working copy) @@ -21,7 +21,7 @@ main-wrapped = check-options ; xtc-transform(!"parse-xrm", // parse input (returns a FILE) - !["-b", "--preserve-positions" | <pass-verbose>()]) + <concat>[ ["-b"], <pass-verbose>(), <pass-add-pos>() ]) ; read-from // read parsed input ; /*FIXME*/strip-annos // FIXME: remove this line!!!!!!!!!!!!!!!!!!!!!!!!!! ; xrm-front-pipeline // transformations @@ -29,14 +29,10 @@ ; if <get-config> "-b" then write-to // output binary ATerms else - if must-pp-prism then // output PRISM source - write-to; xtc-transform(!"pp-prism", pass-verbose) - else if must-pp-aterm then // output pp-ATerms write-to; xtc-transform(!"pp-aterm", pass-verbose) - else - write-to-text // output text ATerms - end + else // output PRISM source + write-to; xtc-transform(!"pp-prism", pass-verbose) end end @@ -53,8 +49,8 @@ // list of available options for xrm-front xrm-front-options = - pp-prism-option - + pp-aterm-option + pp-aterm-option + + add-pos-option + keep-attributes-option + desugar-option @@ -66,13 +62,6 @@ where(<set-pp-aterm> "no") ; warn-msg(|"Pretty printing cancelled: binary output requested.") end - - // it doesn't make sense: we're asked for binary output + PRISM output! - ; if must-pp-prism then - err-msg(|"Cannot generate binary output (-b) and PRISM output - (--pp-prism|-P) at the same time.") - ; <exit> 1 - end end strategies @@ -92,21 +81,6 @@ strategies - pp-prism-option = - Option("-P" + "--pp-prism" - , <set-pp-prism> "yes" - , !HelpString("-P | --pp-prism", "Convert output in PRISM source code - using pp-prism") - ) - - set-pp-prism = - <set-config> ("pp-prism", <id>) - - must-pp-prism = - <get-config> "pp-prism" => "yes" - -strategies - pp-aterm-option = Option("-A" + "--pp-aterm" , <set-pp-aterm> "yes" @@ -133,6 +107,24 @@ must-desugar = <get-config> "desugar" => "yes" +strategies + + add-pos-option = + Option("-P" + "--add-pos" + , <set-add-pos> "yes" + , !HelpString("-P | --add-pos", "When issuing error messages, tell the line + and column of the error. This is disabled by default as it + implies a big memory overhead if the input file is big.") + ) + + set-add-pos = + <set-config> ("add-pos", <id>) + + must-add-pos = + <get-config> "add-pos" => "yes" + + pass-add-pos = must-add-pos < !["--preserve-positions"] + ![] + /** * Documentation */ Index: src/str/Makefile.am --- src/str/Makefile.am (revision 32) +++ src/str/Makefile.am (working copy) @@ -5,19 +5,22 @@ ## Mail <sigoure.benoit@lrde.epita.fr> ## ## Started on Thu Apr 27 17:59:35 2006 SIGOURE Benoit -## Last update Thu May 25 17:27:20 2006 SIGOURE Benoit +## Last update Thu May 25 19:32:14 2006 SIGOURE Benoit ## include $(top_srcdir)/config/Transformers.mk -include $(wildcard *.dep) bin_PROGRAMS = xrm-front -xrm_SOURCES = xrm-front.c +xrm_front_SOURCES= xrm-front.c SCFLAGS = --main main-$* STRINCLUDES = -I $(srcdir) -I $(XTC)/share/xtc \ -I $(top_builddir)/src/sig \ - -I $(top_builddir)/src/syn/xrm + -I $(top_builddir)/src/syn/xrm \ + --C-include '"$(top_builddir)/src/lib/native/import-libstr-reals.c"' +AM_CFLAGS = -I$(top_srcdir)/src/lib/native + LDADD += $(SSL_LIBS) EXTRA_DIST = $(wildcard *.str) Index: src/str/prism-desugar.str --- src/str/prism-desugar.str (revision 32) +++ src/str/prism-desugar.str (working copy) @@ -22,6 +22,7 @@ <+ EvalPlus <+ EvalMinus <+ EvalMul <+ EvalDiv <+ EvalLt <+ EvalLtEq <+ EvalGt <+ EvalGtEq <+ EvalEq <+ EvalNeq <+ EvalAnd <+ EvalOr + <+ EvalMin <+ EvalMax <+ EvalFloor <+ EvalCeil <+ EvalPow <+ EvalMod ) ; topdown(try(SimplifyDoubles <+ TruncateDouble)) @@ -160,3 +161,41 @@ |[ false | true ]| -> |[ true ]| EvalOr: |[ false | false ]| -> |[ false ]| + +rules + + EvalMin: + |[ func(min, a*) ]| -> |[ r ]| + where !a*;debug + ; map(\ Double(d) -> d \);debug + ; minRL => r;debug + + EvalMax: + |[ func(max, a*) ]| -> |[ r ]| + where !a*;debug + ; map(\ Double(d) -> d \);debug + ; maxRL => r;debug + + EvalFloor: + |[ func(floor, d) ]| -> |[ r ]| where <floor>(d) => r + + EvalCeil: + |[ func(ceil, d) ]| -> |[ r ]| where <ceil>(d) => r + + EvalPow: + |[ func(pow, d1, d2) ]| -> |[ r ]| where <powR>(d1, d2) => r + + EvalMod: + |[ func(mod, d1, d2) ]| -> |[ r ]| + where !Double(d1) => ast_d1 + ; !Double(d2) => ast_d2 + /* ensure that d1 and d2 are in fact Int */ + ; <SimplifyDoubles> ast_d1 => Int(i) + ; <SimplifyDoubles> ast_d2 => Int(j) + ; if !j => "0" then + err-msg(|"Modulo by zero detected:") + ; debug + ; <xtc-exit> 3 + else + <modS> (i, j) => r + end Index: src/str/reals.str --- src/str/reals.str (revision 32) +++ src/str/reals.str (working copy) @@ -2,16 +2,64 @@ strategies - // for some reason the following rules are only defined for integers - // in the stratego-lib. Here is their equivalent for reals. + /* + ** for some reason the following rules are only defined for integers + ** in the stratego-lib. Here is their equivalent for reals. + */ + + maxr = gtr < Fst + Snd + minr = gtr < Snd + Fst + 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)) + maxR = where((string-to-real, string-to-real); maxr) + minR = where((string-to-real, string-to-real); minr) + + pow = powR <+ powI + + /** Let (x, y) be a tuple of reals, this strategy returns the value of x + ** raised to the power of y. + ** @type (String, String) -> String + */ + powR = (string-to-real, string-to-real); powr; real-to-string + + /** Let (x, y) be a tuple of integers, this strategy returns the value of x + ** raised to the power of y. + ** @warning the result may not be an integer (eg, if y is less than zero) + ** @type (String, String) -> String + */ + powS = (string-to-int, string-to-int); powi; real-to-string + + /** @type (Real, Real) -> Real */ + powr = ?(x, y); prim("STR_REALS_powr", x, y) + /** @type (Int, Int) -> Real */ + powi = ?(x, y); prim("STR_REALS_powi", x, y) + + ceil = string-to-real; prim("STR_REALS_ceil", <id>); real-to-string + floor = string-to-real; prim("STR_REALS_floor", <id>); real-to-string + + /** Find the min in a list of reals within strings + ** @type List(String) -> String + */ + minRL = + ?[h|t] + ; foldr(<string-to-real> h, minr, string-to-real) + ; real-to-string + + /** Find the max in a list of reals within strings + ** @type List(String) -> String + */ + maxRL = + ?[h|t] + ; foldr(<string-to-real> h, maxr, string-to-real) + ; real-to-string /** ** tests whether two reals are equal Index: src/syn/Makefile.am --- src/syn/Makefile.am (revision 32) +++ src/syn/Makefile.am (working copy) @@ -5,9 +5,7 @@ ## Mail <sigoure.benoit@lrde.epita.fr> ## ## Started on Thu Apr 27 17:40:41 2006 SIGOURE Benoit -## Last update Tue May 9 20:36:52 2006 SIGOURE Benoit +## Last update Thu May 25 18:44:17 2006 SIGOURE Benoit ## -include $(top_srcdir)/config/Transformers.mk - SUBDIRS = prism xrm Index: src/syn/prism/PRISM-MetaVars.sdf --- src/syn/prism/PRISM-MetaVars.sdf (revision 32) +++ src/syn/prism/PRISM-MetaVars.sdf (working copy) @@ -7,7 +7,7 @@ %% FIXME: The following doesn't work [xyzfgh][0-9]* "'" -> IdentifierPrime {prefer} [e][0-9]* -> Expression {prefer} - "a"[0-9]* "*" -> {Identifier ","}+ {prefer} + "a"[0-9]* "*" -> {Expression ","}+ {prefer} [m][0-9]* -> Module {prefer} "m"[0-9]* "*" -> Module+ {prefer} [c][0-9]* -> Command {prefer} Index: src/Makefile.am --- src/Makefile.am (revision 32) +++ src/Makefile.am (working copy) @@ -5,9 +5,9 @@ ## Mail <sigoure.benoit@lrde.epita.fr> ## ## Started on Thu Apr 27 16:57:03 2006 SIGOURE Benoit -## Last update Thu May 11 00:15:37 2006 SIGOURE Benoit +## Last update Thu May 25 19:05:24 2006 SIGOURE Benoit ## include $(top_srcdir)/config/toplevel.mk -SUBDIRS = syn sig str lib tools +SUBDIRS = syn sig lib str tools Index: tests/test-pp-prism.sh.in --- tests/test-pp-prism.sh.in (revision 32) +++ tests/test-pp-prism.sh.in (working copy) @@ -12,6 +12,7 @@ test_cnt=0 test_pass=0 target_dir='output-pp-prism' +rm -f failed_tests.$$ test ! -d $target_dir && { mkdir $target_dir \ || { echo "Cannot create $target_dir/ directory" && exit 1; } } @@ -31,6 +32,7 @@ "@top_builddir@/src/tools/parse-prism" -i "$file" -o "$outdir/$bfile.aterm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: parsing FAILED" >> failed_tests.$$ continue fi echo 'OK, no ambiguities found' @@ -40,6 +42,7 @@ -i "$outdir/$bfile.aterm" -o "$outdir/$bfile.pp.pm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: pretty printing FAILED" >> failed_tests.$$ continue fi echo 'OK' @@ -53,6 +56,7 @@ cat -n "$outdir/$bfile.pp.pm" echo '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<' echo 'Now continuing with the next test...' + echo " * $file: re-parsing FAILED" >> failed_tests.$$ continue fi echo 'OK, no ambiguities found' @@ -62,6 +66,7 @@ -i "$outdir/$bfile.pp2aterm" -o "$outdir/$bfile.pp2.pm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: re-pretty printing FAILED" >> failed_tests.$$ continue fi echo 'OK' @@ -78,10 +83,14 @@ @STRATEGOXT@/bin/pp-aterm \ -i "$outdir/$bfile.pp2aterm" -o "$outdir/$bfile.pp2aterm.pp" diff -u "$outdir/$bfile.aterm.pp" "$outdir/$bfile.pp2aterm.pp" + echo " * $file: both parses did NOT produce the same AST" >> failed_tests.$$ + continue ;; *pp*) echo 'FAILED: the two pretty printing did NOT produce the same source:' diff -u "$outdir/$bfile.pp.pm" "$outdir/$bfile.pp2.pm" + echo " * $file: both pretty pretty did NIT produce the same source" >> failed_tests.$$ + continue ;; esac @@ -91,6 +100,7 @@ echo "$0: $test_pass/$test_cnt tests passed" echo "`date` $0: $test_pass/$test_cnt tests passed" >> test_summary -rm -rf "$outdir" +cat failed_tests.$$ >> test_summary +rm -rf failed_tests.$$ "$outdir" test $test_pass -eq $test_cnt Index: tests/xrm/desugar_builtins.pm --- tests/xrm/desugar_builtins.pm (revision 0) +++ tests/xrm/desugar_builtins.pm (revision 0) @@ -0,0 +1,29 @@ +module desugarme + x : [0..42]; + + // [] x=min(0) -> (x'=1); // invalid (must have at least 2 args) + [] x=func(min, 1, 2) -> (x'=0); + [] x=func(min, 4, 3, 5) -> (x'=1); + + // [] x=max(4) -> (x'=2); // invalid (must have at least 2 args) + [] x=func(max, 4, 5) -> (x'=3); + [] x=max(4, 5, 6) -> (x'=4); + + [] x=floor(41) -> (x'=5); + [] x=func(floor, 42.2) -> (x'=6); + // [] x=func(floor, 5, 6) -> (x'=7); // invalid (must have 1 arg) + + [] x=ceil(40) -> (x'=8); + [] x=func(ceil, 41.2) -> (x'=9); + // [] x=func(ceil, 5, 6) -> (x'=10); // invalid (must have 1 arg) + + // NOTE: there is no "short" version for pow, eg pow(2, 8) + // NOTE: short versions are "deprecated" + [] x=func(pow, 2, 8) -> (x'=11); + [] x=func(pow, 9.0, 0.5) -> (x'=12); + // [] x=func(pow, 5, 6, 7) -> (x'=13); // invalid (must have 2 args) + + [] x=func(mod, 1977, 100) -> (x'=14); + // [] x=func(mod, 42, 0) -> (x'=15); // invalid (modulo by 0) + // [] x=func(mod, 5, 6, 7) -> (x'=16); // invalid (must have 2 args) +endmodule Index: tests/test-xrm-front.sh.in --- tests/test-xrm-front.sh.in (revision 32) +++ tests/test-xrm-front.sh.in (working copy) @@ -12,6 +12,7 @@ test_cnt=0 test_pass=0 target_dir='output-xrm-front' +rm -f failed_tests.$$ test ! -d $target_dir && { mkdir $target_dir \ || { echo "Cannot create $target_dir/ directory" && exit 1; } } @@ -27,46 +28,43 @@ echo ">>> Starting the test for $basefile" test_cnt=$((test_cnt + 1)) - echo @ECHO_N@ " Converting $basefile into standard PRISM AST ... " - "@top_builddir@/src/str/xrm-front" \ + echo @ECHO_N@ " Converting $basefile into standard PRISM ... " + "@top_builddir@/src/str/xrm-front" -A \ -i "$file" -o "$outdir/$bfile.pm.aterm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: xrm-front failed (-A) FAILED" >> failed_tests.$$ continue fi echo 'OK' echo @ECHO_N@ " Converting $basefile into standard PRISM code ... " - "@top_builddir@/src/str/xrm-front" -P \ + "@top_builddir@/src/str/xrm-front" \ -i "$file" -o "$outdir/$bfile.pm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: xrm-front failed FAILED" >> failed_tests.$$ continue fi echo 'OK' echo @ECHO_N@ " Re-Parsing generated PRISM code for $basefile ... " - "@top_builddir@/src/tools/parse-prism" \ + "@top_builddir@/src/tools/parse-prism" -A \ -i "$outdir/$bfile.pm" -o "$outdir/$bfile.pm2.aterm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: re-parsing FAILED" >> failed_tests.$$ continue fi echo 'OK, no ambiguities found' - err='' - diff -q "$outdir/$bfile.pm.aterm" "$outdir/$bfile.pm2.aterm" || err='aterm' + diff -q "$outdir/$bfile.pm.aterm" "$outdir/$bfile.pm2.aterm" - case $err in - *aterm*) + if [ $? -ne 0 ]; then echo 'FAILED: the two parses did NOT produce the same AST:' - @STRATEGOXT@/bin/pp-aterm \ - -i "$outdir/$bfile.pm.aterm" -o "$outdir/$bfile.pm.aterm.pp" - @STRATEGOXT@/bin/pp-aterm \ - -i "$outdir/$bfile.pm2.aterm" -o "$outdir/$bfile.pm2.aterm.pp" + echo " * $file: both parses did NOT produce the same AST" >> failed_tests.$$ diff -u "$outdir/$bfile.pm.aterm.pp" "$outdir/$bfile.pm2.aterm.pp" - ;; - esac + fi echo "<<< Test for $basefile PASSED" test_pass=$((test_pass + 1)) @@ -74,6 +72,7 @@ echo "$0: $test_pass/$test_cnt tests passed" echo "`date` $0: $test_pass/$test_cnt tests passed" >> test_summary -rm -rf "$outdir" +cat failed_tests.$$ >> test_summary +rm -rf failed_tests.$$ "$outdir" test $test_pass -eq $test_cnt Index: tests/test-parse-xrm.sh.in --- tests/test-parse-xrm.sh.in (revision 32) +++ tests/test-parse-xrm.sh.in (working copy) @@ -11,16 +11,22 @@ test_cnt=0 test_pass=0 +rm -f failed_tests.$$ + for file in `find "@srcdir@" -name '*.pm' -o -name '*.nm' -o -name '*.sm' -o -name '*.xpm' | sort`; do echo @ECHO_N@ " Parsing `basename $file` ... " "@top_builddir@/src/tools/parse-xrm" -i "$file" -o /dev/null if [ $? -eq 0 ]; then echo 'OK, no ambiguities found' test_pass=$((test_pass + 1)) + else + echo " * $file: FAILED (bad return value: $rv)" >> failed_tests.$$ fi test_cnt=$((test_cnt + 1)) done echo "$0: $test_pass/$test_cnt tests passed" echo "`date` $0: $test_pass/$test_cnt tests passed" >> test_summary +cat failed_tests.$$ >> test_summary +rm -f failed_tests.$$ test $test_pass -eq $test_cnt Index: tests/test-parse-prism.sh.in --- tests/test-parse-prism.sh.in (revision 32) +++ tests/test-parse-prism.sh.in (working copy) @@ -11,16 +11,23 @@ test_cnt=0 test_pass=0 +rm -f failed_tests.$$ + for file in `find "@srcdir@" -name '*.pm' -o -name '*.nm' -o -name '*.sm' | sort`; do echo @ECHO_N@ " Parsing `basename $file` ... " "@top_builddir@/src/tools/parse-prism" -i "$file" -o /dev/null - if [ $? -eq 0 ]; then + rv=$? + if [ $rv -eq 0 ]; then echo 'OK, no ambiguities found' test_pass=$((test_pass + 1)) + else + echo " * $file: FAILED (bad return value: $rv)" >> failed_tests.$$ fi test_cnt=$((test_cnt + 1)) done echo "$0: $test_pass/$test_cnt tests passed" echo "`date` $0: $test_pass/$test_cnt tests passed" >> test_summary +cat failed_tests.$$ >> test_summary +rm -f failed_tests.$$ test $test_pass -eq $test_cnt Index: tests/test-pp-xrm.sh.in --- tests/test-pp-xrm.sh.in (revision 32) +++ tests/test-pp-xrm.sh.in (working copy) @@ -12,6 +12,7 @@ test_cnt=0 test_pass=0 target_dir='output-pp-xrm' +rm -f failed_tests.$$ test ! -d $target_dir && { mkdir $target_dir \ || { echo "Cannot create $target_dir/ directory" && exit 1; } } @@ -31,6 +32,7 @@ "@top_builddir@/src/tools/parse-xrm" -i "$file" -o "$outdir/$bfile.aterm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: parsing FAILED" >> failed_tests.$$ continue fi echo 'OK, no ambiguities found' @@ -40,6 +42,7 @@ -i "$outdir/$bfile.aterm" -o "$outdir/$bfile.pp.xpm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: pretty printing FAILED" >> failed_tests.$$ continue fi echo 'OK' @@ -53,6 +56,7 @@ cat -n "$outdir/$bfile.pp.xpm" echo '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<' echo 'Now continuing with the next test...' + echo " * $file: re-parsing FAILED" >> failed_tests.$$ continue fi echo 'OK, no ambiguities found' @@ -62,6 +66,7 @@ -i "$outdir/$bfile.pp2aterm" -o "$outdir/$bfile.pp2.xpm" if [ $? -ne 0 ]; then echo 'FAILED, continuing with the next test...' + echo " * $file: re-pretty printing FAILED" >> failed_tests.$$ continue fi echo 'OK' @@ -78,10 +83,14 @@ @STRATEGOXT@/bin/pp-aterm \ -i "$outdir/$bfile.pp2aterm" -o "$outdir/$bfile.pp2aterm.pp" diff -u "$outdir/$bfile.aterm.pp" "$outdir/$bfile.pp2aterm.pp" + echo " * $file: both parses did NOT produce the same AST" >> failed_tests.$$ + continue ;; *pp*) echo 'FAILED: the two pretty printing did NOT produce the same source:' diff -u "$outdir/$bfile.pp.xpm" "$outdir/$bfile.pp2.xpm" + echo " * $file: both pretty pretty did NIT produce the same source" >> failed_tests.$$ + continue ;; esac @@ -91,6 +100,7 @@ echo "$0: $test_pass/$test_cnt tests passed" echo "`date` $0: $test_pass/$test_cnt tests passed" >> test_summary -rm -rf "$outdir" +cat failed_tests.$$ >> test_summary +rm -rf failed_tests.$$ "$outdir" test $test_pass -eq $test_cnt Index: configure.ac --- configure.ac (revision 32) +++ configure.ac (working copy) @@ -5,7 +5,7 @@ ## Mail <sigoure.benoit@lrde.epita.fr> ## ## Started on Thu Apr 27 15:55:56 2006 SIGOURE Benoit -## Last update Tue May 16 04:03:02 2006 SIGOURE Benoit +## Last update Thu May 25 18:56:02 2006 SIGOURE Benoit ## ## --------------- ## @@ -79,6 +79,7 @@ src/lib/prism/pp/Makefile src/lib/xrm/Makefile src/lib/xrm/pp/Makefile + src/lib/native/Makefile src/tools/Makefile tests/Makefile ]) Property changes on: bootstrap ___________________________________________________________________ Name: svn:executable + *