https://svn.lrde.epita.fr/svn/xrm/trunk
Index: ChangeLog
from SIGOURE Benoit <sigoure.benoit(a)lrde.epita.fr>
Use libstratego-gpp for direct pretty printing.
This is a brand new way of pretty-printing. It relies on a very
recent version of libstratego-gpp and thus requires a very recent
installation of Stratego/XT 0.17M1.
Instead of calling prism-to-abox and Abox-2-text (which implies
creating several temporary files under /tmp) pp-{prism,xrm} do the
pretty-printing themselves and then use libstratego-gpp to transform
the boxed AST into text. This is much more efficient.
* src/tools/Makefile.am: Add includes flags for direct pretty printing.
* src/tools/pp-xrm.str: Use libstratego-gpp.
* src/tools/pp-prism.str: Ditto.
* src/lib/xrm/pp/xrm-to-abox.str: Move pp-xrm-to-abox...
* src/lib/xrm/pp/pp-xrm-to-box.str: ...here.
* src/lib/prism/pp/prism-to-abox.str: Move pp-prism-to-abox...
* src/lib/prism/pp/pp-prism-to-box.str: ...here.
* src/str/xrm-to-prism.str: Add a notice message.
* tests/xrm/array-decl-with-meta-and-non-meta-and-exp.xpm: New test.
* configure.ac: Use stratego-gpp.
configure.ac | 4 +
src/lib/prism/pp/pp-prism-to-box.str | 37 +++++++++++++
src/lib/prism/pp/prism-to-abox.str | 34 ------------
src/lib/xrm/pp/pp-xrm-to-box.str | 44 ++++++++++++++++
src/lib/xrm/pp/xrm-to-abox.str | 41 --------------
src/str/xrm-to-prism.str | 1
src/tools/Makefile.am | 13 ++++
src/tools/pp-prism.str | 18 +++---
src/tools/pp-xrm.str | 18 +++---
tests/xrm/array-decl-with-meta-and-non-meta-and-exp.xpm | 5 +
10 files changed, 121 insertions(+), 94 deletions(-)
Index: src/tools/Makefile.am
--- src/tools/Makefile.am (revision 47)
+++ src/tools/Makefile.am (working copy)
@@ -5,7 +5,7 @@
## Mail <sigoure.benoit(a)lrde.epita.fr>
##
## Started on Mon May 8 21:16:56 2006 SIGOURE Benoit
-## Last update Thu May 25 17:28:02 2006 SIGOURE Benoit
+## Last update Fri Jun 2 17:57:09 2006 SIGOURE Benoit
##
include $(top_srcdir)/config/Transformers.mk
@@ -21,11 +21,20 @@
CLEANFILES = $(wildcard *.c) $(wildcard *.dep)
SCFLAGS = --main main-$*
-STRINCLUDES = -I $(srcdir) -I $(XTC)/share/xtc
+STRINCLUDES = -I $(srcdir) -I $(XTC)/share/xtc \
+ -I $(GPP)/share/sdf/gpp \
+ $(STRATEGO_GPP_STRCFLAGS) \
+ -I $(top_srcdir)/src/lib/prism/pp \
+ -I $(top_srcdir)/src/lib/xrm/pp \
+ -I $(top_builddir)/src/lib/prism/pp \
+ -I $(top_builddir)/src/lib/xrm/pp \
+ -I $(top_builddir)/src/sig
LDADD += $(SSL_LIBS)
parse_prism_SOURCES = parse-prism.c
pp_prism_SOURCES= pp-prism.c
+pp_prism_LDADD = $(STRATEGO_GPP_LIBS)
parse_xrm_SOURCES = parse-xrm.c
pp_xrm_SOURCES= pp-xrm.c
+pp_xrm_LDADD = $(STRATEGO_GPP_LIBS)
Index: src/tools/pp-xrm.str
--- src/tools/pp-xrm.str (revision 47)
+++ src/tools/pp-xrm.str (working copy)
@@ -2,27 +2,27 @@
module pp-xrm
imports
- libxtclib // FIXME: import libstratego-xtc for strc 0.17
+ libstratego-lib
tool-doc
+ libstratego-gpp
+ pp-xrm-to-box
strategies
main-pp-xrm =
- // xtc-io-wrap(extra-opts, usage, about, deps, s)
- xtc-io-wrap(
+ // io-stream-wrap(extra-opts, usage, about, s)
+ io-stream-wrap(
fail
, pp-xrm-usage
, pp-xrm-about
- , !["xrm-to-abox", "abox2text"]
, pp-xrm
)
pp-xrm =
- xtc-transform(get-2abox, pass-verbose)
- ; xtc-abox2text
-
- get-2abox =
- <get-config> "2abox" <+ !"xrm-to-abox"
+ ?(<read-from-stream>, out-file)
+ ; pp-xrm-to-abox
+ ; box2text-stream(|80, out-file)
+ // FIXME: a final \n is missing
/**
* Documentation
Index: src/tools/pp-prism.str
--- src/tools/pp-prism.str (revision 47)
+++ src/tools/pp-prism.str (working copy)
@@ -2,27 +2,27 @@
module pp-prism
imports
- libxtclib // FIXME: import libstratego-xtc for strc 0.17
+ libstratego-lib
tool-doc
+ libstratego-gpp
+ pp-prism-to-box
strategies
main-pp-prism =
- // xtc-io-wrap(extra-opts, usage, about, deps, s)
- xtc-io-wrap(
+ // io-stream-wrap(extra-opts, usage, about, s)
+ io-stream-wrap(
fail
, pp-prism-usage
, pp-prism-about
- , !["prism-to-abox", "abox2text"]
, pp-prism
)
pp-prism =
- xtc-transform(get-2abox, pass-verbose)
- ; xtc-abox2text
-
- get-2abox =
- <get-config> "2abox" <+ !"prism-to-abox"
+ ?(<read-from-stream>, out-file)
+ ; pp-prism-to-abox
+ ; box2text-stream(|80, out-file)
+ // FIXME: a final \n is missing
/**
* Documentation
Index: src/lib/xrm/pp/pp-xrm-to-box.str
--- src/lib/xrm/pp/pp-xrm-to-box.str (revision 0)
+++ src/lib/xrm/pp/pp-xrm-to-box.str (revision 0)
@@ -0,0 +1,44 @@
+module pp-xrm-to-box
+imports
+ Box
+ XRM // signature
+ PRISM // signature of the base language (see README)
+ prism-command
+ prism-constant
+ prism-declaration
+ prism-expression
+ prism-formula
+ prism-global
+ prism-init
+ prism-module
+ prism-modulesfile
+ prism-modulesfiletype
+ prism-reward
+ prism-systemcomposition
+ prism-update
+ xrm-parenthesize
+ xrm-expression
+ xrm-module
+ xrm-meta-for
+ xrm-meta-if
+ xrm-arrays
+
+strategies
+
+ pp-xrm-to-abox =
+ pp-xrm-to-abox(prism-to-box) // we keep prism-to-box as rule name
+ // because we simply extend it
+
+ pp-xrm-to-abox(pprules) =
+ // strategy from xrm-parenthesize.str generated by sdf2parenthesize
+ parenthesize-XRM
+ ; topdown(try(very-special-conflict)
+ ; repeat(pprules))
+
+rules
+
+ very-special-conflict:
+ Minus(Minus(e)) -> Minus(Parenthetical(Minus(e)))
+
+ very-special-conflict:
+ Plus(Plus(e)) -> Plus(Parenthetical(Plus(e)))
Index: src/lib/xrm/pp/xrm-to-abox.str
--- src/lib/xrm/pp/xrm-to-abox.str (revision 47)
+++ src/lib/xrm/pp/xrm-to-abox.str (working copy)
@@ -2,28 +2,7 @@
imports
libxtclib // FIXME: import libstratego-xtc for strc 0.17
tool-doc
- Box
- XRM // signature
- PRISM // signature of the base language (see README)
- prism-command
- prism-constant
- prism-declaration
- prism-expression
- prism-formula
- prism-global
- prism-init
- prism-module
- prism-modulesfile
- prism-modulesfiletype
- prism-reward
- prism-systemcomposition
- prism-update
- xrm-parenthesize
- xrm-expression
- xrm-module
- xrm-meta-for
- xrm-meta-if
- xrm-arrays
+ pp-xrm-to-box
strategies
@@ -48,24 +27,6 @@
write-to-text // write text output
end
-strategies
- pp-xrm-to-abox =
- pp-xrm-to-abox(prism-to-box) // we keep prism-to-box as rule name
- // because we simply extend it
-
- pp-xrm-to-abox(pprules) =
- // strategy from xrm-parenthesize.str generated by sdf2parenthesize
- parenthesize-XRM
- ; topdown(try(very-special-conflict))
- ; topdown(try(repeat(pprules)))
-
-rules
- very-special-conflict:
- Minus(Minus(e)) -> Minus(Parenthetical(Minus(e)))
-
- very-special-conflict:
- Plus(Plus(e)) -> Plus(Parenthetical(Plus(e)))
-
/**
* Documentation
*/
Index: src/lib/prism/pp/pp-prism-to-box.str
--- src/lib/prism/pp/pp-prism-to-box.str (revision 0)
+++ src/lib/prism/pp/pp-prism-to-box.str (revision 0)
@@ -0,0 +1,37 @@
+module pp-prism-to-box
+imports
+ Box
+ PRISM // signature
+ prism-command
+ prism-constant
+ prism-declaration
+ prism-expression
+ prism-formula
+ prism-global
+ prism-init
+ prism-module
+ prism-modulesfile
+ prism-modulesfiletype
+ prism-reward
+ prism-systemcomposition
+ prism-update
+ prism-parenthesize
+
+strategies
+
+ pp-prism-to-abox =
+ pp-prism-to-abox(prism-to-box)
+
+ pp-prism-to-abox(pprules) =
+ // strategy from prism-parenthesize.str generated by sdf2parenthesize
+ parenthesize-PRISM
+ ; topdown(try(very-special-conflict)
+ ; repeat(pprules))
+
+rules
+
+ very-special-conflict:
+ Minus(Minus(e)) -> Minus(Parenthetical(Minus(e)))
+
+ very-special-conflict:
+ Plus(Plus(e)) -> Plus(Parenthetical(Plus(e)))
Index: src/lib/prism/pp/prism-to-abox.str
--- src/lib/prism/pp/prism-to-abox.str (revision 47)
+++ src/lib/prism/pp/prism-to-abox.str (working copy)
@@ -2,22 +2,7 @@
imports
libxtclib // FIXME: import libstratego-xtc for strc 0.17
tool-doc
- Box
- PRISM // signature
- prism-command
- prism-constant
- prism-declaration
- prism-expression
- prism-formula
- prism-global
- prism-init
- prism-module
- prism-modulesfile
- prism-modulesfiletype
- prism-reward
- prism-systemcomposition
- prism-update
- prism-parenthesize
+ pp-prism-to-box
strategies
@@ -42,23 +27,6 @@
write-to-text // write text output
end
-strategies
- pp-prism-to-abox =
- pp-prism-to-abox(prism-to-box)
-
- pp-prism-to-abox(pprules) =
- // strategy from prism-parenthesize.str generated by sdf2parenthesize
- parenthesize-PRISM
- ; topdown(try(very-special-conflict))
- ; topdown(try(repeat(pprules)))
-
-rules
- very-special-conflict:
- Minus(Minus(e)) -> Minus(Parenthetical(Minus(e)))
-
- very-special-conflict:
- Plus(Plus(e)) -> Plus(Parenthetical(Plus(e)))
-
/**
* Documentation
*/
Index: src/str/xrm-to-prism.str
--- src/str/xrm-to-prism.str (revision 47)
+++ src/str/xrm-to-prism.str (working copy)
@@ -91,6 +91,7 @@
/* paste them at the end of the file */
; ModulesFile(id, <conc>(<id>, rand-gen-modules))
+ ; notice-msg(|"xrm-to-prism: added modules for random numbers")
/* remove array accesses: x[i] -> x_i */
// FIXME: can we make this more efficient than a complete bottomup?
Index: tests/xrm/array-decl-with-meta-and-non-meta-and-exp.xpm
--- tests/xrm/array-decl-with-meta-and-non-meta-and-exp.xpm (revision 0)
+++ tests/xrm/array-decl-with-meta-and-non-meta-and-exp.xpm (revision 0)
@@ -0,0 +1,5 @@
+for i from 0 to 4 do
+ for j in 0, 1 do
+ const int N[i+2+j][3] = 0;
+ end
+end
Index: configure.ac
--- configure.ac (revision 47)
+++ configure.ac (working copy)
@@ -5,7 +5,7 @@
## Mail <sigoure.benoit(a)lrde.epita.fr>
##
## Started on Thu Apr 27 15:55:56 2006 SIGOURE Benoit
-## Last update Thu May 25 18:56:02 2006 SIGOURE Benoit
+## Last update Fri Jun 2 17:52:40 2006 SIGOURE Benoit
##
## --------------- ##
@@ -59,6 +59,8 @@
# define PACKAGE_NAME_TERM, PACKAGE_VERSION_TERM and PACKAGE_BUGREPORT_TERM
# theses are #defined so that PACKAGE_* are accessible as ATerms
XT_TERM_DEFINE
+# use STRATEGO_GPP
+XT_CHECK_PACKAGE([STRATEGO_GPP],[stratego-gpp])
## -------------------- ##
## Output configuration ##