https://svn.lrde.epita.fr/svn/xrm/trunk
Index: ChangeLog
from SIGOURE Benoit <sigoure.benoit(a)lrde.epita.fr>
Factor common code between different parsers.
* src/tools/parse-pctl.str,
* src/tools/parse-xrm.str,
* src/tools/parse-prism.str,
* src/tools/parse-xpctl.str: Move redundant code ...
* src/tools/parser-common.str: ... here.
* TODO: Bring up to date.
TODO | 26 ++++++++++++++++++++++++++
src/tools/parse-pctl.str | 43 +++++--------------------------------------
src/tools/parse-prism.str | 43 +++++--------------------------------------
src/tools/parse-xpctl.str | 43 +++++--------------------------------------
src/tools/parse-xrm.str | 43 +++++--------------------------------------
src/tools/parser-common.str | 38 +++++++++++++++++++++++++++++++++++++-
6 files changed, 83 insertions(+), 153 deletions(-)
Index: src/tools/parse-pctl.str
--- src/tools/parse-pctl.str (revision 74)
+++ src/tools/parse-pctl.str (working copy)
@@ -1,5 +1,3 @@
-// Code mostly from parse-java by Martin Bravenboer <martin(a)cs.uu.nl>
-
module parse-pctl
imports
libxtclib // FIXME: import libstratego-xtc for strc 0.17
@@ -10,37 +8,13 @@
main-parse-pctl =
// xtc-io-wrap(extra-opts, usage, about, deps, s)
xtc-io-wrap(
- parse-pctl-options
- , parse-pctl-usage
+ parser-options
+ , parser-usage
, parser-about
, !["sglr", "implode-asfix", "PCTL.tbl",
"pp-aterm"]
- , parse-pctl
+ , parser-main
)
- parse-pctl-options =
- symbol-option
- + preserve-comments-option
- + preserve-positions-option
- + pp-aterm-option
- + allow-amb-option
-
-strategies
-
- parse-pctl =
- where(?FILE(input-file-name) + !"stdin" => input-file-name)
- ; xtc-sglr-no-heuristics(get-parse-table, get-start-symbol)
- ; if must-preserve-comments then
- xtc-transform(!"asfix-anno-comments", pass-verbose)
- end
- ; if must-preserve-positions then
- xtc-transform(!"addPosInfo", !["-p", input-file-name
- | <pass-verbose>()])
- end
- ; xtc-implode-asfix
- ; if must-pp-aterm then
- xtc-transform(!"pp-aterm", pass-verbose)
- end
-
strategies
symbol-option =
@@ -77,12 +51,5 @@
*/
strategies
- parse-pctl-usage =
- <tool-doc>
- [ Usage("parse-pctl [OPTIONS]")
- , Summary(
- "Parses a PCTL source file to an abstract syntax
- tree in the ATerm format.")
- , OptionUsage()
- , AutoReportBugs()
- ]
+ parser-usage =
+ template-parser-usage(|"parse-pctl", "PCTL")
Index: src/tools/parse-xrm.str
--- src/tools/parse-xrm.str (revision 74)
+++ src/tools/parse-xrm.str (working copy)
@@ -1,5 +1,3 @@
-// Code mostly from parse-java by Martin Bravenboer <martin(a)cs.uu.nl>
-
module parse-xrm
imports
libxtclib // FIXME: import libstratego-xtc for strc 0.17
@@ -10,37 +8,13 @@
main-parse-xrm =
// xtc-io-wrap(extra-opts, usage, about, deps, s)
xtc-io-wrap(
- parse-xrm-options
- , parse-xrm-usage
+ parser-options
+ , parser-usage
, parser-about
, !["sglr", "implode-asfix", "XRM.tbl",
"pp-aterm"]
- , parse-xrm
+ , parser-main
)
- parse-xrm-options =
- symbol-option
- + preserve-comments-option
- + preserve-positions-option
- + pp-aterm-option
- + allow-amb-option
-
-strategies
-
- parse-xrm =
- where(?FILE(input-file-name) + !"stdin" => input-file-name)
- ; xtc-sglr-no-heuristics(get-parse-table, get-start-symbol)
- ; if must-preserve-comments then
- xtc-transform(!"asfix-anno-comments", pass-verbose)
- end
- ; if must-preserve-positions then
- xtc-transform(!"addPosInfo", !["-p", input-file-name
- | <pass-verbose>()])
- end
- ; xtc-implode-asfix
- ; if must-pp-aterm then
- xtc-transform(!"pp-aterm", pass-verbose)
- end
-
strategies
symbol-option =
@@ -77,12 +51,5 @@
*/
strategies
- parse-xrm-usage =
- <tool-doc>
- [ Usage("parse-xrm [OPTIONS]")
- , Summary(
- "Parses an eXtended Reactive Module source file to an abstract syntax
- tree in the ATerm format.")
- , OptionUsage()
- , AutoReportBugs()
- ]
+ parser-usage =
+ template-parser-usage(|"parse-xrm", "eXtended Reactive Modules")
Index: src/tools/parse-prism.str
--- src/tools/parse-prism.str (revision 74)
+++ src/tools/parse-prism.str (working copy)
@@ -1,5 +1,3 @@
-// Code mostly from parse-java by Martin Bravenboer <martin(a)cs.uu.nl>
-
module parse-prism
imports
libxtclib // FIXME: import libstratego-xtc for strc 0.17
@@ -10,37 +8,13 @@
main-parse-prism =
// xtc-io-wrap(extra-opts, usage, about, deps, s)
xtc-io-wrap(
- parse-prism-options
- , parse-prism-usage
+ parser-options
+ , parser-usage
, parser-about
, !["sglr", "implode-asfix", "PRISM.tbl",
"pp-aterm"]
- , parse-prism
+ , parser-main
)
- parse-prism-options =
- symbol-option
- + preserve-comments-option
- + preserve-positions-option
- + pp-aterm-option
- + allow-amb-option
-
-strategies
-
- parse-prism =
- where(?FILE(input-file-name) + !"stdin" => input-file-name)
- ; xtc-sglr-no-heuristics(get-parse-table, get-start-symbol)
- ; if must-preserve-comments then
- xtc-transform(!"asfix-anno-comments", pass-verbose)
- end
- ; if must-preserve-positions then
- xtc-transform(!"addPosInfo", !["-p", input-file-name
- | <pass-verbose>()])
- end
- ; xtc-implode-asfix
- ; if must-pp-aterm then
- xtc-transform(!"pp-aterm", pass-verbose)
- end
-
strategies
symbol-option =
@@ -77,12 +51,5 @@
*/
strategies
- parse-prism-usage =
- <tool-doc>
- [ Usage("parse-prism [OPTIONS]")
- , Summary(
- "Parses a PRISM source file to an abstract syntax
- tree in the ATerm format.")
- , OptionUsage()
- , AutoReportBugs()
- ]
+ parser-usage =
+ template-parser-usage(|"parse-prism", "PRISM")
Index: src/tools/parser-common.str
--- src/tools/parser-common.str (revision 74)
+++ src/tools/parser-common.str (working copy)
@@ -1,9 +1,35 @@
-// used by parse-prism and parse-xrm to factorize common strategies
+// used by parse-* to factor common strategies
module parser-common
strategies
+ parser-main =
+ where(?FILE(input-file-name) + !"stdin" => input-file-name)
+ ; xtc-sglr-no-heuristics(get-parse-table, get-start-symbol)
+ ; if must-preserve-comments then
+ xtc-transform(!"asfix-anno-comments", pass-verbose)
+ end
+ ; if must-preserve-positions then
+ xtc-transform(!"addPosInfo", !["-p", input-file-name
+ | <pass-verbose>()])
+ end
+ ; xtc-implode-asfix
+ ; if must-pp-aterm then
+ xtc-transform(!"pp-aterm", pass-verbose)
+ end
+
+strategies
+
+ parser-options =
+ symbol-option
+ + preserve-comments-option
+ + preserve-positions-option
+ + pp-aterm-option
+ + allow-amb-option
+
+strategies
+
/* sglr options:
** -fi: heuristic: injection count
** -fe: heuristic: eagerness
@@ -84,6 +110,16 @@
*/
strategies
+ template-parser-usage(|parser-name, language) =
+ <tool-doc>
+ [ Usage(<concat-strings>[parser-name, " [OPTIONS]"])
+ , Summary(<concat-strings>[
+ "Parses a ", language, " source file to an abstract syntax
+ tree in the ATerm format."])
+ , OptionUsage()
+ , AutoReportBugs()
+ ]
+
parser-about =
<tool-doc>
[ AutoProgram()
Index: src/tools/parse-xpctl.str
--- src/tools/parse-xpctl.str (revision 74)
+++ src/tools/parse-xpctl.str (working copy)
@@ -1,5 +1,3 @@
-// Code mostly from parse-java by Martin Bravenboer <martin(a)cs.uu.nl>
-
module parse-xpctl
imports
libxtclib // FIXME: import libstratego-xtc for strc 0.17
@@ -10,37 +8,13 @@
main-parse-xpctl =
// xtc-io-wrap(extra-opts, usage, about, deps, s)
xtc-io-wrap(
- parse-xpctl-options
- , parse-xpctl-usage
+ parser-options
+ , parser-usage
, parser-about
, !["sglr", "implode-asfix", "XPCTL.tbl",
"pp-aterm"]
- , parse-xpctl
+ , parser-main
)
- parse-xpctl-options =
- symbol-option
- + preserve-comments-option
- + preserve-positions-option
- + pp-aterm-option
- + allow-amb-option
-
-strategies
-
- parse-xpctl =
- where(?FILE(input-file-name) + !"stdin" => input-file-name)
- ; xtc-sglr-no-heuristics(get-parse-table, get-start-symbol)
- ; if must-preserve-comments then
- xtc-transform(!"asfix-anno-comments", pass-verbose)
- end
- ; if must-preserve-positions then
- xtc-transform(!"addPosInfo", !["-p", input-file-name
- | <pass-verbose>()])
- end
- ; xtc-implode-asfix
- ; if must-pp-aterm then
- xtc-transform(!"pp-aterm", pass-verbose)
- end
-
strategies
symbol-option =
@@ -77,12 +51,5 @@
*/
strategies
- parse-xpctl-usage =
- <tool-doc>
- [ Usage("parse-xpctl [OPTIONS]")
- , Summary(
- "Parses an eXtended Properties source file to an abstract syntax
- tree in the ATerm format.")
- , OptionUsage()
- , AutoReportBugs()
- ]
+ parser-usage =
+ template-parser-usage(|"parse-xpctl", "eXtended Properties")
Index: TODO
--- TODO (revision 74)
+++ TODO (working copy)
@@ -103,6 +103,23 @@
end
end
+ * Fix the rand builtin. Instead of generating an extra module to host the
+ random variable and generate random numbers, host the random variable in
+ the module that called rand. Update the random variable each time it's
+ accessed to ensure good randomness, eg:
+ module random => module random
+ x : [0..51] init 0; => x : [0..51] init 0;
+ [] true -> x'=rand(42); => __rand_0 : [0..42]; // no init here
+ endmodule => [] true -> x'=__rand_0 +
+ => 1/43:(__rand_0'=0) + ... +
+ => 1/43:(__rand_0'=42);
+ => endmodule
+
+ * Generalize the ranges. Instead of writing rand (42, 51), write:
+ rand (42 .. 51)
+ So that rand (42) always returns 42 and rand (42, 51) returns either 42
+ or 51.
+
## -------------- ##
## Desugarisation ##
## -------------- ##
@@ -177,6 +194,15 @@
loops and then later try to group them? Would there be cases where
grouping gets tricky? What about d_2 above?
+ * Don't use external parsers/pretty-printers in xrm-front. This leads to
+ many /tmp files and implies a great performance penalty on big
+ inputs/outputs. Instead, factor each parser in an external library linked
+ to xrm-front (preferably a static library because dynamic libraries must
+ be installed in the right path or require messing up with
+ LD_LIBRARY_PATH). This way, no external process will be involved. See if
+ we can also get rid of pp-aterm by using it directly through
+ libstratego-gpp.
+
## ----- ##
## Notes ##
## ----- ##