diff --git a/contrib/sparverius/xjsonize/.depend b/contrib/sparverius/xjsonize/.depend new file mode 100644 index 000000000..9aa4c6a0c --- /dev/null +++ b/contrib/sparverius/xjsonize/.depend @@ -0,0 +1,36 @@ +BUILD/json_sats.o : +BUILD/basics_sats.o : SATS/json.sats +BUILD/stamp0_sats.o : SATS/json.sats +BUILD/symbol_sats.o : SATS/json.sats +BUILD/label0_sats.o : SATS/json.sats +BUILD/locinfo_sats.o : SATS/json.sats +BUILD/lexing_sats.o : SATS/json.sats +BUILD/filpath_sats.o : SATS/json.sats +BUILD/dynexp0_sats.o : SATS/json.sats +BUILD/staexp0_sats.o : SATS/json.sats +BUILD/dynexp1_sats.o : SATS/json.sats +BUILD/staexp1_sats.o : SATS/json.sats +BUILD/statyp2_sats.o : SATS/json.sats +BUILD/staexp2_sats.o : SATS/json.sats +BUILD/dynexp2_sats.o : SATS/json.sats +BUILD/dynexp3_sats.o : SATS/json.sats +BUILD/fixity_sats.o : SATS/json.sats +BUILD/jsonize0_sats.o : +BUILD/json_dats.o : SATS/json.sats +BUILD/basics_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/basics.sats +BUILD/stamp0_dats.o : SATS/stamp0.sats SATS/json.sats DATS/json.dats +BUILD/symbol_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/symbol.sats +BUILD/label0_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/json.sats DATS/json.dats SATS/label0.sats SATS/symbol.sats +BUILD/locinfo_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/locinfo.sats +BUILD/lexing_token_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/lexing.sats SATS/locinfo.sats SATS/basics.sats SATS/symbol.sats +BUILD/filpath_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/filpath.sats +BUILD/staexp0_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/json.sats DATS/json.dats SATS/dynexp0.sats SATS/staexp0.sats SATS/label0.sats SATS/lexing.sats +BUILD/dynexp0_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/dynexp0.sats SATS/staexp0.sats SATS/lexing.sats +BUILD/staexp1_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/json.sats DATS/json.dats SATS/dynexp0.sats SATS/staexp0.sats SATS/label0.sats SATS/lexing.sats SATS/locinfo.sats SATS/staexp1.sats DATS/staexp0.dats SATS/symbol.sats +BUILD/dynexp1_dats.o : SATS/json.sats DATS/json.dats SATS/json.sats DATS/json.dats SATS/label0.sats SATS/lexing.sats SATS/filpath.sats SATS/staexp0.sats SATS/dynexp0.sats SATS/staexp1.sats SATS/dynexp1.sats DATS/dynexp0.dats +BUILD/statyp2_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/staexp2.sats SATS/statyp2.sats SATS/symbol.sats SATS/locinfo.sats SATS/stamp0.sats SATS/label0.sats +BUILD/staexp2_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/json.sats DATS/json.dats SATS/basics.sats SATS/dynexp0.sats SATS/staexp0.sats SATS/label0.sats SATS/lexing.sats SATS/staexp1.sats SATS/staexp2.sats SATS/symbol.sats SATS/locinfo.sats SATS/stamp0.sats SATS/label0.sats +BUILD/dynexp2_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/json.sats DATS/json.dats SATS/lexing.sats SATS/locinfo.sats SATS/label0.sats SATS/filpath.sats SATS/dynexp0.sats SATS/staexp0.sats SATS/dynexp1.sats SATS/dynexp2.sats SATS/staexp2.sats SATS/symbol.sats SATS/stamp0.sats +BUILD/dynexp3_dats.o : HATS/libxatsopt.hats SATS/json.sats DATS/json.dats SATS/json.sats DATS/json.dats SATS/lexing.sats SATS/label0.sats SATS/filpath.sats SATS/staexp0.sats SATS/dynexp0.sats SATS/staexp1.sats SATS/dynexp1.sats SATS/statyp2.sats SATS/staexp2.sats SATS/dynexp2.sats SATS/dynexp3.sats +BUILD/jsonize0_dats.o : HATS/libxatsopt.hats SATS/json.sats SATS/basics.sats SATS/fixity.sats SATS/label0.sats SATS/locinfo.sats SATS/lexing.sats SATS/stamp0.sats SATS/symbol.sats SATS/filpath.sats SATS/staexp0.sats SATS/dynexp0.sats SATS/staexp1.sats SATS/dynexp1.sats SATS/statyp2.sats SATS/staexp2.sats SATS/dynexp2.sats SATS/dynexp3.sats DATS/json.dats DATS/basics.dats DATS/label0.dats DATS/locinfo.dats DATS/lexing_token.dats DATS/stamp0.dats DATS/symbol.dats DATS/filpath.dats DATS/staexp0.dats DATS/dynexp0.dats DATS/staexp1.dats DATS/dynexp1.dats DATS/statyp2.dats DATS/staexp2.dats DATS/dynexp2.dats DATS/dynexp3.dats DATS/json.dats SATS/jsonize0.sats +BUILD/xjsonize_dats.o : SATS/json.sats SATS/basics.sats SATS/fixity.sats SATS/label0.sats SATS/locinfo.sats SATS/lexing.sats SATS/stamp0.sats SATS/symbol.sats SATS/filpath.sats SATS/staexp0.sats SATS/dynexp0.sats SATS/staexp1.sats SATS/dynexp1.sats SATS/statyp2.sats SATS/staexp2.sats SATS/dynexp2.sats SATS/dynexp3.sats SATS/jsonize0.sats diff --git a/contrib/sparverius/xjsonize/BUILD/xats/CATS/.gitkeep b/contrib/sparverius/xjsonize/BUILD/xats/CATS/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/sparverius/xjsonize/BUILD/xats/CATS/lexbuf.cats b/contrib/sparverius/xjsonize/BUILD/xats/CATS/lexbuf.cats new file mode 100644 index 000000000..bf9eae13a --- /dev/null +++ b/contrib/sparverius/xjsonize/BUILD/xats/CATS/lexbuf.cats @@ -0,0 +1,89 @@ +/***********************************************************************/ +/* */ +/* Applied Type System */ +/* */ +/***********************************************************************/ + +/* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ +// +// Author: Hongwei Xi +// Start Time: May, 2018 +// Authoremail: gmhwxi@gmail.com +// +/* ****** ****** */ + +#ifndef XANADU_SRCGEN_CATS_LEXBUF +#define XANADU_SRCGEN_CATS_LEXBUF + +/* ****** ****** */ + +/* +typedef +lexbuf_tflat = +$extype_struct +"xats_lexbuf_struct" of +{ + base_ntot= int +, base_nrow= int +, base_ncol= int +(* +, char= int +*) +, cbuf= string +// +, begp= ptr +, endp= ptr, curp= ptr +// +, cbhead= cblist, cbtail= cblist +// +} (* end of [lexbuf] *) +*/ + +typedef struct { +// + atstype_int ntot ; // char number + atstype_int nrow ; // line number + atstype_int ncol ; // line offset +// +/* + atstype_int char ; // ungetc +*/ + atstype_ptr cbuf ; // prefix +// + atstype_ptr begp ; // start + atstype_ptr endp ; // finish + atstype_ptr curp ; // current +// + atstype_ptr cbhead ; // 1st cblock + atstype_ptr cbtail ; // rest of cblocks +// +} xats_lexbuf_struct ; + +/* ****** ****** */ + +#endif // end of [XANADU_SRCGEN_CATS_LEXBUF] + +/* ****** ****** */ + +/* end of [xats_lexbuf.cats] */ diff --git a/contrib/sparverius/xjsonize/BUILD/xats/CATS/locinfo.cats b/contrib/sparverius/xjsonize/BUILD/xats/CATS/locinfo.cats new file mode 100644 index 000000000..002db0e9d --- /dev/null +++ b/contrib/sparverius/xjsonize/BUILD/xats/CATS/locinfo.cats @@ -0,0 +1,56 @@ +/***********************************************************************/ +/* */ +/* Applied Type System */ +/* */ +/***********************************************************************/ + +/* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ +// +// Author: Hongwei Xi +// Start Time: May, 2018 +// Authoremail: gmhwxi@gmail.com +// +/* ****** ****** */ + +#ifndef \ +ATS3_SRCGEN_CATS_XATS_LOCINFO +#define \ +ATS3_SRCGEN_CATS_XATS_LOCINFO + +/* ****** ****** */ + +typedef struct { + atstype_int ntot ; // char number + atstype_int nrow ; // line number + atstype_int ncol ; // line offset +} xats_position_struct ; + +/* ****** ****** */ +// +#endif // end if [ifndef] +// [ATS3_SRCGEN_CATS_XATS_LOCINFO] +// +/* ****** ****** */ + +/* end of [xats_locinfo.cats] */ diff --git a/contrib/sparverius/xjsonize/BUILD/xats/CATS/parsing.cats b/contrib/sparverius/xjsonize/BUILD/xats/CATS/parsing.cats new file mode 100644 index 000000000..4b4d1bd30 --- /dev/null +++ b/contrib/sparverius/xjsonize/BUILD/xats/CATS/parsing.cats @@ -0,0 +1,70 @@ +/***********************************************************************/ +/* */ +/* Applied Type System */ +/* */ +/***********************************************************************/ + +/* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ +// +// Author: Hongwei Xi +// Start Time: June, 2018 +// Authoremail: gmhwxi@gmail.com +// +/* ****** ****** */ +// +#ifndef \ +ATS3_SRCGEN_CATS_XATS_PARSING +#define \ +ATS3_SRCGEN_CATS_XATS_PARSING +// +/* ****** ****** */ + +/* +typedef +tokbuf_tflat = +$extype_struct +"xats_tokbuf_struct" of +{ + token *begp; + token *endp; + token *curp; +} (* end of [tokbuf] *) +*/ + +typedef struct { +// + atstype_ptr begp ; // start + atstype_ptr endp ; // finish + atstype_ptr curp ; // current +// +} xats_tokbuf_struct ; + +/* ****** ****** */ +// +#endif // end if [ifndef] +// [ATS3_SRCGEN_CATS_XATS_PARSING] +// +/* ****** ****** */ + +/* end of [xats_parsing.cats] */ diff --git a/contrib/sparverius/xjsonize/CATS/lexbuf.cats b/contrib/sparverius/xjsonize/CATS/lexbuf.cats new file mode 100644 index 000000000..bf9eae13a --- /dev/null +++ b/contrib/sparverius/xjsonize/CATS/lexbuf.cats @@ -0,0 +1,89 @@ +/***********************************************************************/ +/* */ +/* Applied Type System */ +/* */ +/***********************************************************************/ + +/* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ +// +// Author: Hongwei Xi +// Start Time: May, 2018 +// Authoremail: gmhwxi@gmail.com +// +/* ****** ****** */ + +#ifndef XANADU_SRCGEN_CATS_LEXBUF +#define XANADU_SRCGEN_CATS_LEXBUF + +/* ****** ****** */ + +/* +typedef +lexbuf_tflat = +$extype_struct +"xats_lexbuf_struct" of +{ + base_ntot= int +, base_nrow= int +, base_ncol= int +(* +, char= int +*) +, cbuf= string +// +, begp= ptr +, endp= ptr, curp= ptr +// +, cbhead= cblist, cbtail= cblist +// +} (* end of [lexbuf] *) +*/ + +typedef struct { +// + atstype_int ntot ; // char number + atstype_int nrow ; // line number + atstype_int ncol ; // line offset +// +/* + atstype_int char ; // ungetc +*/ + atstype_ptr cbuf ; // prefix +// + atstype_ptr begp ; // start + atstype_ptr endp ; // finish + atstype_ptr curp ; // current +// + atstype_ptr cbhead ; // 1st cblock + atstype_ptr cbtail ; // rest of cblocks +// +} xats_lexbuf_struct ; + +/* ****** ****** */ + +#endif // end of [XANADU_SRCGEN_CATS_LEXBUF] + +/* ****** ****** */ + +/* end of [xats_lexbuf.cats] */ diff --git a/contrib/sparverius/xjsonize/CATS/locinfo.cats b/contrib/sparverius/xjsonize/CATS/locinfo.cats new file mode 100644 index 000000000..002db0e9d --- /dev/null +++ b/contrib/sparverius/xjsonize/CATS/locinfo.cats @@ -0,0 +1,56 @@ +/***********************************************************************/ +/* */ +/* Applied Type System */ +/* */ +/***********************************************************************/ + +/* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ +// +// Author: Hongwei Xi +// Start Time: May, 2018 +// Authoremail: gmhwxi@gmail.com +// +/* ****** ****** */ + +#ifndef \ +ATS3_SRCGEN_CATS_XATS_LOCINFO +#define \ +ATS3_SRCGEN_CATS_XATS_LOCINFO + +/* ****** ****** */ + +typedef struct { + atstype_int ntot ; // char number + atstype_int nrow ; // line number + atstype_int ncol ; // line offset +} xats_position_struct ; + +/* ****** ****** */ +// +#endif // end if [ifndef] +// [ATS3_SRCGEN_CATS_XATS_LOCINFO] +// +/* ****** ****** */ + +/* end of [xats_locinfo.cats] */ diff --git a/contrib/sparverius/xjsonize/CATS/parsing.cats b/contrib/sparverius/xjsonize/CATS/parsing.cats new file mode 100644 index 000000000..4b4d1bd30 --- /dev/null +++ b/contrib/sparverius/xjsonize/CATS/parsing.cats @@ -0,0 +1,70 @@ +/***********************************************************************/ +/* */ +/* Applied Type System */ +/* */ +/***********************************************************************/ + +/* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ +// +// Author: Hongwei Xi +// Start Time: June, 2018 +// Authoremail: gmhwxi@gmail.com +// +/* ****** ****** */ +// +#ifndef \ +ATS3_SRCGEN_CATS_XATS_PARSING +#define \ +ATS3_SRCGEN_CATS_XATS_PARSING +// +/* ****** ****** */ + +/* +typedef +tokbuf_tflat = +$extype_struct +"xats_tokbuf_struct" of +{ + token *begp; + token *endp; + token *curp; +} (* end of [tokbuf] *) +*/ + +typedef struct { +// + atstype_ptr begp ; // start + atstype_ptr endp ; // finish + atstype_ptr curp ; // current +// +} xats_tokbuf_struct ; + +/* ****** ****** */ +// +#endif // end if [ifndef] +// [ATS3_SRCGEN_CATS_XATS_PARSING] +// +/* ****** ****** */ + +/* end of [xats_parsing.cats] */ diff --git a/contrib/sparverius/xjsonize/DATS/basics.dats b/contrib/sparverius/xjsonize/DATS/basics.dats new file mode 100644 index 000000000..0ecebbee6 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/basics.dats @@ -0,0 +1,86 @@ +#include "share/atspre_staload.hats" +#staload +UN = "prelude/SATS/unsafe.sats" +// +(* ****** ****** *) +// +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/basics.sats" + +#staload "./../SATS/basics.sats" + + +implement +jsonize_valkind + (vlk) = node("valkind", res) where +val res = +( +// +case+ vlk of +| VLKval() => jstr("VLKval") +| VLKvalp() => jstr("VLKvalp") +| VLKvaln() => jstr("VLKvaln") +(* +| VLKmcval() => jstr("VLKprval") +*) +| VLKprval() => jstr("VLKprval") +// +) (* end of [jsonize_valkind] *) +end + +implement +jsonize_funkind + (fnk) = node("funkind", res) where +val res = +( +// +case+ fnk of +| FNKfn0() => jsonize("FNKfn0") +| FNKfnx() => jsonize("FNKfnx") +| FNKfn1() => jsonize("FNKfn1") +| FNKfun() => jsonize("FNKfun") +// +| FNKprfn0() => jsonize("FNKprfn0") +| FNKprfn1() => jsonize("FNKprfn1") +| FNKprfun() => jsonize("FNKprfun") +| FNKpraxi() => jsonize("FNKpraxi") +// +| FNKcastfn() => jsonize("FNKcastfn") +// +) (* end of [jsonize_funkind] *) +end + + +implement +jsonize_impkind + (knd) = node("impkind", res) where +val res = +( +case+ knd of +| IMPprf() => jsonize("IMPprf") +| IMPval() => jsonize("IMPval") +| IMPfun() => jsonize("IMPfun") +| IMPtmp() => jsonize("IMPtmp") +| IMPgen() => jsonize("IMPgen") +) (* end of [jsonize_impkind] *) +end + + +implement +jsonize_funclo2 + (fc2) = node("funclo2", res) where +val res = +( +case+ fc2 of +| FC2fun() => + jsonize("FC2fun") +| FC2clo(knd) => + jsonify("FC2clo", "knd", jsonize(knd)) +) +end diff --git a/contrib/sparverius/xjsonize/DATS/dynexp0.dats b/contrib/sparverius/xjsonize/DATS/dynexp0.dats new file mode 100644 index 000000000..02286f2b5 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/dynexp0.dats @@ -0,0 +1,1120 @@ +#include +"share/atspre_staload.hats" +#staload +UN = "prelude/SATS/unsafe.sats" + +#include +"./../HATS/libxatsopt.hats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/dynexp0.sats" +#staload "{$XATS}/SATS/staexp0.sats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/dynexp0.sats" +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/lexing.sats" + + +(* +overload jsonize with jsonize_option +*) + +implement jsonize_val = jsonize_token +implement jsonize_val = jsonize_s0exp +implement jsonize_val = jsonize_sort0 +implement jsonize_val = jsonize_s0arg +implement jsonize_val = jsonize_t0arg +implement jsonize_val = jsonize_s0marg +implement jsonize_val = jsonize_t0marg +implement jsonize_val = jsonize_sq0arg +implement jsonize_val = jsonize_tq0arg +implement jsonize_val = jsonize_ti0arg +implement jsonize_val = jsonize_f0arg + +implement +jsonize_q0arg + (x0) = +( +// +case+ +x0.node() of +(* +| Q0ARGnone(tok) => + jsonify("Q0ARGnone", "tok", jsonize(tok)) +*) +| Q0ARGsome(sid, opt) => + jsonify("Q0ARGsome", ("sid", "opt"), + (jsonize(sid), jsonize_option(opt))) +// +) (* end of [jsonize_q0arg] *) + +implement +jsonize_a0typ + (x0) = +( +// +case+ x0.node() of +(* +| A0TYPnone(tok) => + jsonify("A0TYPnone", tok) +*) +| A0TYPsome(s0e, opt) => + jsonify("A0TYPsome", ("s0e", "opt"), (jsonize(s0e), jsonize_option(opt))) +// +) (* end of [jsonize_a0typ] *) + + +local +// +implement jsonize_val = jsonize_a0typ + +fun +jsonize_a0typlstopt +(opt: a0typlstopt): jsonval = +( +case+ opt of +| None() => jsonify("None") +| Some(a0ts) => jsonify("Some", "a0ts", jsonize_list(a0ts)) +) +// +overload jsonize with jsonize_a0typlstopt of 100 +// + +implement jsonize_val = jsonize_s0qua + +in (* in-of-local *) + +implement +jsonize_d0arg + (x0) = +( +// +case+ x0.node() of +// +| D0ARGnone(tok) => + jsonify("D0ARGnone", "tok", jsonize(tok)) +// +| D0ARGsome_sta + (tbeg, s0qs, tend) => + jsonify("D0ARGsome_sta", ("tbeg", "s0qs", "tend"), + (jsonize(tbeg), jsonize_list(s0qs), jsonize(tend))) +// +| D0ARGsome_dyn1 + (tok) => + jsonify("D0ARGsome_dyn1", "tok", jsonize(tok)) +| D0ARGsome_dyn2 + (tbeg, arg0, opt1, tend) => + jsonify( + "D0ARGsome_dyn", + ("tbeg", "arg0", "opt1", "tend"), + (jsonize(tbeg), jsonize_list(arg0), jsonize(opt1), jsonize(tend)) + ) +// +) (* end of [jsonize_d0arg] *) + +end // end of [local] + + +implement jsonize_val = jsonize_s0qua +implement jsonize_val = jsonize_s0exp + +implement +jsonize_f0arg + (x0) = +( +// +case+ +x0.node() of +| F0ARGnone(tok) => + jsonify("F0ARGnone", "tok", jsonize(tok)) +| F0ARGsome_dyn(d0p) => + jsonify("F0ARGsome_dyn", "d0p", jsonize(d0p)) +| F0ARGsome_sta(tbeg, s0qs, tend) => + jsonify( + "F0ARGsome_sta", ("tbeg", "s0qs", "tend"), + (jsonize(tbeg), jsonize_list(s0qs), jsonize(tend)) + ) + +| F0ARGsome_met(tbeg, s0es, tend) => + jsonify( + "F0ARGsome_met", ("tbeg", "s0es", "tend"), + (jsonize(tbeg), jsonize_list(s0es), jsonize(tend)) + ) + (* where val _ = $showtype(s0es) end *) +// +) (* end of [jsonize_f0arg] *) + +implement jsonize_val = jsonize_q0arg + +implement +jsonize_sq0arg + (x0) = +( +// +case+ +x0.node() of +| SQ0ARGnone(tok) => + jsonify("SQ0ARGnone", "tok", jsonize(tok)) +| SQ0ARGsome(tbeg, q0as, tend) => + jsonify( + "SQ0ARGsome", ("tbeg", "q0as", "tend"), + (jsonize(tbeg), jsonize_list(q0as), jsonize(tend)) + ) + +// +) (* end of [jsonize_sq0arg] *) + +implement +jsonize_tq0arg + (x0) = +( +// +case+ +x0.node() of +| TQ0ARGnone(tok) => + jsonify("TQ0ARGnone", "tok", jsonize(tok)) +| TQ0ARGsome(tbeg, q0as, tend) => + jsonify( + "TQ0ARGsome", ("tbeg", "q0as", "tend"), + (jsonize(tbeg), jsonize_list(q0as), jsonize(tend)) + ) +// +) (* end of [jsonize_tq0arg] *) + + +implement +jsonize_ti0arg + (x0) = +( +// +case+ +x0.node() of +| TI0ARGnone(tok) => + jsonify("TI0ARGnone", "tok", jsonize(tok)) +| TI0ARGsome(tbeg, q0as, tend) => + jsonify( + "TI0ARGsome", ("tbeg", "q0as", "tend"), + (jsonize(tbeg), jsonize_list(q0as), jsonize(tend)) + ) +// +) (* end of [jsonize_ti0arg] *) + + + +implement +{a}(*tmp*) +jsonize_dl0abeled + (x0) = let +// +val+DL0ABELED(l0, t0, x1) = x0 +// +in +node("dl0abeled", res) where +val res = + jsonify("SL0ABELED", ("l0", "t0", "x1"), + (jsonize(l0), jsonize(t0), jsonize_val(x1)) + ) +end + +end // end of [jsonize_dl0abeled] + +implement(a:type) jsonize_val = jsonize_dl0abeled + + +local + +implement +jsonize_val = jsonize_d0pat + +implement +jsonize_val = jsonize_dl0abeled + + +in (* in-of-local *) + +implement +jsonize_d0pat + (x0) = +( +case+ x0.node() of +// +| D0Pid(id) => + jsonify("D0Pid", "id", jsonize(id)) +// +| D0Pint(i0) => + jsonify("D0Pint", "i0", jsonize(i0)) +| D0Pchr(c0) => + jsonify("D0Pchr", "c0", jsonize(c0)) +| D0Pflt(f0) => + jsonify("D0Pflt", "f0", jsonize(f0)) +| D0Pstr(s0) => + jsonify("D0Pstr", "s0", jsonize(s0)) +// +| D0Papps(d0ps) => + jsonify("D0Papps", "d0ps", jsonize_list(d0ps)) + +// +| D0Psqarg + (tbeg, s0as, tend) => + jsonify( + "D0Psqarg", ("tbeg", "s0as", "tend"), + (jsonize(tbeg), jsonize_list(s0as), jsonize(tend)) + ) + (* where val _ = $showtype(s0as) end *) +// +| D0Pparen + (tbeg, d0ps, tend) => + jsonify( + "D0Pparen", ("tbeg", "d0ps", "tend"), + (jsonize(tbeg), jsonize_list(d0ps), jsonize(tend)) + ) +// +| D0Ptuple + (tbeg, topt, d0ps, tend) => + jsonify( + "D0Ptuple", ("tbeg", "topt", "d0ps", "tend"), + (jsonize(tbeg), jsonize_option(topt), jsonize_list(d0ps), jsonize(tend)) + ) +| D0Precord + (tbeg, topt, ld0ps, tend) => + jsonify( + "D0Precord", ("tbeg", "topt", "ld0ps", "tend"), + ( + jsonize(tbeg), + jsonize_option(topt), + jsonize_list(ld0ps), + jsonize(tend) + ) + ) +// +| D0Panno + (d0p, ann) => + jsonify("D0Panno", ("d0p", "ann"), (jsonize(d0p), jsonize(ann))) +// +| D0Pqual + (tok, d0p) => + jsonify("D0Pqual", ("tok", "d0p"), (jsonize(tok), jsonize(d0p))) +// +| D0Pnone(tok) => jsonify("D0Pnone", "tok", jsonize(tok)) +// +) (* end of [jsonize_d0pat] *) + +end // end of [local] + + +local + +implement +jsonize_val = jsonize_d0pat + +in (* in-of-local *) + +implement +jsonize_d0pat_RPAREN + (x0) = +( +case+ x0 of +| d0pat_RPAREN_cons0(tok) => + jsonify("d0pat_RPAREN_cons0", "tok", jsonize(tok)) +| d0pat_RPAREN_cons1(tok1, d0ps, tok2) => + jsonify( + "d0pat_RPAREN_cons1", ("tok1", "d0ps", "tok2"), + (jsonize(tok1), jsonize_list(d0ps), jsonize(tok2)) + ) +) (* end of [jsonize_d0pat_RPAREN] *) + +end // end of [local] + + +local + +implement +jsonize_val = jsonize_d0pat + +in (* in-of-local *) + +implement +jsonize_labd0pat_RBRACE + (x0) = +( +case+ x0 of +| labd0pat_RBRACE_cons0(tok) => + jsonify("labd0pat_RBRACE_cons0", "tok", jsonize(tok)) +| labd0pat_RBRACE_cons1(tok1, ld0ps, tok2) => + jsonify( + "labd0pat_RBRACE_cons1", ("tok1", "ld0ps", "tok2"), + ( + jsonize(tok1), + jsonize_list(ld0ps), + jsonize(tok2) + ) + ) +) (* end of [jsonize_labd0pat_RBRACE] *) + +end // end of [local] + + +local + +implement +jsonize_val = jsonize_d0exp +(* +implement +jsonize_val = jsonize_d0clau +*) +implement +jsonize_val = jsonize_s0exp +implement +jsonize_val = jsonize_d0ecl +implement +jsonize_val = jsonize_f0arg + +implement +jsonize_val = jsonize_dl0abeled + + +in (* in-of-local *) + +implement +jsonize_d0exp + (x0) = +( +case+ x0.node() of +// +| D0Eid(id) => + jsonify("D0Eid", "id", jsonize(id)) +// +| D0Eint(i0) => + jsonify("D0Eint", "i0", jsonize(i0)) +| D0Echr(c0) => + jsonify("D0Echr", "c0", jsonize(c0)) +| D0Eflt(f0) => + jsonify("D0Eflt", "f0", jsonize(f0)) +| D0Estr(s0) => + jsonify("D0Estr", "s0", jsonize(s0)) +// +| D0Eapps(d0es) => + jsonify("D0Eapps", "d0es", jsonize_list(d0es)) +// +| D0Esqarg + (tbeg, s0es, tend) => + jsonify( + "D0Esqarg", ("tbeg", "s0es", "tend"), + (jsonize(tbeg), jsonize_list(s0es), jsonize(tend)) + ) +| D0Etqarg + (tbeg, s0es, tend) => + jsonify( + "D0Etqarg", ("tbeg", "s0es", "tend"), + (jsonize(tbeg), jsonize_list(s0es), jsonize(tend)) + ) +// +| D0Eparen + (tbeg, d0es, tend) => + jsonify( + "D0Eparen", ("tbeg", "d0es", "tend"), + (jsonize(tbeg), jsonize_list(d0es), jsonize(tend)) + ) +// +| D0Etuple + (tbeg, topt, d0es, tend) => + jsonify( + "D0Etuple", ("tbeg", "topt", "d0es", "tend"), + ( + jsonize(tbeg), + jsonize_option(topt), + jsonize_list(d0es), + jsonize(tend) + ) + ) +| D0Erecord + (tbeg, topt, ld0es, tend) => + jsonify( + "D0Erecord", ("tbeg", "topt", "ld0es", "tend"), + ( + jsonize(tbeg), + jsonize_option(topt), + jsonize_list(ld0es), + jsonize(tend) + ) + ) +// +| D0Eif0 + (tif0, d0e1, d0e2, d0e3, tend) => + jsonify( + "D0Eif0", ("tif0", "d0e1", "d0e2", "d0e3", "tend"), + ( + jsonize(tif0), + jsonize(d0e1), + jsonize(d0e2), + jsonize(d0e3), + jsonize_option(tend) + ) + ) +// +| D0Ecase + (tok0, d0e1, tof2, tbar, d0cs, tend) => + jsonify( + "D0Ecase", ("tok0", "d0e1", "tof2", "tbar", "d0cs", "tend"), + ( + jsonize(tok0), + jsonize(d0e1), + jsonize(tof2), + jsonize_option(tbar), + jsonize("..."), (* jsonize_list(d0cs), *) + jsonize_option(tend) + ) + ) +// +| D0Elet + (tok0, d0cs, topt, d0es, tok2) => + jsonify( + "D0Elet", ("tok0", "d0cs", "topt", "d0es", "tok2"), + ( + jsonize(tok0), + jsonize_list(d0cs), + jsonize_option(topt), + jsonize_list(d0es), + jsonize(tok2) + ) + ) +// +| D0Ewhere(d0e1, d0cs) => + jsonify("D0Ewhere", ("d0e1", "d0cs"), (jsonize(d0e1), jsonize(d0cs))) +// +// +| D0Ebrack + (tbeg, d0es, tend) => + jsonify( + "D0Ebrack", ("tbeg", "d0es", "tend"), + (jsonize(tbeg), jsonize_list(d0es), jsonize(tend)) + ) +| D0Edtsel + (tdot, lab1, arg2) => + jsonify( + "D0Edtsel", ("tdot", "lab1", "arg2"), + (jsonize(tdot), jsonize(lab1), jsonize_option(arg2)) + ) +// +| D0Elam + (tok0, arg1, res2, farrw, fbody, tend) => + jsonify( + "D0Elam", ("tok0", "arg1", "res2", "farrw", "fbody", "tend"), + ( + jsonize(tok0), + jsonize_list(arg1), + jsonize(res2), + jsonize(farrw), + jsonize(fbody), + jsonize_option(tend) + ) + ) +| D0Efix + (tok0, fid0, arg1, res2, farrw, fbody, tend) => + jsonify( + "D0Efix", ("tok0", "fid0", "arg1", "res2", "farrw", "fbody", "tend"), + ( + jsonize(tok0), + jsonize(fid0), + jsonize_list(arg1), + jsonize(res2), + jsonize(farrw), + jsonize(fbody), + jsonize_option(tend) + ) + ) +// +| D0Eanno + (d0e, ann) => + jsonify("D0Eanno", ("d0e", "ann"), (jsonize(d0e), jsonize(ann))) +// +| D0Equal + (tok, d0e) => + jsonify("D0Equal", ("tok", "d0e"), (jsonize(tok), jsonize(d0e))) +// +| D0Enone(tok) => jsonify("D0Enone"," tok", jsonize(tok)) +// +) (* end of [jsonize_d0exp] *) + +end // end of [local] + +local + +implement +jsonize_val = jsonize_d0exp + +in (* in-of-local *) + +implement +jsonize_d0exp_RPAREN + (x0) = +( +case+ x0 of +| d0exp_RPAREN_cons0(tok) => + jsonify("d0exp_RPAREN_cons0", "tok", jsonize(tok)) +| d0exp_RPAREN_cons1(tok1, d0es, tok2) => + jsonify( + "d0exp_RPAREN_cons1", ("tok1", "d0es", "tok2"), + (jsonize(tok1), jsonize_list(d0es), jsonize(tok2)) + ) +| d0exp_RPAREN_cons2(tok1, d0es, tok2) => + jsonify( + "d0exp_RPAREN_cons2", ("tok1", "d0es", "tok2"), + (jsonize(tok1), jsonize_list(d0es), jsonize(tok2)) + ) +) (* end of [jsonize_d0exp_RPAREN] *) + +end // end of [local] + +local + +implement +jsonize_val = jsonize_d0exp +implement +jsonize_val = jsonize_dl0abeled + + +in (* in-of-local *) + +implement +jsonize_labd0exp_RBRACE + (x0) = +( +case+ x0 of +| labd0exp_RBRACE_cons0(tok) => + jsonify("labd0exp_RBRACE_cons0", "tok", jsonize(tok)) +| labd0exp_RBRACE_cons1(tok1, ld0es, tok2) => + jsonify( + "labd0exp_RBRACE_cons1", ("tok1", "ld0es", "tok2"), + ( + jsonize(tok1), + jsonize_list(ld0es), + jsonize(tok2) + ) + ) +) (* end of [jsonize_labd0exp_RBRACE] *) + +end // end of [local] + + +implement +jsonize_d0exp_THEN(x0) = +( +case+ x0 of +| d0exp_THEN(tok, d0e) => + jsonify("d0exp_THEN", ("tok", "d0e"), (jsonize(tok), jsonize(d0e))) +) (* end of [jsonize_d0exp_THEN] *) + + +implement +jsonize_d0exp_ELSE(x0) = +( +case+ x0 of +| d0exp_ELSEnone() => + jsonify("d0exp_ELSEnone") +| d0exp_ELSEsome(tok, d0e) => + jsonify("d0exp_ELSEsome", ("tok", "d0e"), (jsonize(tok), jsonize(d0e))) +) (* end of [jsonize_d0exp_ELSE] *) + + +implement +jsonize_endwhere(x0) = +( +case+ x0 of +| endwhere_cons1(tok) => + jsonify("endwhere_cons1", "tok", jsonize(tok)) +| endwhere_cons2(tok1, opt2) => + jsonify("endwhere_cons2", ("tok1", "opt2"), + (jsonize(tok1), jsonize_option(opt2)) + ) +) + +implement jsonize_val = jsonize_d0ecl + + +implement +jsonize_d0eclseq_WHERE(x0) = +( +case+ x0 of +| d0eclseq_WHERE + (tok0, opt1, d0cs, opt2) => + jsonify( + "d0eclseq_WHERE", ("tok0", "opt1", "d0cs", "opt2"), + ( + jsonize(tok0), + jsonize_option(opt1), + jsonize_list(d0cs), + jsonize(opt2) + ) + ) +) (* end of [jsonize_d0eclseq_WHERE] *) + + +implement jsonize_val = jsonize_s0exp + +implement +jsonize_f0unarrow(x0) = +( +case+ x0 of +| F0UNARROWnone(tok) => + jsonify("F0UNARROWnone", "tok", jsonize(tok)) +| F0UNARROWdflt(tok) => + jsonify("F0UNARROWdflt", "tok", jsonize(tok)) +| F0UNARROWlist(tbeg, s0es, tend) => + jsonify( + "F0UNARROWlist", ("tbeg", "s0es", "tend"), + (jsonize(tbeg), jsonize_list(s0es), jsonize(tend)) + ) +) (* end of [jsonize_f0unarrow] *) + + + +implement jsonize_val(x) = jsonize_i0dnt(x) + +implement +jsonize_decmodopt + (x0) = +node("decmodopt", res) where +val res = +( +case+ x0 of +// +| DECMODnone() => + jsonify("DECMODnone") +// +| DECMODsing(tok, id0) => + jsonify("DECMODsing", ("tok", "id0"), rst) where + val rst = (jsonize(tok), jsonize(id0)) + end +| DECMODlist(tok, tbeg, ids, tend) => + (* jsonize!( out, "DECMODlist", tok, tbeg, ids, tend) *) + jsonify("DECMODsing", ("tok", "tbeg", "ids", "tend"), rst) where + (* val _ = $showtype(ids) *) + val xys = jsonize_list(ids) + val rst = (jsonize(tok), jsonize(tbeg), xys, jsonize(tend)) + end +) +end + +implement +jsonize_teqd0expopt + (x0) = +( +case+ x0 of +| TEQD0EXPnone() => + jsonify("TEQD0EXPnone") +| TEQD0EXPsome(tok, d0e) => + jsonify("TEQD0EXPsome", ("tok", "d0e"), (jsonize(tok), jsonize(d0e))) +) + +implement +jsonize_wths0expopt + (x0) = +( +case+ x0 of +| WTHS0EXPnone() => + jsonify("WTHS0EXPnone") +| WTHS0EXPsome(tok, d0e) => + jsonify("WTHS0EXPsome", ("tok", "d0e"), (jsonize(tok), jsonize(d0e))) +) + + +local + +implement +jsonize_val = jsonize_d0ecl +implement +jsonize_val = jsonize_g0marg +implement +jsonize_val = jsonize_v0aldecl +implement +jsonize_val = jsonize_v0ardecl +implement +jsonize_val = jsonize_f0undecl +implement +jsonize_val = jsonize_d0cstdecl +implement +jsonize_val = jsonize_i0dnt + +implement +jsonize_val = jsonize_d0tsort +implement +jsonize_val = jsonize_d0atype + +implement +jsonize_val = jsonize_t0int + +in (* in-of-local *) + +implement +jsonize_d0ecl + (x0) = +( +case+ x0.node() of +// +| D0Cnone(tok) => + jsonify("D0Cnone", "tok", jsonize(tok)) +// +| D0Ctokerr(tok) => + jsonify("D0Ctokerr", "tok", jsonize(tok)) +// +| D0Cnonfix(tok, ids) => + jsonify("D0Cnonfix", ("tok", "ids"), (jsonize(tok), jsonize_list(ids))) +| D0Cfixity(tok, ids, opt) => + jsonify( + "D0Cfixity", ("tok", "ids", "opt"), + (jsonize(tok), jsonize_list(ids), jsonize(opt)) + ) +// +| D0Cstatic(tok, d0c) => + jsonify("D0Cstatic", ("tok", "d0c"), (jsonize(tok), jsonize(d0c))) +| D0Cextern(tok, d0c) => + jsonify("D0Cextern", ("tok", "d0c"), (jsonize(tok), jsonize(d0c))) +// +| D0Cdefine + (tok, gid, gmas, gdef) => + jsonify( + "D0Cdefine", ("tok", "gid", "gmas", "gdef"), + (jsonize(tok), jsonize(gid), jsonize_list(gmas), jsonize(gdef)) + ) +// +| D0Cmacdef + (tok, gid, gmas, mdef) => + jsonify( + "D0Cmacdef", ("tok", "gid", "gmas", "mdef"), + (jsonize(tok), jsonize(gid), jsonize_list(gmas), jsonize(mdef)) + ) +// +| D0Cinclude(tok, d0e) => + jsonify("D0Cinclude", ("tok", "d0e"), (jsonize(tok), jsonize(d0e))) +// +| D0Cstaload(tok, d0e) => + jsonify("D0Cstaload", ("tok", "d0e"), (jsonize(tok), jsonize(d0e))) +(* +| D0Cdynload(tok, d0e) => + jsonify("D0Cdynload", tok, d0e) +*) +// +| D0Cabssort(tok, tid) => + jsonify("D0Cabssort", ("tok", "tid"), (jsonize(tok), jsonize(tid))) +// +| D0Cstacst0 + (tok, sid, tmas, tok1, s0t2) => + jsonify( + "D0Cstacst0", ("tok", "sid", "tmas", "tok1", "s0t2"), + ( + jsonize(tok), + jsonize(sid), + jsonize_list(tmas), + jsonize(tok1), jsonize(s0t2) + ) + ) +// +| D0Csortdef + (tok, tid, tok1, def2) => + jsonify( + "D0Csortdef", ("tok", "tid", "tok1", "def2"), + (jsonize(tok), jsonize(tid), jsonize(tok1), jsonize(def2)) + ) +| D0Csexpdef + (tok, sid, arg, res, tok1, tdef) => + jsonify( + "D0Csexpdef", ("tok", "sid", "arg", "res", "tok1", "tdef"), + ( + jsonize(tok), + jsonize(sid), + jsonize_list(arg), + jsonize_option(res), + jsonize(tok1), + jsonize(tdef) + ) + ) +// +| D0Cabstype + (tok, sid, arg, res, tdef) => + jsonify( + "D0Cabstype", ("tok", "sid", "arg", "res", "tdef"), + ( + jsonize(tok), + jsonize(sid), + jsonize_list(arg), + jsonize_option(res), + jsonize(tdef) + ) + ) +// +| D0Cabsimpl + (tok, sqid, smas, res0, teq1, def2) => + jsonify( + "D0Cabsimpl", ("tok", "sqid", "smas", "res0", "teq1", "def2"), + ( + jsonize(tok), + jsonize(sqid), + jsonize_list(smas), + jsonize_option(res0), + jsonize(teq1), + jsonize(def2) + ) + ) +// +| D0Cvaldecl + (tok, mopt, d0cs) => + jsonify( + "D0Cvaldecl", ("tok", "mopt", "d0cs"), + (jsonize(tok), jsonize(mopt), jsonize_list(d0cs)) + ) +// +| D0Cvardecl + (tok, mopt, d0cs) => + jsonify( + "D0Cvardecl", ("tok", "mopt", "d0cs"), + (jsonize(tok), jsonize(mopt), jsonize_list(d0cs)) + ) +// +| D0Cfundecl + (tok, mopt, tqas, d0cs) => + jsonify( + "D0Cfundecl", ("tok", "mopt", "tqas", "d0cs"), + (jsonize(tok), jsonize(mopt), jsonize_list(tqas), jsonize_list(d0cs)) + ) +// +| D0Cimpdecl + (tok, mopt, sqas, tqas, dqid, tias, f0as, res0, teq1, d0e2) => + jsonify( + "D0Cimpdecl", + ("tok", "mopt", "sqas", "tqas", "dqid", "tias", "f0as", "res0", "teq1", "d0e2"), + ( + jsonize(tok), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(dqid), + jsonize_list(tias), + jsonize_list(f0as), + jsonize(res0), + jsonize(teq1), + jsonize(d0e2) + ) + ) +// +| D0Csymload + (tok, sym, twth, dqid, tint) => + jsonify( + "D0Csymload", ("tok", "sym", "twth", "dqid", "tint"), + (jsonize(tok), jsonize(sym), jsonize(twth), jsonize(dqid), jsonize_option(tint)) + ) +// +| D0Cdatasort(tok, d0cs) => + jsonify("D0Cdatasort", ("tok", "d0cs"), (jsonize(tok), jsonize_list(d0cs))) +// +| D0Cdatatype(tok, d0cs, wopt) => + jsonify( + "D0Cdatatype", ("tok", "d0cs", "wopt"), + (jsonize(tok), jsonize_list(d0cs), jsonize(wopt)) + ) +// +| D0Cdynconst + (tok, tqas, d0cs) => + jsonify( + "D0Cdynconst", ("tok", "tqas", "d0cs"), + (jsonize(tok), jsonize_list(tqas), jsonize_list(d0cs)) + ) +// +| D0Clocal + (tbeg, d0cs0, topt, d0cs1, tend) => + jsonify( + "D0Clocal", ("tbeg", "d0cs0", "topt", "d0cs1", "tend"), + ( + jsonize(tbeg), + jsonize_list(d0cs0), + jsonize_option(topt), + jsonize_list(d0cs1), + jsonize(tend) + ) + ) +// +(* +| _(*rest-of-d1ecl*) => + jsonify("jsonize_d1ecl: D0C...: not-yet-implemented") +*) +// +) (* end of [jsonize_d0ecl] *) + +end // end of [local] + + +implement +jsonize_precopt + (x0) = +( +case+ x0 of +| PRECOPTnil() => + jsonify("PRECOPTnil") +| PRECOPTint(tint) => + jsonify("PRECOPTint", "tint", jsonize(tint)) +| PRECOPTopr(topr, pmod) => + jsonify("PRECOPTopr", ("topr", "pmod"), (jsonize(topr), jsonize(pmod))) +) (* end of [jsonize_precopt] *) + + + +implement +jsonize_signint + (x0) = +( +case+ x0 of +| SIGNINTint(tint) => + jsonify("SIGNINTint", "tint", jsonize(tint)) +| SIGNINTopr(topr, tint) => + jsonify("SIGNINTopr", ("topr", "tint"), (jsonize(topr), jsonize(tint))) +) +// +implement +jsonize_precmod + (x0) = +( +case+ x0 of +| PRECMODnone() => + jsonify("PRECMODnone") +| PRECMODsome(tbeg, sint, tend) => + jsonify("PRECMODsome", ("tbeg", "sint", "tend"), (jsonize(tbeg), jsonize(sint), jsonize(tend))) +) + + + +implement +jsonize_abstdf0 + (x0) = +( +case+ x0 of +| ABSTDF0some() => + jsonify("ABSTDF0some") +| ABSTDF0lteq(tok, s0e) => + jsonify("ABSTDF0lteq", ("tok", "s0e"), (jsonize(tok), jsonize(s0e))) +| ABSTDF0eqeq(tok, s0e) => + jsonify("ABSTDF0eqeq", ("tok", "s0e"), (jsonize(tok), jsonize(s0e))) +) (* end of [jsonize_abstdf0] *) + + +implement +jsonize_g0expdef + (x0) = +( +case+ x0 of +| G0EDEFnone() => + jsonify("G0EDEFnone") +| G0EDEFsome(topt, g0e1) => + jsonify("G0EDEFsome", ("topt", "g0e1"), (jsonize_option(topt), jsonize(g0e1))) +) + + +implement +jsonize_d0macdef + (x0) = +( +case+ x0 of +| D0MDEFnone() => + jsonify("D0MDEFnone") +| D0MDEFsome(topt, d0e1) => + jsonify("D0MDEFsome", ("topt", "d0e1"), (jsonize_option(topt), jsonize(d0e1))) +) + + +implement +jsonize_wd0eclseq + (x0) = +( +case+ x0 of +| WD0CSnone() => + jsonify("WD0CSnone") +| WD0CSsome(tbeg, topt, d0cs, tend) => + jsonify("WD0CSsome", ("tbeg", "topt", "d0cs", "tend"), + ( + jsonize(tbeg), + jsonize_option(topt), + jsonize_list(d0cs), + jsonize(tend) + ) + ) +) (* end of [jsonize_wd0eclseq] *) + + +implement jsonize_val = jsonize_d0exp + +implement +jsonize_v0aldecl + (x0) = let +// +val+V0ALDECL(rcd) = x0 +// +in + jsonify("V0ALDECL@{", ("pat", "teq", "def", "wtp"), + (jsonize(rcd.pat), jsonize_option(rcd.teq), jsonize_option(rcd.def), jsonize(rcd.wtp))) +end // end of [jsonize_v0aldecl] + + +implement jsonize_val = jsonize_i0dnt +implement jsonize_val = jsonize_s0exp + +implement +jsonize_v0ardecl + (x0) = let +// +val+V0ARDECL(rcd) = x0 +// +in + jsonify("V0ARDECL", ("nam", "wth", "res", "ini"), + ( + jsonize(rcd.nam), + jsonize_option(rcd.wth), + jsonize_option(rcd.res), + jsonize(rcd.ini) + ) + ) +end // end of [jsonize_v0ardecl] + + +implement jsonize_val = jsonize_f0arg + +implement +jsonize_f0undecl + (x0) = let +// +val+F0UNDECL(rcd) = x0 +// +in + jsonify("F0UNDECL", ("nam", "arg", "res", "teq", "def", "wtp"), + ( + jsonize(rcd.nam), + jsonize_list(rcd.arg), + jsonize(rcd.res), + jsonize_option(rcd.teq), + jsonize_option(rcd.def), + jsonize(rcd.wtp) + ) + ) +end // end of [jsonize_f0undecl] + + +implement jsonize_val = jsonize_d0arg + +implement +jsonize_d0cstdecl + (x0) = let +// +val+D0CSTDECL(rcd) = x0 +// +in + jsonify( + "D0CSTDECL", ("nam", "arg", "res", "def"), + ( + jsonize(rcd.nam), + jsonize_list(rcd.arg), + jsonize(rcd.res), + jsonize(rcd.def) + ) + ) +end // end of [jsonize_d0cstdecl] diff --git a/contrib/sparverius/xjsonize/DATS/dynexp1.dats b/contrib/sparverius/xjsonize/DATS/dynexp1.dats new file mode 100644 index 000000000..d8671a70b --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/dynexp1.dats @@ -0,0 +1,937 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +(* +#include "./../HATS/libxatsopt.hats" +*) + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" + +#staload "{$XATS}/SATS/staexp0.sats" +#staload "{$XATS}/SATS/dynexp0.sats" + +#staload "{$XATS}/SATS/staexp1.sats" +#staload "{$XATS}/SATS/dynexp1.sats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/label0.sats" +#staload "./../SATS/lexing.sats" +#staload "./../SATS/filpath.sats" + +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/dynexp0.sats" + +#staload "./../SATS/staexp1.sats" +#staload "./../SATS/dynexp1.sats" + +#staload _ = "./dynexp0.dats" + +implement +jsonize_val = jsonize_token +implement +jsonize_val = jsonize_sort1 +implement +jsonize_val = jsonize_filpath + +implement +jsonize_val = jsonize_d1exp + +implement +jsonize_val = jsonize_dl0abeled + +implement +jsonize_q1arg + (x0) = +node("q1arg", res) where +val res = +( +// +case+ x0.node() of +(* +| Q1ARGnone(tok) => + jsonify("Q1ARGnone", "tok", jsonize(tok)) +*) +| Q1ARGsome(tok, opt) => + jsonify("Q1ARGsome", ("tok", "opt"), + ( + jsonize(tok), + jsonize_option(opt) + ) + ) +// +) (* end of [jsonize_q1arg] *) +end + +implement +jsonize_a1typ + (x0) = +node("a1typ", res) where +val res = +( +// +case+ x0.node() of +| A1TYPsome(s1e, opt) => + jsonify("A1TYPsome", ("s1e", "opt"), + ( + jsonize(s1e), + jsonize_option(opt) + ) + ) +// +) (* end of [jsonize_a1typ] *) +end + + +local +// +implement +jsonize_val = jsonize_a1typ + +fun +jsonize_a1typlstopt +(opt: a1typlstopt): jsonval = +( +case+ opt of +| None() => jsonify("None") +| Some(a1ts) => jsonval_labval1("Some", jsonize_list(a1ts)) +) +// +overload jsonize with jsonize_a1typlstopt of 100 +// + +implement +jsonize_val = jsonize_s1qua + +in (* in-of-local *) + +implement +jsonize_d1arg + (x0) = +node("d1arg", res) where +val res = +( +// +case+ x0.node() of +// +| D1ARGsome_sta(s1qs) => + jsonify("D1ARGsome_sta", "s1qs", jsonize_list(s1qs)) +// +| D1ARGsome_dyn1(tok) => + jsonify("D1ARGsome_dyn1", "tok", jsonize(tok)) +| D1ARGsome_dyn2(arg0, opt1) => + jsonify("D1ARGsome_dyn2", ("arg0", "opt1"), + ( + jsonize_list(arg0), + jsonize(opt1) + ) + ) +// +) (* end of [jsonize_d1arg] *) +end +end // end of [local] + + +implement +jsonize_val = jsonize_s1qua +implement +jsonize_val = jsonize_s1exp +implement +jsonize_val = jsonize_q1arg + + +implement +jsonize_f1arg + (x0) = +node("f1arg", res) where +val res = +( +// +case+ +x0.node() of +(* +| F1ARGnone(tok) => + jsonify("F1ARGnone", "tok", jsonize(tok)) +*) +| F1ARGsome_dyn(d1p0) => + jsonify("F1ARGsome_dyn", "d1p0", jsonize(d1p0)) +| F1ARGsome_sta(s1qs) => + jsonify("F1ARGsome_sta", "s1qs", jsonize_list(s1qs)) +| F1ARGsome_met(s1es) => + jsonify("F1ARGsome_met", "s1es", jsonize_list(s1es)) +// +) (* end of [jsonize_f1arg] *) +end + +(* ****** ****** *) + +implement +jsonize_sq1arg + (x0) = +node("sq1arg", res) where +val res = +( +// +case+ +x0.node() of +| SQ1ARGnone(tok) => + jsonify("SQ1ARGnone", "tok", jsonize(tok)) +| SQ1ARGsome(q1as) => + jsonify("SQ1ARGsome", "q1as", jsonize_list(q1as)) +// +) (* end of [jsonize_sq1arg] *) +end + +(* ****** ****** *) + +implement +jsonize_ti1arg + (x0) = +node("ti1arg", res) where +val res = +( +// +case+ +x0.node() of +| TI1ARGnone(tok) => + jsonify("TI1ARGnone", "tok", jsonize(tok)) +| TI1ARGsome(s1es) => + jsonify("TI1ARGsome", "s1es", jsonize_list(s1es)) +// +) (* end of [jsonize_ti1arg] *) +end + +(* ****** ****** *) + +implement +jsonize_tq1arg + (x0) = +node("tq1arg", res) where +val res = +( +// +case+ +x0.node() of +| TQ1ARGnone(tok) => + jsonify("TQ1ARGnone", "tok", jsonize(tok)) +| TQ1ARGsome(q1as) => + jsonify("TQ1ARGsome", "q1as", jsonize_list(q1as)) +// +) (* end of [jsonize_tq1arg] *) +end + + +implement jsonize_val = jsonize_d1exp +implement jsonize_val = jsonize_d1ecl +implement jsonize_val = jsonize_f1arg +implement jsonize_val = jsonize_s1exp +implement jsonize_val = jsonize_d1clau + +implement +jsonize_d1exp + (x0) = //labval2(jsonize("d1exp"), res) where +(* res where *) +node("d1exp", res) where +{ +val res = +( +case+ x0.node() of +| D1Eid(tok) => + jsonify("D1Eid", "tok", jsonize(tok)) +// +| D1Eint(tok) => + jsonify("D1Eint", "tok", jsonize(tok)) +| D1Echr(tok) => + jsonify("D1Echr", "tok", jsonize(tok)) +| D1Eflt(tok) => + jsonify("D1Eflt", "tok", jsonize(tok)) +| D1Estr(tok) => + jsonify("D1Estr", "tok", jsonize(tok)) +// +| D1Eapp() => + jsonify("D1Eapp") +// +| D1Ebs0() => + jsonify("D1Ebs0") +| D1Ebs1(d1e) => + jsonify("D1Ebs1", "d1e", jsonize(d1e)) +// +| D1Eapp1(d1e0, d1e1) => + jsonify("D1Eapp1", ("d1e0", "d1e1"), (jsonize(d1e0), jsonize(d1e1))) + +| D1Eapp2(d1e0, d1e1, d1e2) => + jsonify("D1Eapp2", ("d1e0", "d1e1", "d1e2"), + (jsonize(d1e0), jsonize(d1e1), jsonize(d1e2)) + ) +| D1Esqarg(s1es) => + jsonify("D1Esqarg", "s1es", jsonize_list(s1es)) +| D1Etqarg(s1es) => + jsonify("D1Etqarg", "s1es", jsonize_list(s1es)) +// +| D1Elist(d1es) => + jsonify("D1Elist", "d1es1", jsonize_list(d1es)) +| D1Elist(d1es1, d1es2) => + jsonify("D1Elist", ("d1es1", "d1es2"), + (jsonize_list(d1es1), jsonize_list(d1es2)) + ) +// +| D1Eseqn(d1es1, d1es2) => + jsonify("D1Eseqn", ("d1es1", "d1es2"), + (jsonize_list(d1es1), jsonize_list(d1es2)) + ) +// +| D1Etuple(tok, d1es) => + jsonify("D1Etuple", ("tok", "d1es"), (jsonize(tok), jsonize_list(d1es))) + +| D1Etuple(tok, d1es1, d1es2) => + jsonify("D1Etuple", ("tok", "d1es1", "d1es2"), + (jsonize(tok), jsonize_list(d1es1), jsonize_list(d1es2)) + ) +// +| D1Ebrack(d1es) => + jsonify("D1Ebrack", "d1es", jsonize_list(d1es)) + +| D1Edtsel(lab1, arg2) => + jsonify("D1Edtsel", ("lab1", "arg2"), (jsonize(lab1), jsonize_option(arg2))) +// +| D1Elet(d1cs, d1es) => + jsonify("D1Elet", ("d1cs", "d1es"), + (jsonize_list(d1cs), jsonize_list(d1es)) + ) +// +| D1Ewhere(d1e1, d1cs) => + jsonify("D1Ewhere", ("d1e1", "d1cs"), + (jsonize(d1e1), jsonize_list(d1cs)) + ) +// +| D1Eif0(d1e1, d1e2, opt3) => + jsonify("D1Eif0", ("d1e1", "d1e2", "opt3"), + (jsonize(d1e1), jsonize(d1e2), jsonize_option(opt3)) + ) +// +| D1Ecase(knd, d1e1, dcls) => + jsonify("D1Ecase", ("knd", "d1e1", "dcls"), + (jsonize(knd), jsonize(d1e1), jsonize_list(dcls)) + ) +// +| D1Elam + (knd, farg, tres, arrw, body) => + jsonify("D1Elam", ("knd", "farg", "tres", "arrw", "body"), + ( + jsonize(knd), + jsonize_list(farg), + jsonize(tres), + jsonize(arrw), + jsonize(body) + ) + ) + +| D1Efix + (knd, fid, farg, tres, arrw, body) => + jsonify( + "D1Efix", ("knd", "fid", "farg", "tres", "arrw", "body"), ( + jsonize(knd), + jsonize(fid), + jsonize_list(farg), + jsonize(tres), + jsonize(arrw), + jsonize(body) + ) + ) +// +| D1Erecord(tok, ld1es) => + jsonify ( + "D1Erecord", ("tok", "ld1es"), + ( + jsonize(tok), + jsonize_list(ld1es) + ) + ) +| D1Erecord(tok, ld1es1, ld1es2) => + jsonify ( + "D1Erecord", ("tok", "ld1es1", "ld1es2"), + ( + jsonize(tok), + jsonize_list(ld1es1), + jsonize_list(ld1es2) + ) + ) +| D1Eanno(d1e1, s1e2) => + jsonify("D1Eanno", ("d1e1", "s1e2"), (jsonize(d1e1), jsonize(s1e2))) +// +| D1Equal(tok1, d1e2) => + jsonify("D1Equal", ("tok1", "d1e2"), (jsonize(tok1), jsonize(d1e2))) +// +| D1Enone((*void*)) => jsonize("D1Enone") // ")") +// +) (* jsonize_d1exp *) +} + + +implement jsonize_val = jsonize_d1ecl +implement jsonize_val = jsonize_d1exp +implement jsonize_val = jsonize_v1aldecl +implement jsonize_val = jsonize_v1ardecl +implement jsonize_val = jsonize_g1exp + +implement jsonize_val = jsonize_f1undecl +implement jsonize_val = jsonize_f1arg +implement jsonize_val = jsonize_ti1arg +implement jsonize_val = jsonize_tq1arg +implement jsonize_val = jsonize_sq1arg + +implement jsonize_val = jsonize_g1marg +implement jsonize_val = jsonize_s1marg +implement jsonize_val = jsonize_t1marg +implement jsonize_val = jsonize_t0int + +implement jsonize_val = jsonize_d1atype +implement jsonize_val = jsonize_d1tsort +implement jsonize_val = jsonize_d1cstdecl + + +implement +jsonize_d1ecl + (x0) = +node("d1ecl", res) where +val res = +( +case+ x0.node() of +// +| D1Cnone() => + jsonify("D1Cnone") +| D1Cnone(d0c) => + jsonify("D1Cnone", "d0c", jsonize(d0c)) +// +| D1Cstatic(knd, d1c) => + jsonify("D1Cstatic", ("knd", "d1c"), (jsonize(knd), jsonize(d1c))) +// +| D1Cextern(knd, d1c) => + jsonify("D1Cextern", ("knd", "d1c"), (jsonize(knd), jsonize(d1c))) +// +| D1Cdefine + (tok, sym, arg, def) => + jsonify("D1Cdefine", ("tok", "sym", "arg", "def"), + ( + jsonize(tok), + jsonize(sym), + jsonize_list(arg), + jsonize_option(def) + ) + ) +| D1Cmacdef + (tok, sym, arg, def) => + jsonify("D1Cmacdef", ("tok", "sym", "arg", "def"), + ( + jsonize(tok), + jsonize(sym), + jsonize_list(arg), + jsonize_option(def) + ) + ) +// +| D1Cinclude + (tok, src, knd, opt, body) => + ( + jsonify("D1Cinclude", ("tok", "src", "knd", "opt", "body"), + ( + jsonize(tok), + jsonize(src), + jsonize(knd), + jsonize_option(opt), + jsonize(body) + ) + ) + ) where + { + val body = + ( + case+ body of + | None _ => "None()" + | Some _ => "Some()"): string + } +// +| D1Cstaload + ( tok, src, knd, opt, flag, body) => + ( + jsonify("D1Cstaload", + ("tok", "src", "knd", "opt", "flag", "body"), + ( + jsonize(tok), + jsonize(src), + jsonize(knd), + jsonize_option(opt), + jsonize(flag), + jsonize(body) + ) + ) + ) where + { + val body = + ( + case+ body of + | None _ => "None()" + | Some _ => "Some()") : string + } +// +| D1Cabssort(tok, tid) => + jsonify("D1Cabssort", ("tok", "tid"), (jsonize(tok), jsonize(tid))) +// +| D1Cstacst0 + (tok, sid, tmas, s0t) => + jsonify("D1Cstacst0", ("tok", "sid", "tmas", "s0t"), + ( + jsonize(tok), + jsonize(sid), + jsonize_list(tmas), + jsonize(s0t) + ) + ) +// +| D1Csortdef + (knd, tok, def) => + jsonify("D1Csortdef", ("knd", "tok", "def"), + (jsonize(knd), jsonize(tok), jsonize(def)) + ) +// +| D1Csexpdef + ( knd, sid, arg, res, def) => + jsonify("D1Csexpdef", ("knd", "sid", "arg", "res", "def"), + ( + jsonize(knd), + jsonize(sid), + jsonize_list(arg), + jsonize_option(res), + jsonize(def) + ) + ) +// +| D1Cabstype + (knd, sid, arg, res, def) => + jsonify("D1Cabstype", ("knd", "sid", "arg", "res", "def"), + ( + jsonize(knd), + jsonize(sid), + jsonize_list(arg), + jsonize_option(res), + jsonize(def) + ) + ) +// +| D1Cabsimpl + (tok, sqid, smas, res0, def1) => + jsonify("D1Cabsimpl", ("tok", "sqid", "smas", "res0", "def1"), + (jsonize(tok), + jsonize(sqid), + jsonize_list(smas), + jsonize_option(res0), + jsonize(def1)) + ) +// +| D1Cvaldecl + (tok, mods, d1cs) => + jsonify("D1Cvaldecl", ("tok", "mods", "d1cs"), + ( + jsonize(tok), + jsonize(mods), + jsonize_list(d1cs) + ) + ) +// +| D1Cvardecl(tok, mopt, d1cs) => + jsonify("D1Cvardecl", ("tok", "mopt", "d1cs"), + ( + jsonize(tok), + jsonize(mopt), + jsonize_list(d1cs) + ) + ) +// +| D1Cfundecl + (tok, mopt, tqas, d1cs) => + jsonify("D1Cfundecl", ("tok", "mopt", "tqas", "d1cs"), + ( + jsonize(tok), + jsonize(mopt), + jsonize_list(tqas), + jsonize_list(d1cs) + ) + ) +// +| D1Cimpdecl + (tok, mopt, sqas, tqas, dqid, tias, f1as, res0, teq1, d1e2) => + jsonify("D1Cimpdecl", + ("tok", "mopt", "sqas", "tqas", "dqid", "tias", "f1as", "res0", "teq1", "d1e2"), + ( + jsonize(tok), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(dqid), + jsonize_list(tias), + jsonize_list(f1as), + jsonize(res0), + jsonize(teq1), + jsonize(d1e2) + ) + ) +// +| D1Csymload + (knd, sym, dqid, tint) => + jsonify("D1Csymload", ("knd", "sym", "dqid", "tint"), + (jsonize(knd), jsonize(sym), jsonize(dqid), jsonize_option(tint)) + ) +// +| D1Cdatasort + (knd, d1tsts) => + jsonify("D1Cdatasort", ("knd", "d1tsts"), + ( + jsonize(knd), + jsonize_list(d1tsts) + ) + ) +// +| D1Cdatatype + (knd, d1typs, wopt) => + jsonify("D1Cdatatype", ("knd", "d1typs", "wopt"), + ( + jsonize(knd), + jsonize_list(d1typs), + jsonize(wopt) + ) + ) +// +| D1Cdynconst + (tok, tqas, d1cs) => + jsonify("D1Cdynconst", ("tok", "tqas", "d1cs"), + ( + jsonize(tok), + jsonize_list(tqas), + jsonize_list(d1cs) + ) + ) +// +| D1Clocal + (d1cs_head, d1cs_body) => + jsonify("D1Clocal", ("d1cs_head", "d1cs_body"), + ( + jsonize_list(d1cs_head), + jsonize_list(d1cs_body) + ) + ) +// +| D1Ctokerr(d0c0) => + jsonify("D1Ctokerr", "d0c0", jsonize(d0c0)) +// +(* +| _(*rest-of-d1ecl*) => + jsonize!(out, "jsonize_d1ecl: D1C...: not-yet-implemented") +*) +// +) (* end of [jsonize_d1ecl] *) +end + + +local + +implement +jsonize_val = jsonize_d1pat +implement +jsonize_val = jsonize_s1arg + +in (* in-of-local *) + +implement +jsonize_d1pat + (x0) = +node("d1pat", res) where +val res = +( +case+ +x0.node() of +| D1Pid(tok) => + jsonify("D1Pid", "tok", jsonize(tok)) +// +| D1Pint(tok) => + jsonify("D1Pint", "tok", jsonize(tok)) +| D1Pchr(tok) => + jsonify("D1Pchr", "tok", jsonize(tok)) +| D1Pflt(tok) => + jsonify("D1Pflt", "tok", jsonize(tok)) +| D1Pstr(tok) => + jsonify("D1Pstr", "tok", jsonize(tok)) +// +| D1Papp() => + jsonify("D1Papp") +// +| D1Pbs0() => + jsonify("D1Pbs0") +| D1Pbs1(d1p) => + jsonify("D1Pbs1", "d1p", jsonize(d1p)) +// +| D1Papp1(d1p0, d1p1) => + jsonify("D1Papps", ("d1p0", "d1p1"), (jsonize(d1p0), jsonize(d1p1))) +| D1Papp2(d1p0, d1p1, d1p2) => + jsonify("D1Papps", ("d1p0", "d1p1", "d1p2"), (jsonize(d1p0), jsonize(d1p1), jsonize(d1p2))) +// +| D1Psarg(s1as) => + jsonify("D1Psarg", "s1as", jsonize_list(s1as)) +// +| D1Plist(d1ps) => + jsonify("D1Plist1", "d1ps", jsonize_list(d1ps)) +| D1Plist(d1ps1, d1ps2) => + jsonify("D1Plist2", ("d1ps1", "d1ps2"), (jsonize_list(d1ps1), jsonize_list(d1ps2))) +// +| D1Ptuple(tok, d1ps) => + jsonify("D1Ptuple1", ("tok", "d1ps"), (jsonize(tok), jsonize_list(d1ps))) +| D1Ptuple(tok, d1ps1, d1ps2) => + jsonify("D1Ptuple2", ("tok", "d1ps1", "d1ps2"), + ( + jsonize(tok), + jsonize_list(d1ps1), + jsonize_list(d1ps2) + ) + ) +// +| D1Precord(tok, ld1ps) => + jsonify("D1Precord1", ("tok", "ld1ps"), + (jsonize(tok), jsonize_list(ld1ps)) + ) +| D1Precord(tok, ld1ps1, ld1ps2) => + jsonify("D1Precord2", ("tok", "ld1ps1", "ld1ps2"), + ( + jsonize(tok), + jsonize_list(ld1ps1), + jsonize_list(ld1ps2) + ) + ) +// +| D1Panno(d1p, s1e) => + jsonify("D1Panno", ("d1p", "s1e"), (jsonize(d1p), jsonize(s1e))) +// +| D1Pnone((*void*)) => + jsonify("D1Pnone") +// +) (* end of [jsonize_d1pat] *) +end + +end // end of [local] + + +implement jsonize_val = jsonize_s1exp + +implement +jsonize_f1unarrow + (x0) = +node("f1unarrow", res) where +val res = +( +case+ x0 of +| F1UNARROWdflt() => + jsonify("F1UNARROWdflt") +| F1UNARROWlist(s1es) => + jsonify("F1UNARROWlist", "s1es", jsonize_list(s1es)) +) (* end of [jsonize_f1unarrow] *) +end + +implement +jsonize_teqd1expopt + (x0) = +node("teqd1expopt", res) where +val res = +( +case+ x0 of +| TEQD1EXPnone() => + jsonify("TEQD1EXPnone") + +| TEQD1EXPsome(tok, d1e) => + jsonify("TEQD1EXPsome", ("tok", "d1e"), (jsonize(tok), jsonize(d1e))) +) +end + +implement +jsonize_wths1expopt + (x0) = +node("wths1expopt", res) where +val res = +( +case+ x0 of +| WTHS1EXPnone() => + jsonify("WTHS1EXPnone") +| WTHS1EXPsome(tok, s1e) => + jsonify("WTHS1EXPsome", ("tok", "s1e"), (jsonize(tok), jsonize(s1e))) +) +end + +implement +jsonize_d1gua + (x0) = +node("d1gua", res) where +val res = +( +case+ +x0.node() of +| D1GUAexp(d1e) => + jsonify("D1GUAexp", "d1e", jsonize(d1e)) +| D1GUAmat(d1e, d1p) => + jsonify("D1GUAexp", ("d1e", "d1p"), (jsonize(d1e), jsonize(d1p))) +) (* end of [jsonize_d1gua] *) +end + + +implement +jsonize_d1clau + (x0) = +node("d1clau", res) where +val res = +( +case+ +x0.node() of +| D1CLAUgpat(d1gp) => + jsonify("D1CLAUgpat", "d1gp", jsonize(d1gp)) +| D1CLAUclau(d1gp, d0e0) => + jsonify("D1CLAUclau", ("d1gp", "d0e0"), (jsonize(d1gp), jsonize(d0e0))) +) (* end of [jsonize_d1clau] *) +end + +implement +jsonize_val = jsonize_d1gua + +implement +jsonize_d1gpat + (x0) = +node("d1gpat", res) where +val res = +( +case+ +x0.node() of +| D1GPATpat(d1p) => + jsonify("D1GPATpat", "d1p", jsonize(d1p)) +| D1GPATgua(d1p, d1gs) => + jsonify("D1GPATgua", ("d1p", "d1gs"), (jsonize(d1p), jsonize_list(d1gs))) +) (* end of [jsonize_d1gpat] *) +end + +implement +jsonize_abstdf1 + (x0) = +node("abstdf1", res) where +val res = +( +case+ x0 of +| ABSTDF1some() => + jsonify("ABSTDF1some") +| ABSTDF1lteq(s0e) => + jsonify("ABSTDF1lteq", "s0e", jsonize(s0e)) +| ABSTDF1eqeq(s0e) => + jsonify("ABSTDF1eqeq", "s0e", jsonize(s0e)) +) (* end of [jsonize_abstdf1] *) +end + +implement +jsonize_wd1eclseq + (x0) = +node("wd1eclseq", res) where +val res = +( +case+ x0 of +| WD1CSnone() => + jsonify("WD1CSnone") +| WD1CSsome(d1cs) => + jsonify("WD1CSsome", "d1cs", jsonize_list(d1cs)) +) (* end of [jsonize_wd1eclseq] *) +end + +implement +jsonize_v1aldecl + (x0) = let +// +val+V1ALDECL(rcd) = x0 +// +in +node("v1aldecl", res) where +val res = + + jsonify("V1ALDECL", ("pat", "def", "wtp"), + ( + jsonize(rcd.pat), + jsonize_option(rcd.def), + jsonize(rcd.wtp) + ) + ) +end + +end // end of [jsonize_v1aldecl] + + +implement +jsonize_v1ardecl + (x0) = let +// +val+V1ARDECL(rcd) = x0 +// +in +node("v1ardecl", res) where +val res = + + jsonify("V1ARDECL", ("nam", "wth", "res", "ini"), + ( + jsonize(rcd.nam), + jsonize_option(rcd.wth), + jsonize_option(rcd.res), + jsonize(rcd.ini) + ) + ) +end + +end // end of [jsonize_v1ardecl] + + +implement +jsonize_f1undecl + (x0) = let +// +val+F1UNDECL(rcd) = x0 +// +in +node("f1undecl", res) where +val res = + jsonify("F1UNDECL", ("nam", "arg", "res", "def", "wtp"), + ( + jsonize(rcd.nam), + jsonize_list(rcd.arg), + jsonize(rcd.res), + jsonize_option(rcd.def), + jsonize(rcd.wtp) + ) + ) +end +end // end of [jsonize_f1undecl] + + +implement jsonize_val = jsonize_d1arg + +implement +jsonize_d1cstdecl + (x0) = let +// +val+D1CSTDECL(rcd) = x0 +// +in +node("d1cstdecl", res) where +val res = + jsonify( + "D1CSTDEC", ("nam", "arg", "res", "def"), + ( + jsonize(rcd.nam), + jsonize_list(rcd.arg), + jsonize(rcd.res), + jsonize(rcd.def) + ) + ) +end +end // end of [jsonize_d1cstdecl] diff --git a/contrib/sparverius/xjsonize/DATS/dynexp2.dats b/contrib/sparverius/xjsonize/DATS/dynexp2.dats new file mode 100644 index 000000000..6f4481726 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/dynexp2.dats @@ -0,0 +1,895 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" +(* +#staload "{$XATS}/SATS/dynexp0.sats" +#staload "{$XATS}/SATS/staexp0.sats" +*) +#staload "{$XATS}/SATS/dynexp1.sats" +#staload "{$XATS}/SATS/dynexp2.sats" +(* #staload "{$XATS}/SATS/staexp2.sats" *) + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/lexing.sats" +#staload "./../SATS/locinfo.sats" + +#staload "./../SATS/label0.sats" +#staload "./../SATS/filpath.sats" + +#staload "./../SATS/dynexp0.sats" +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/dynexp1.sats" + +#staload "./../SATS/dynexp2.sats" + + +#staload "./../SATS/staexp2.sats" + +#staload SYM_J = "./../SATS/symbol.sats" +#staload STM_J = "./../SATS/stamp0.sats" + +(* overload jsonize with $D1.jsonize_d1exp *) +(* overload jsonize with $D1.jsonize_d1ecl *) + +overload jsonize with $SYM_J.jsonize_symbol +overload jsonize with $STM_J.jsonize_stamp + + +implement +jsonize_val = jsonize_s2exp +implement +jsonize_val = jsonize_filpath + + +implement +jsonize_val = jsonize_d2con + +implement +jsonize_d2con + (x0) = +( + (* jsonval_labval1("d2con", rst) where *) + node("d2con", rst) where + val lst = $list{labjsonval}($SYM_J.labify_symbol(x0.sym()), $STM_J.labify_stamp(x0.stamp())) + val rst = JSONlablist(lst) + end + +) + +implement +jsonize_val = jsonize_d2cst + +implement +jsonize_d2cst + (x0) = +( + (* jsonval_labval1("d2cst", rst) where *) + (* node("d2cst", rst) where *) + node2("d2cst", jsonize(x0.loc()), rst) where + (* rst where *) + val lst = $list{labjsonval}( + $SYM_J.labify_symbol(x0.sym()), $STM_J.labify_stamp(x0.stamp()) + ) + val rst = JSONlablist(lst) + end + +) + + + + +implement +jsonize_val = jsonize_d2var + +implement +jsonize_d2var + (x0) = + (* jsonval_labval1("d2var", rst) where *) + (* node("d2var", rst) where *) + node2("d2var", jsonize(x0.loc()), rst) where + (* rst where *) + val lst = $list{labjsonval}( + $SYM_J.labify_symbol(x0.sym()), $STM_J.labify_stamp(x0.stamp()) + ) + val rst = JSONlablist(lst) + end + + +implement +jsonize_val = jsonize_f2arg +implement +jsonize_val = jsonize_d2pat +implement +jsonize_val = jsonize_s2var +implement +jsonize_val = jsonize_s2exp + + +implement +jsonize_f2arg + (x0) = +(* jsonval_labval1("f2arg", rst) where *) +(* res where *) +(* node("f2arg", res) where *) +node2("f2arg", jsonize(x0.loc()), res) where +(* +let +in +*) +val res = +( +// +case+ +x0.node() of +(* +| F2ARGnone(tok) => + jsonize("F2ARGnone", "tok", jsonize(tok)) +*) +| F2ARGsome_met(s2es) => + jsonify("F2ARGsome_met", "s2es", jsonize_list(s2es)) +| F2ARGsome_dyn(npf, d2ps) => + jsonify("F2ARGsome_dyn", ("npf", "d2ps"), + (jsonval_labval1("npf", jsonize(npf)), + jsonize_list(d2ps) + ) + ) +| F2ARGsome_sta(s2vs, s2ps) => + jsonify("F2ARGsome_sta", ("s2vs", "s2ps"), + ( + jsonize_list(s2vs), + jsonize_list(s2ps) + ) + ) +) +end + + + + +implement +jsonize_val = jsonize_d2pat +implement +jsonize_val = jsonize_s2var + +implement +jsonize_val = jsonize_d2pitm + + +implement +jsonize_d2pat + (x0) = +(* jsonval_labval1("d2pat", res) where *) +// labval2(jsonize("d2pat"), res) where +(* res where *) +node("d2pat", res) where +val res = +( +case- x0.node() of +// +| D2Pint(tok) => + jsonify("D2Pint", "tok", jsonize(tok)) +| D2Pbtf(tok) => + jsonify("D2Pbtf", "tok", jsonize(tok)) +| D2Pchr(tok) => + jsonify("D2Pchr", "tok", jsonize(tok)) +| D2Pflt(tok) => + jsonify("D2Pflt", "tok", jsonize(tok)) +| D2Pstr(tok) => + jsonify("D2Pstr", "tok", jsonize(tok)) +// +| D2Pvar(d2v) => + jsonify("D2Pvar", "d2v", jsonize(d2v)) +// +| D2Pcon1(d2c0) => + jsonify("D2Pcon1", "d2c0", jsonize(d2c0)) +| D2Pcon2(d2cs) => + jsonify("D2Pcon2", "d2cs", jsonize_list(d2cs)) +// +| D2Psym0(sym, d2pis) => + jsonify("D2Psym0", ("sym", "d2pis"), (jsonize(sym), jsonize_list(d2pis))) +// +| D2Psapp(d2f0, s2vs) => + jsonify("D2Psapp", ("d2f0", "s2vs"), + (jsonize(d2f0), jsonize_list(s2vs)) + ) +| D2Pdapp(d2f0, npf0, d2ps) => + jsonify("D2Pdapp", ("d2f0", "npf0", "d2ps"), + (jsonize(d2f0), jsonval_labval1("npf", jsonize(npf0)), jsonize_list(d2ps)) + ) +// +| D2Ptuple(knd, npf, d2ps) => + jsonify("D2Ptuple", ("knd", "npf", "d2ps"), + (jsonize(knd), jsonval_labval1("npf", jsonize(npf)), jsonize_list(d2ps)) + ) +// +| D2Panno(d2p1, s2e2) => + jsonify("D2Panno", ("d2p1", "s2e2"), (jsonize(d2p1), jsonize(s2e2))) +// +| D2Pnone0() => + jsonify("D2Pnone0") +| D2Pnone1(d1psrc) => + jsonify("D2Pnone1", "d1psrc", jsonize(d1psrc)) +// +) (* end of [jsonize_d2pat] *) +end + + +implement +jsonize_val = jsonize_d2exp +implement +jsonize_val = jsonize_d2ecl +implement +jsonize_val = jsonize_d2pitm +implement +jsonize_val = jsonize_s2exp +implement +jsonize_val = jsonize_d2clau + +implement +jsonize_val = jsonize_f2arg +implement +jsonize_val = jsonize_effs2expopt + + +implement +jsonize_d2exp + (x0) = +(* jsonval_labval1("d2exp", res) where *) +(* res where *) +node("d2exp", res) where +val res = +( +case+ x0.node() of +// +| D2Eint(tok) => + jsonify("D2Eint", "tok", jsonize(tok)) +| D2Ebtf(tok) => + jsonify("D2Ebtf", "tok", jsonize(tok)) +| D2Echr(tok) => + jsonify("D2Echr", "tok", jsonize(tok)) +| D2Eflt(tok) => + jsonify("D2Eflt", "tok", jsonize(tok)) +| D2Estr(tok) => + jsonify("D2Estr", "tok", jsonize(tok)) +// +| D2Etop(tok) => + jsonify("D2Etop", "tok", jsonize(tok)) +// +| D2Evar(d2v) => + + jsonify("D2Evar", "d2v", jsonize(d2v)) +// +| D2Ecst1(d2c) => + jsonify("D2Ecst1", "d2c", jsonize(d2c)) +| D2Econ1(d2c) => + jsonify("D2Econ1", "d2c", jsonize(d2c)) +| D2Ecst2(d2cs) => + jsonify("D2Ecst2", "d2cs", jsonize_list(d2cs)) +| D2Econ2(d2cs) => + jsonify("D2Econ2", "d2cs", jsonize_list(d2cs)) +// +| D2Esym0 + (d1e1, dpis) => + jsonify("D2Esym0", ("d1e1", "dpis"), (jsonize(d1e1), jsonize_list(dpis))) +// +| D2Esapp + (d2f0, s2as) => + jsonify("D2Esapp", ("d2f0", "s2as"), (jsonize(d2f0), jsonize_list(s2as))) +| D2Etapp + (d2f0, s2as) => + jsonify("D2Etapp", ("d2f0", "s2as"), (jsonize(d2f0), jsonize_list(s2as))) +| D2Edapp + (d2f0, npf0, d2as) => + jsonify( + "D2Edapp", ("d2f0", "npf0", "d2as"), + (jsonize(d2f0), jsonval_labval1("npf", jsonize(npf0)), jsonize_list(d2as))) +// +| D2Elet + (d2cs, d2e2) => + jsonify("D2Elet", ("d2cs", "d2e2"), (jsonize_list(d2cs), jsonize(d2e2))) +| D2Ewhere + (d2e1, d2cs) => + jsonify("D2Ewhere", ("d2e1", "d2cs"), (jsonize(d2e1), jsonize_list(d2cs))) +// +| D2Eseqn + (d2es, d1e1) => + jsonify("D2Eseqn", ("d2es", "d1e1"(*last*)), + (jsonize_list(d2es), jsonize(d1e1))) +// +| D2Etuple + (knd, npf, d2es) => + jsonify("D2Etuple", ("knd", "npf", "d2es"), + (jsonize(knd), jsonval_labval1("npf", jsonize(npf)), jsonize_list(d2es))) +// +| D2Eassgn + (d2e1, d2e2) => + jsonify("D2Eassgn", ("d2e1", "d2e2"), (jsonize(d2e1), jsonize(d2e2))) +// +| D2Edtsel + (lab0, dpis, npf2, arg3) => + ( + case+ arg3 of + | None() => + jsonify("D2Edtsel", ("lab0", "dpis"), (jsonize(lab0), jsonize_list(dpis))) + | Some(d2es) => + jsonify("D2Edtsel", ("lab0", "dpis", "npf2", "d2es"), + ( + jsonize(lab0), + jsonize_list(dpis), + jsonval_labval1("npf", jsonize(npf2)), + jsonize_list(d2es) + ) + ) + ) +// +| D2Eif0 + (d2e1, d2e2, opt3) => + jsonify("D2Eif0", ("d2e1", "d2e2", "opt3"), + (jsonize(d2e1), jsonize(d2e2), jsonize_option(opt3))) +// +| D2Ecase + (knd, d2e1, d2cls) => + jsonify("D2Ecase", ("knd", "d2e1", "d2cls"), + (jsonize(knd), jsonize(d2e1), jsonize_list(d2cls))) +// +| D2Elam + (knd, f2as, tres, arrw, body) => + jsonify("D2Elam", ("knd", "f2as", "tres", "arrw", "body"), + ( + jsonize(knd), + jsonize_list(f2as), + jsonize(tres), + jsonize(arrw), + jsonize(body) + ) + ) +| D2Efix + (knd, fid, f2as, tres, arrw, body) => + jsonify("D2Efix", ("knd", "fid", "f2as", "tres", "arrw", "body"), + ( + jsonize(knd), + jsonize(fid), + jsonize_list(f2as), + jsonize(tres), + jsonize(arrw), + jsonize(body) + ) + ) +// +(* +| D2Eflat(d2e1) => + fprint!(out, "D2Eflat(", d2e1, ")") +*) +// +| D2Eaddr(d2e1) => + jsonify("D2Eaddr", "d2e1", jsonize(d2e1)) +| D2Eeval(d2e1) => + jsonify("D2Eeval", "d2e1", jsonize(d2e1)) +| D2Efold(d2e1) => + jsonify("D2Efold", "d2e1", jsonize(d2e1)) +// +| D2Elazy(d2e1) => + jsonify("D2Elazy", "d2e1", jsonize(d2e1)) +| D2Ellazy(d2e1, opt2) => + jsonify("D2Ellazy", ("d2e1", "opt2"), (jsonize(d2e1), jsonize_option(opt2))) +// +| D2Eanno(d2e1, s2e2) => + jsonify("D2Eanno", ("d2e1", "s2e2"), (jsonize(d2e1), jsonize(s2e2))) +// +| D2Enone0() => + jsonify("D2Enone0") +| D2Enone1(d1esrc) => + jsonify("D2Enone1", "d1esrc", jsonize(d1esrc)) +// +) +end // end of where + + + + + + +local + +implement +jsonize_val = jsonize_d2ecl +implement +jsonize_val = jsonize_v2aldecl +implement +jsonize_val = jsonize_v2ardecl +implement +jsonize_val = jsonize_f2undecl + +implement +jsonize_val = jsonize_f2arg +implement +jsonize_val = jsonize_ti2arg +implement +jsonize_val = jsonize_tq2arg +implement +jsonize_val = jsonize_sq2arg + +overload jsonize with jsonize_loc_t of 1 + +in (* in-of-local *) + +implement +jsonize_d2ecl + (x0) = +(* jsonval_labval1("d2ecl", res) where *) +(* res where *) +(* node("d2ecl", res) where *) +node2("d2ecl", jsonize(x0.loc()), res) where +(* +val _ = $showtype(x0.loc()) +val _ = $showtype((x0.loc()).beg_ntot()) +*) +val res = +( +case- x0.node() of +// +| D2Cstatic + (tok, d2c) => + jsonify("D2Cstatic", "d2c", jsonize(d2c)) +| D2Cextern + (tok, d2c) => + jsonify("D2Cextern", ("tok", "d2c"), (jsonize(tok), jsonize(d2c))) +// +| D2Cinclude + ( tok + , src, knd + , fopt, body) => + jsonify("D2Cinclude", + ( + "tok", "src", "knd", "fopt", "body" + ), + ( + jsonize(tok), + jsonize(src), + jsonize(knd), + jsonize_option(fopt), + jsonize(body) + ) where + + val body = + ( + case+ body of + | None _ => "None()" + | Some _ => "Some()" + ): string + end + ) +// +| D2Cstaload + ( tok + , src, knd + , fopt, flag, body) => + jsonify("D2Cinclude", + ( + "tok", "src", "knd", "fopt", "flag", "body" + ), + ( + jsonize(tok), + jsonize(src), + jsonize(knd), + jsonize_option(fopt), + jsonize(flag), + jsonize(body) + ) where + val body = + ( + case+ body of + | None _ => "None()" + | Some _ => "Some()" + ): string + end + ) +// +| D2Clocal(head, body) => + jsonify("D2Clocal", ("head", "body"), + ( + jsonize_list(head), + jsonize_list(body) + ) + ) +// +| D2Cabssort(d1c) => + jsonify("D2Cabssort", "d1c", jsonize("...")) +// +| D2Cstacst0(s2c, s2t) => + jsonify("D2Cstacst0", ("s2c", "s2t"), (jsonize(s2c), jsonize(s2t))) +// +| D2Csortdef(sym, s2tx) => + jsonify("D2Csortdef", ("sym", "s2tx"), + (jsonize(sym), jsonize(s2tx)) + ) +// +| D2Csexpdef(s2c, s2e) => + jsonify("D2Csexpdef", ("s2c", "s2e"), (jsonize(s2c), jsonize(s2e))) +// +| D2Cabstype(s2c, df2) => + jsonify("D2Cabstype", ("s2c", "df2"), (jsonize(s2c), jsonize(df2))) +// +| D2Cabsimpl + (knd, sqid, def0) => + jsonify( + "D2Csymload", + ( + "knd", "sqid", "def0" + ), + ( + jsonize(knd), + jsonize(sqid), + jsonize(def0) + ) + ) + +// +| D2Csymload + (tok, sym0, dpi1) => + jsonify( + "D2Csymload", + ( + "tok", "sym0", "dpi1" + ), + ( + jsonize(tok), + jsonize(sym0), + jsonize(dpi1) + ) + ) +// +| D2Cvaldecl + (knd, mopt, v2ds) => + jsonify( + "D2Cvaldecl", + ( + "knd", "mopt", "v2ds" + ), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(v2ds) + ) + ) + +| D2Cfundecl + (knd, mopt, tqas, f2ds) => + jsonify( + "D2Cfundecl", + ( + "knd", "mopt", "tqas", "f2ds" + ), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(tqas), + jsonize_list(f2ds) + ) + ) + +// +| D2Cvardecl(knd, mopt, v2ds) => + jsonify( + "D2Cvardecl", ("knd", "mopt", "v2ds"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(v2ds) + ) + ) +// +| D2Cimpdecl1 + ( knd, mopt, sqas, tqas + , dqid, tias, f2as, res0, d2e1) => + jsonify( + "D2Cimpdecl1", + ( + "knd", "mopt", "sqas", "tqas", "dqid", "tias", "f2as", "res0", "d2e1" + ), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(dqid), + jsonize_list(tias), + jsonize_list(f2as), + jsonize(res0), + jsonize(d2e1) + ) + ) +| D2Cimpdecl2 + ( knd, mopt, sqas, tqas + , dqid, tias, f2as, res0, d2e1) => + jsonify( + "D2Cimpdecl2", + ( + "knd", "mopt", "sqas", "tqas", "dqid", "tias", "f2as", "res0", "d2e1" + ), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(dqid), + jsonize_list(tias), + jsonize_list(f2as), + jsonize(res0), + jsonize(d2e1) + ) + ) +// +| D2Cdatasort(d1c) => + jsonify("D2Cdatasort", "d1c", jsonize(d1c)) +| D2Cdatatype(d1c) => + jsonify("D2Cdatatype", "d1c", jsonize(d1c)) +// +| D2Cdynconst + (knd, tqas, d2cs) => + jsonify( + "D2Cdynconst", + ( + "knd", "tqas", "d2cs" + ), + ( + jsonize(knd), + jsonize_list(tqas), + jsonize_list(d2cs) + ) + ) +// +| D2Cnone0() => + jsonify("D2Cnone0") +| D2Cnone1(d1csrc) => + jsonify("D2Csortdef", "d1csrc", jsonize(d1csrc)) +// +) (* end of [jsonize_d2ecl] *) +end + +end // end of [local] + + + +implement +jsonize_d2itm + (x0) = +(* jsonval_labval1("d2itm", res) where *) +node("d2itm", res) where +val res = +( +case+ x0 of +// +| D2ITMvar(d2v0) => + jsonify("D2ITMvar", "d2v0", jsonize(d2v0)) +// +| D2ITMcon(d2cs) => + jsonify("D2ITMcon", "d2cs", jsonize_list(d2cs)) +// +| D2ITMcst(d2cs) => + jsonify("D2ITMcst", "d2cs", jsonize_list(d2cs)) +// +| D2ITMsym(sym, dpis) => + jsonify("D2ITMsym", ("sym", "dpis"), (jsonize(sym), jsonize_list(dpis))) +// +) (* end of [jsonize_d2itm] *) +end + +implement +jsonize_d2pitm + (x0) = +(* jsonval_labval1("d2pitm", res) where *) +(* res where *) +node("d2pitm", res) where +val res = +( +case+ x0 of +| D2PITMnone(dqid) => + jsonify("D2PITMnone", "dqid", jsonize(dqid)) +| D2PITMsome(pval, d2i0) => + jsonify("D2PITMsome", ("pval", "d2i0"), (jsonize(pval), jsonize(d2i0))) +) (* end of [jsonize_d2pitm] *) +end + +local + +implement +jsonize_val = jsonize_s2var + +in + +implement +jsonize_sq2arg + (x0) = +( + (* jsonval_labval1("sq2arg", jsonize_list(x0.s2vs())) *) + node("sq2arg", jsonize_list(x0.s2vs())) +) (* end of [jsonize_sq2arg] *) + + + +implement +jsonize_tq2arg + (x0) = +( + (* jsonval_labval1("tq2arg", jsonize_list(x0.s2vs())) *) + node("tq2arg", jsonize_list(x0.s2vs())) +) (* end of [jsonize_tq2arg] *) + +end + +implement +jsonize_ti2arg + (x0) = +( + (* jsonval_labval1("ti2arg", jsonize_list(x0.s2es())) *) + node("ti2arg", jsonize_list(x0.s2es())) +) (* end of [jsonize_ti2arg] *) + + +local + +implement +jsonize_val = jsonize_d2cst + +in + +implement +jsonize_impld2cst + (x0) = +(* jsonval_labval1("impld2cst", res) where *) +(* res where *) +node("impld2cst", res) where +val res = +( +case+ x0 of +| +IMPLD2CST1(dqid, d2cs) => + jsonify("IMPLD2CST1", ("d2qid", "d2cs"), ( + jsonize(dqid), jsonize_list(d2cs)) + ) +| +IMPLD2CST2(dqid, d2cs, opt2) => + jsonify("IMPLD2CST2", ("d2qid", "d2cs", "opt2"), ( + jsonize(dqid), jsonize_list(d2cs), jsonize_option(opt2) + ) + ) +) // end of [jsonize_impld2cst] +end + +implement +jsonize_val = jsonize_s2cst + +implement +jsonize_impls2cst + (x0) = +node("impls2cst", res) where +val res = +( +case+ x0 of +| IMPLS2CST1(sqid, s2cs) => + jsonify("IMPLS2CST1", ("sqid", "s2cs"), + (jsonize(sqid), jsonize_list(s2cs)) + ) +| IMPLS2CST2(sqid, s2cs, opt2) => + jsonify("IMPLS2CST2", ("sqid", "s2cs", "opt2"), + ( + jsonize(sqid), + jsonize_list(s2cs), + jsonize_option(opt2) + ) + ) +) // end of [jsonize_impls2cst] +end + +end + + +implement +jsonize_d2clau + (x0) = +(* jsonval_labval1("d2clau", res) where *) +(* res where *) +node("d2clau", res) where +val res = +( +case+ +x0.node() of +| D2CLAUpat(d2gp) => + jsonify("D2CLAUpat", "d2gp", jsonize(d2gp)) +| D2CLAUexp(d2gp, d0e0) => + jsonify("D2CLAUexp", ("d2gp", "d0e0"), (jsonize(d2gp), jsonize(d0e0))) +) +end + +implement +jsonize_d2gpat + (x0) = +(* jsonval_labval1("d2gpat", res) where *) +(* res where *) +node("d2gpat", res) where +val res = +( +case+ +x0.node() of +| D2GPATpat(d2p) => + jsonify("D2GPATpat", "d2p", jsonize(d2p)) +| D2GPATgua(d2p, d2gs) => + jsonify("D2GPATgua", ("d2p", "d2gs"), (jsonize(d2p), jsonize("..."))) +) +end + +implement +jsonize_v2aldecl + (x0) = let +// +val+V2ALDECL(rcd) = x0 +// +in + node("v2aldecl", res) where + (* node2("v2arlecl", jsonize(rcd.loc), res) where *) + val res = + jsonify("V2ALDECL", ("pat", "def", "wtp"), + ( + jsonize(rcd.pat), + jsonize_option(rcd.def), + jsonize_option(rcd.wtp) + ) + ) + end +end // end of [jsonize_v2aldecl] + + +implement +jsonize_v2ardecl + (x0) = let +// +val+V2ARDECL(rcd) = x0 +// +in + node("v2ardecl", res) where + (* node2("v2ardecl", jsonize(rcd.loc), res) where *) + val res = + jsonify( + "V2ARDECL", ("d2v", "wth", "res", "ini"), + ( + jsonize(rcd.d2v), + jsonize_option(rcd.wth), + jsonize_option(rcd.res), + jsonize_option(rcd.ini) + ) + ) + end +end // end of [jsonize_v2ardecl] + + +implement +jsonize_f2undecl + (x0) = let +// +val+F2UNDECL(rcd) = x0 +// +in + node("f2undecl", res) where + (* node2("f2undecl", jsonize(rcd.loc), res) where *) + val res = + jsonify("F2UNDECL", ("nam", "d2c", "arg", "res", "def", "wtp"), + ( + jsonize(rcd.nam), + jsonize(rcd.d2c), + jsonize_list(rcd.arg), + jsonize(rcd.res), + jsonize_option(rcd.def), + jsonize_option(rcd.wtp) + ) + ) + end +end // end of [jsonize_f2undecl] diff --git a/contrib/sparverius/xjsonize/DATS/dynexp3.dats b/contrib/sparverius/xjsonize/DATS/dynexp3.dats new file mode 100644 index 000000000..2573ee90a --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/dynexp3.dats @@ -0,0 +1,774 @@ + +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/dynexp1.sats" +#staload "{$XATS}/SATS/dynexp2.sats" +#staload "{$XATS}/SATS/dynexp3.sats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/lexing.sats" +#staload "./../SATS/label0.sats" +#staload "./../SATS/filpath.sats" + +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/dynexp0.sats" + +#staload "./../SATS/staexp1.sats" +#staload "./../SATS/dynexp1.sats" + +#staload "./../SATS/statyp2.sats" + +#staload "./../SATS/staexp2.sats" +#staload "./../SATS/dynexp2.sats" + +#staload "./../SATS/dynexp3.sats" + + +implement +jsonize_val = jsonize_filpath + + +implement +jsonize_val = jsonize_s2exp +implement +jsonize_val = jsonize_d2exp +implement +jsonize_val = jsonize_d3pat + +implement +jsonize_val = jsonize_d2pitm +implement +jsonize_val = jsonize_s2var +implement +jsonize_val = jsonize_d2var +implement +jsonize_val = jsonize_d2cst +implement +jsonize_val = jsonize_d2con +implement +jsonize_val = jsonize_ti2arg +implement +jsonize_val = jsonize_tq2arg +implement +jsonize_val = jsonize_sq2arg +implement +jsonize_val = jsonize_f2arg + +implement +jsonize_val = jsonize_t2ype + +implement +jsonize_val = jsonize_d3ecl +implement +jsonize_val = jsonize_d3clau +implement +jsonize_val = jsonize_f3arg +implement +jsonize_val = jsonize_d3gua +implement +jsonize_val = jsonize_v3aldecl +implement +jsonize_val = jsonize_v3ardecl +implement +jsonize_val = jsonize_f3undecl +implement +jsonize_val = jsonize_d3exp + + +implement +jsonize_d3pat + (x0) = +node("d3pat", res) where +val res = +( +case- x0.node() of +// +| D3Pnil() => + jsonify("D3Pnil") +| D3Pany() => + jsonify("D3Pany") +// +| D3Pint(tok) => + jsonify("D3Pint", "tok", jsonize(tok)) +| D3Pbtf(tok) => + jsonify("D3Pbtf", "tok", jsonize(tok)) +| D3Pchr(tok) => + jsonify("D3Pchr", "tok", jsonize(tok)) +| D3Pflt(tok) => + jsonify("D3Pflt", "tok", jsonize(tok)) +| D3Pstr(tok) => + jsonify("D3Pstr", "tok", jsonize(tok)) +// +| D3Pvar(d2v) => + jsonify("D3Pvar", "d2v", jsonize(d2v)) +// +| D3Pcon1(d2c0) => + jsonify("D3Pcon1", "d2c0", jsonize(d2c0)) +| D3Pcon2(d2cs) => + jsonify("D3Pcon2", "d2cs", jsonize_list(d2cs)) +// +| D3Psym0(sym0, d2pis) => + jsonify("D3Psym0", ("sym0", "d2pis"), + (jsonize(sym0), jsonize_list(d2pis)) + ) +// +| D3Pdapp + (d3f0, npf0, d3ps) => + jsonify("D3Pdapp", ("d3f0", "npf0", "d3ps"), + (jsonize(d3f0), jsonize(npf0), jsonize_list(d3ps)) + ) +// +| D3Ptuple + (knd1, npf2, ldps) => + jsonify("D3Ptuple", ("knd1", "npf2", "ldps"), + (jsonize(knd1), jsonize(npf2), jsonize_list(ldps)) + ) +// +| D3Panno(d3p1, s2e2) => + jsonify("D3Panno", ("d3p1", "s2e2"), (jsonize(d3p1), jsonize(s2e2))) +// +| D3Ptcast(d3p1, t2p2) => + jsonify("D3Ptcast", ("d3p1", "t2p2"), (jsonize(d3p1), jsonize(t2p2))) +// +| D3Pnone0() => + jsonify("D3Pnone0") +| D3Pnone1(d1psrc) => + jsonify("D3Pnone1", "d1psrc", jsonize(d1psrc)) +| D3Pnone2(d2psrc) => + jsonify("D3Pnone2", "d2psrc", jsonize(d2psrc)) +// +) (* end of [jsonize_d3pat] *) +end + + +implement +jsonize_f3arg + (x0) = +node("f3arg", res) where +val res = +( +// +case+ +x0.node() of +// +| F3ARGnone2(f2a) => + jsonify("F3ARGnone2", "f2a", jsonize(f2a)) +| F3ARGnone3(f3a) => + jsonify("F3ARGnone2", "f3a", jsonize(f3a)) +// +| F3ARGsome_met(s2es) => + jsonify("F3ARGsome_met", "s2es", jsonize_list(s2es)) +// +| F3ARGsome_dyn(npf, d3ps) => + jsonify("F3ARGsome_dyn", ("npf", "d3ps"), + ( + jsonize(npf), + jsonize_list(d3ps) + ) + ) +| F3ARGsome_sta(s2vs, s2ps) => + jsonify("F3ARGsome_sta", ("s2vs", "s2ps"), + ( + jsonize_list(s2vs), + jsonize_list(s2ps) + ) + ) +// +) (* end of [jsonize_f3arg] *) +end + +implement +jsonize_d3exp + (x0) = +node("d3exp", res) where +val res = +( +case+ +x0.node() of +// +| D3Eint(tok) => + jsonify("D3Eint", "tok", jsonize(tok)) +| D3Ebtf(tok) => + jsonify("D3Ebtf", "tok", jsonize(tok)) +| D3Echr(tok) => + jsonify("D3Echr", "tok", jsonize(tok)) +| D3Eflt(tok) => + jsonify("D3Eflt", "tok", jsonize(tok)) +| D3Estr(tok) => + jsonify("D3Estr", "tok", jsonize(tok)) +// +| D3Etop(tok) => + jsonify("D3Etop", "tok", jsonize(tok)) +// +| D3Evar(d2v1) => + jsonify("D3Evar", "d2v1", jsonize(d2v1)) +// +| D3Econ1(d2c1) => + jsonify("D3Econ1", "d2c1", jsonize(d2c1)) +| D3Ecst1(d2c1) => + jsonify("D3Ecst1", "d2c1", jsonize(d2c1)) +// +| D3Econ2(d2cs) => + jsonify("D3Econ2", "d2cs", jsonize_list(d2cs)) +| D3Ecst2(d2cs) => + jsonify("D3Ecst2", "d2cs", jsonize_list(d2cs)) +// +| D3Esym0 + (d1e1, dpis) => +(* + jsonify("D3Esym0", d1e1) +*) +(* + jsonify("D3Esym0", d1e1, dpis) +*) +// (* + let + val t2p0 = x0.type() + in + jsonify("D3Esym0", ("d1e1", "t2p0"), (jsonize(d1e1), jsonize(t2p0))) + end +// *) +// +| D3Efcst(d2c1) => + jsonify("D3Efcst", "d2c1", jsonize(d2c1)) +// +| D3Etcst + (d2c1, ti3a, ti2s) => + jsonify("D3Etcst", ("d2c1", "ti3a", "ti2s"), + (jsonize(d2c1), jsonize(ti3a), jsonize_list(ti2s)) + ) +// +| D3Etimp + (d2e1, tsub1, d2c2, tsub2) => + jsonify("D3Etimp", ("d2e1", "tsub1", "d2c2", "tsub2"), + ( + jsonize(d2e1), + jsonize_list(tsub1), + jsonize(d2c2), + jsonize_list(tsub2) + ) + ) +// +| D3Esap0 + (d3e1, s2es) => + jsonify("D3Esap0", ("d3e1", "s2es"), + ( + jsonize(d3e1), + jsonize_list(s2es) + ) + ) +| D3Esap1 + (d3e1, s2es) => + jsonify("D3Esap1", ("d3e1", "s2es"), + ( + jsonize(d3e1), + jsonize_list(s2es) + ) + ) +// +| D3Etapp + (d2f0, s2es) => + jsonify("D3Etapp", ("d2f0", "s2es"), + ( + jsonize(d2f0), + jsonize_list(s2es) + ) + ) +// +| D3Edapp + (d3e1, npf2, d3es) => + jsonify("D3Edapp", ("d3e1", "npf2", "d3es"), + ( + jsonize(d3e1), + jsonize(npf2), + jsonize_list(d3es) + ) + ) +// +| D3Eproj + (d3e1, lab2, idx2) => + jsonify("D3Eproj", ("d3e1", "lab2", "idx2"), + ( + jsonize(d3e1), + jsonize(lab2), + jsonize(idx2) + ) + ) +// +| D3Elet(d3cs, d3e2) => + jsonify("D3Elet", ("d3cs", "d3e2"), + ( + jsonize_list(d3cs), + jsonize(d3e2) + ) + ) +| D3Ewhere(d3e1, d3cs) => + jsonify("D3Ewhere", ("d3e1", "d3cs"), + ( + jsonize(d3e1), + jsonize_list(d3cs) + ) + ) +// +| D3Eseqn(d3es, d3e2) => + jsonify("D3Eseqn", ("d3es", "d3e2"), + ( + jsonize_list(d3es), + jsonize(d3e2) + ) + ) +// +| D3Etuple + (knd1, npf2, d3es) => + jsonify("D3Etuple", ("knd1", "npf2", "d3es"), + ( + jsonize(knd1), + jsonize(npf2), + jsonize_list(d3es) + ) + ) +// +| D3Eassgn + (d3e1, d3e2) => + jsonify("D3Eassgn", ("d3e1", "d3e2"), (jsonize(d3e1), jsonize(d3e2))) +// +| D3Edtsel + (lab0, dpis, npf2, arg3) => + ( + case+ + arg3 of + | + None() => + jsonify("D2Edtsel", ("lab0", "dpis"), + ( + jsonize(lab0), + jsonize_list(dpis) + ) + ) + | + Some(d3es) => + jsonify("D2Edtsel", ("lab0", "dpis", "npf2", "d3es"), + ( + jsonize(lab0), + jsonize_list(dpis), + jsonize(npf2), + jsonize_list(d3es) + ) + ) + ) +// +| D3Eif0 + (d3e1, d3e2, opt3) => + jsonify("D3Eif0", ("d3e1", "d3e2", "opt3"), + ( + jsonize(d3e1), + jsonize(d3e2), + jsonize_option(opt3) + ) + ) +// +| D3Ecase + (knd0, d3e1, dcls) => + jsonify("D3Ecase", ("knd0", "d3e1", "dcls"), + ( + jsonize(knd0), + jsonize(d3e1), + jsonize_list(dcls) + ) + ) +// +| D3Elam + (knd, f3as, tres, arrw, body) => + jsonify("D3Elam", ("knd", "f3as", "tres", "arrw", "body"), + ( + jsonize(knd), + jsonize_list(f3as), + jsonize(tres), + jsonize(arrw), + jsonize(body) + ) + ) +| D3Efix + (knd, fid, f3as, tres, arrw, body) => + jsonify("D3Efix", ("knd", "fid", "f3as", "tres", "arrw", "body"), + ( + jsonize(knd), + jsonize(fid), + jsonize_list(f3as), + jsonize(tres), + jsonize(arrw), + jsonize(body) + ) + ) +// +| D3Eaddr(d3e1) => + ( + jsonify("D3Eaddr", "d3e1", jsonize(d3e1)) + ) +| D3Efold(d3e1) => + ( + jsonify("D3Efold", "d3e1", jsonize(d3e1)) + ) +// +| D3Eeval + (knd, d3e1) => + jsonify("D3Eeval", ("knd", "d3e1"), (jsonize(knd), jsonize(d3e1))) +// +| D3Elazy(d3e1) => + ( + jsonify("D3Elazy", "d3e1", jsonize(d3e1)) + ) +| D3Ellazy(d3e1, opt2) => + jsonify("D3Ellazy", ("d3e1", "opt2"), + ( + jsonize(d3e1), + jsonize_option(opt2) + ) + ) +// +| D3Eanno(d3e1, s2e2) => + jsonify("D3Eanno", ("d3e1", "s2e2"), (jsonize(d3e1), jsonize(s2e2))) +// +| D3Eflat(d3e1) => + ( + jsonify("D3Eflat", "d3e1", jsonize(d3e1)) + ) +| D3Etalf(d3e1) => + ( + jsonify("D3Etalf", "d3e1", jsonize(d3e1)) + ) +// +| D3Elcast(d3e1, lab2) => + jsonify("D3Elcast", ("d3e1", "lab2"), (jsonize(d3e1), jsonize(lab2))) +| D3Etcast(d3e1, t2p2) => + jsonify("D3Etcast", ("d3e1", "t2p2"), (jsonize(d3e1), jsonize(t2p2))) +// +| D3Enone0() => + jsonify("D3Enone0") +| D3Enone1(d2esrc) => + jsonify("D3Enone1", "d2esrc", jsonize(d2esrc)) +| D3Enone2(d3esrc) => + jsonify("D3Enone2", "d3esrc", jsonize(d3esrc)) +// +) +end + +implement +jsonize_d3gua + (x0) = +node("d3gua", res) where +val res = +( +case+ +x0.node() of +| D3GUAexp(d3e) => + jsonify("D3GUAexp", "d3e", jsonize(d3e)) +| D3GUAmat(d3e, d3p) => + jsonify("D3GUAmat", ("d3e", "d3p"), (jsonize(d3e), jsonize(d3p))) +) (* end of [jsonize_d3gua] *) +end + +implement +jsonize_d3clau + (x0) = +node("d3clau", res) where +val res = +( +case+ +x0.node() of +// +| D3CLAUpat(d3gp) => + jsonify("D3CLAUpat", "d3gp", jsonize(d3gp)) +// +| D3CLAUexp(d3gp, d0e0) => + jsonify("D3CLAUexp", ("d3gp", "d0e0"), (jsonize(d3gp), jsonize(d0e0))) +// +) (* end of [jsonize_d3clau] *) +end + +implement +jsonize_d3gpat + (x0) = +node("d3gpat", res) where +val res = +( +case+ +x0.node() of +// +| D3GPATpat(d3p) => + jsonify("D3GPATpat", "d3p", jsonize(d3p)) +// +| D3GPATgua(d3p, d3gs) => + jsonify("D3GPATgua", ("d3p", "d3gs"), + ( + jsonize(d3p), + jsonize_list(d3gs) + ) + ) +// +) (* end of [jsonize_d3gpat] *) +end + +local + +implement jsonize_val = jsonize_t2ype + +in + +implement +jsonize_ti3arg + (x0) = +node("ti3arg", res) where +val res = +( +case+ x0 of +| TI3ARGnone() => + jsonify("TI3ARGnone") +| TI3ARGsome(t2ps) => + jsonify("TI3ARGnone", "t2ps", jsonize_list(t2ps)) +) +end + +end + + +local + +implement +jsonize_val = jsonize_d3ecl +implement +jsonize_val = jsonize_v3aldecl +implement +jsonize_val = jsonize_v3ardecl +implement +jsonize_val = jsonize_f3undecl + +in(*in-of-local*) + +implement +jsonize_d3ecl + (x0) = +node("d3ecl", res) where +val res = +( +// +case+ +x0.node() of +// +| D3Cd2ecl(d2c) => + jsonify("D3Cd2ecl", "d2c", jsonize(d2c)) +// +| D3Cstatic + (tok, d3c) => + jsonify("D3Cstatic", "d3c", jsonize(d3c)) +| D3Cextern + (tok, d3c) => + jsonify("D3Cextern", "d3c", jsonize(d3c)) +// +| D3Cinclude + (tok, src, knd, fopt, body) => + ( + jsonify("D3Cinclude", ("tok", "src", "knd", "fopt", "body"), + ( + jsonize(tok), + jsonize(src), + jsonize(knd), + jsonize_option(fopt), + jsonize(body) + ) + ) + ) where + { + val body = + ( + case+ body of + | None _ => "None()" + | Some _ => "Some()"): string + } +// +| D3Clocal(head, body) => + jsonify("D3Clocal", ("head", "body"), + ( + jsonize_list(head), + jsonize_list(body) + ) + ) +// +| D3Cvaldecl + (knd, mopt, v3ds) => + jsonify("D3Cvaldecl", ("knd", "mopt", "v3ds"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(v3ds) + ) + ) +| D3Cvardecl + (knd, mopt, v3ds) => + jsonify("D3Cvardecl", ("knd", "mopt", "v3ds"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(v3ds) + ) + ) +// +| D3Cfundecl + (knd, mopt, tqas, f3ds) => + jsonify("D3Cfundecl", ("knd", "mopt", "tqas", "f3ds"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(tqas), + jsonize_list(f3ds) + ) + ) +// +| D3Cimpdecl1 + ( knd, mopt, sqas, tqas, id2c, ti3a, ti2s, f3as, res0, d3e0) => + jsonify("D3Cimpdecl1", + ("knd", "mopt", "sqas", "tqas", "id2c", "ti3a", "ti2s", "f3as", "res0", "d3e0"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(id2c), + jsonize(ti3a), + jsonize_list(ti2s), + jsonize_list(f3as), + jsonize(res0), + jsonize(d3e0) + ) + ) +| D3Cimpdecl2 + ( knd, mopt, sqas, tqas, id2c, ti3a, ti2s, f3as, res0, d3e0) => + jsonify("D3Cimpdecl2", + ("knd", "mopt", "sqas", "tqas", "id2c", "ti3a", "ti2s", "f3as", "res0", "d3e0"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(id2c), + jsonize(ti3a), + jsonize_list(ti2s), + jsonize_list(f3as), + jsonize(res0), + jsonize(d3e0) + ) + ) +| D3Cimpdecl3 + ( knd, mopt, sqas, tqas, id2c, ti3a, ti2s, f3as, res0, d3e0) => + jsonify("D3Cimpdecl3", + ("knd", "mopt", "sqas", "tqas", "id2c", "ti3a", "ti2s", "f3as", "res0", "d3e0"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(id2c), + jsonize(ti3a), + jsonize_list(ti2s), + jsonize_list(f3as), + jsonize(res0), + jsonize(d3e0) + ) + ) +// +| D3Cnone0() => + jsonify("D3Cnone0") +| D3Cnone1(d3csrc) => + jsonify("D3Cnone1", "d3csrc", jsonize(d3csrc)) +) +end +// +end // end of [local] + + +implement +jsonize_t2pcast + (x0) = +node("t2pcats", res) where +val res = +( +case+ x0 of +| T2PCASTnone() => + jsonify("T2PCASTnone") +| T2PCASTsome(t2p1, t2p2) => + jsonify("T2PCASTsome", ("t2p1", "t2p2"), (jsonize(t2p1), jsonize(t2p2))) +) (* end of [jsonize_t2pcast] *) +end + +implement +jsonize_v3aldecl + (x0) = let +// +val+V3ALDECL(rcd) = x0 +// +in +node("v3aldecl", res) where +val res = + jsonify("V3ALDECL", ("pat", "def", "wtp"), + ( + jsonize(rcd.pat), + jsonize_option(rcd.def), + jsonize_option(rcd.wtp) + ) + ) +end +end // end of [jsonize_v3aldecl] + + +implement +jsonize_v3ardecl + (x0) = let +// +val+V3ARDECL(rcd) = x0 +// +in +node("v3ardecl", res) where +val res = + jsonify("V3ARDECL", ("d2v", "wth", "res", "ini"), + ( + jsonize(rcd.d2v), + jsonize_option(rcd.wth), + jsonize_option(rcd.res), + jsonize_option(rcd.ini) + ) + ) +end +end // end of [jsonize_v3ardecl] + + +implement +jsonize_f3undecl + (x0) = let +// +val+F3UNDECL(rcd) = x0 +// +in +node("f3undecl", res) where +val res = + jsonify("F3UNDECL", ("nam", "d2c", "arg", "res", "def", "ctp", "wtp"), + ( + jsonize(rcd.nam), + jsonize(rcd.d2c), + jsonize_list(rcd.a2g), + jsonize(rcd.res), + jsonize_option(rcd.def), + jsonize(rcd.ctp), + jsonize_option(rcd.wtp) + ) + ) +end +end // end of [jsonize_f3undecl] diff --git a/contrib/sparverius/xjsonize/DATS/filpath.dats b/contrib/sparverius/xjsonize/DATS/filpath.dats new file mode 100644 index 000000000..772194d45 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/filpath.dats @@ -0,0 +1,22 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/filpath.sats" + + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + + +#staload "./../SATS/filpath.sats" + + +implement jsonize_filpath + (x) = + node("filpath", jsonize(full1)) +where + val full1 = filpath_get_full1(x) +end diff --git a/contrib/sparverius/xjsonize/DATS/intrep0.dats b/contrib/sparverius/xjsonize/DATS/intrep0.dats new file mode 100644 index 000000000..f2a3aa8e9 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/intrep0.dats @@ -0,0 +1,483 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/dynexp1.sats" +#staload "{$XATS}/SATS/dynexp2.sats" +#staload "{$XATS}/SATS/dynexp3.sats" + + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + + +#staload "./../SATS/lexing.sats" +#staload "./../SATS/label0.sats" +#staload "./../SATS/filpath.sats" + +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/dynexp0.sats" + +#staload "./../SATS/staexp1.sats" +#staload "./../SATS/dynexp1.sats" + +#staload "./../SATS/statyp2.sats" + +#staload "./../SATS/staexp2.sats" +#staload "./../SATS/dynexp2.sats" +#staload "./../SATS/dynexp3.sats" + +#staload "./../SATS/intrep0.sats" + + +implement +jsonize_val = jsonize_filpath + + +implement +jsonize_val = jsonize_ir0pat + +implement +jsonize_ir0pat + (x0) = +node("ir0pat", res) where +val res = +( +case+ x0.node() of +// +| IR0Pnil() => + jsonify("IR0Pnil") +| IR0Pint(tok) => + jsonify("IR0Pint", "tok", jsonize(tok)) +| IR0Pbtf(tok) => + jsonify("IR0Pbtf", "tok", jsonize(tok)) +// +| IR0Pany() => + jsonify("IR0Pany") +| IR0Pvar(d2v) => + jsonify("IR0Pvar", "d2v", jsonize(d2v)) +// +| IR0Pcapp(d2c0, irps) => + jsonify("IR0Pcapp", ("d2c0", "irps"), (jsonize(d2c0), jsonize_list(irps))) +// +| IR0Ptuple(knd, irps) => + jsonify("IR0Ptuple", ("knd", "irps"), + (jsonize(knd), jsonize_list(irps)) + ) +// +| IR0Pnone0() => + jsonify("IR0Pnone0") +| IR0Pnone1(d3p) => + jsonify("IR0Pnone1", "d3p", jsonize("...")) +// +) // end of [jsonize_ir0pat] +end + +implement jsonize_val(x) = jsonize_ir0pat(x) + +implement +jsonize_ir0arg + (x0) = +let + val+IR0ARGsome(npf, irps) = x0 +in +node("ir0arg", res) where +val res = + jsonify("IR0ARGsome", ("npf", "irps"), (jsonize(npf), jsonize_list(irps))) +end +end // end of [jsonize_ir0arg] + + +local + +implement jsonize_val = jsonize_ir0exp +implement jsonize_val = jsonize_ir0clau +implement jsonize_val = jsonize_ir0dcl +implement jsonize_val = jsonize_t2ype +implement jsonize_val = jsonize_ir0arg + +implement jsonize_val = jsonize_ti2arg + +in +// +implement +jsonize_ir0exp(x0) = +(* jsonval_labval1("ir0exp", res) where *) +(* res where val res = *) +node("ir0exp", res) where +val res = +( +case+ +x0.node() of +// +| IR0Eint(tok) => + jsonify("IR0Eint", "tok", jsonize(tok)) +| IR0Ebtf(tok) => + jsonify("IR0Ebtf", "tok", jsonize(tok)) +(* +| IR0Eflt(tok) => + jsonize("IR0Eflt") //, tok, ")") +*) +| IR0Estr(tok) => + jsonify("IR0Estr", "tok", jsonize(tok)) +// +| IR0Evar(d2v) => + jsonify("IR0Evar", "d2v", jsonize(d2v)) +// +| IR0Econ1(d2c) => + jsonify("IR0Econ1", "d2c", jsonize(d2c)) + +| IR0Ecst1(d2c) => + jsonify("IR0Ecst1", "d2c", jsonize(d2c)) +// +| IR0Efcst(d2c) => + jsonify("IR0Efst1", "d2c", jsonize(d2c)) +// +| IR0Etcst + (d2c1, ti3a, ti2s) => + jsonify("IR0Etcst", ("d2c1", "ti3a", "ti2s"), + (jsonize(d2c1), jsonize(ti3a), jsonize_list(ti2s)) + ) +| IR0Etimp + (ire1, targ, irc2, tsub) => + jsonify( + "IR0Etimp", ("ire1", "targ", "irc2", "tsub"), + ( + jsonize(ire1), + jsonize_list(targ), + jsonize(irc2), + jsonize_list(tsub) + ) + ) +// +| IR0Edapp + (irf0, npf1, ires) => + jsonify( + "IR0Edapp", ("irf0", "npf1", "ires"), + (jsonize(irf0), jsonize(npf1), jsonize_list(ires)) + ) +// +| IR0Eproj + (ire1, lab2, idx2) => + jsonify( + "IR0Eproj", ("ire1", "lab2", "idx2"), + (jsonize(ire1), jsonize(lab2), jsonize(idx2)) + ) +// +| IR0Elet(irds, ire1) => + jsonify( + "IR0Elet", ("irds", "ire1"), + (jsonize_list(irds), jsonize(ire1)) + ) +| IR0Ewhere(ire1, irds) => + jsonify("IR0Ewhere", ("ire1", "irds"), + (jsonize(ire1), jsonize_list(irds)) + ) +// +| IR0Eseqn + (ires, ire1) => + jsonify("IR0Eseqn", ("ires", "ire1"), (jsonize_list(ires), jsonize(ire1))) +| IR0Etuple + (knd0, npf1, ires) => + jsonify( + "IR0Etuple", ("knd0", "npf1", "ires"), + (jsonize(knd0), jsonize(npf1), jsonize_list(ires)) + ) +| IR0Eassgn(irel, irer) => + jsonify("IR0Eassgn", ("irel", "irer"), (jsonize(irel), jsonize(irer))) +// +| IR0Eif0 + (ire1, ire2, opt3) => + jsonify("IR0Eif0", + ("ire1", "ire2", "opt3"), + (jsonize(ire1), jsonize(ire2), jsonize_option(opt3)) + ) +// +| IR0Ecase + (knd0, ire1, ircls) => + jsonify("IR0Ecase", ("knd0", "ire1", "ircls"), + (jsonize(knd0), jsonize(ire1), jsonize_list(ircls)) + ) +// +| IR0Elam + (knd0, farg, body) => + jsonify( + "IR0Elam", ("knd0", "farg", "body"), + (jsonize(knd0), jsonize_list(farg), jsonize(body)) + ) +| IR0Efix + (knd0, d2v0, farg, body) => + jsonify("IR0Efix", ("knd0", "d2v0", "farg", "body"), + ( + jsonize(knd0), + jsonize(d2v0), + jsonize_list(farg), + jsonize(body) + ) + ) +// +| IR0Eaddr(ire1) => + jsonify("IR0Eaddr", "ire1", jsonize(ire1)) +| IR0Efold(ire1) => + jsonify("IR0Efold", "ire1", jsonize(ire1)) +// +| IR0Eeval + (knd0, ire1) => + jsonify("IR0Eeval", ("knd0", "ire1"), (jsonize(knd0), jsonize(ire1))) +// +| IR0Elazy(ire1) => + jsonify("IR0Elazy", "ire1", jsonize(ire1)) +| IR0Eflat(ire1) => + jsonify("IR0Eflat", "ire1", jsonize(ire1)) +| IR0Etalf(ire1) => + jsonify("IR0Etalf", "ire1", jsonize(ire1)) +// +| IR0Enone0() => + ( + jsonize("IR0Enone0") //, ")") + ) +| IR0Enone1(d3e1) => + ( + jsonize("IR0Enone1") //, d3e1, ")") + ) +// +) +end // end of [jsonize_ir0exp] + +end // end of local + + +implement +jsonize_ir0gua + (x0) = +node("ir0gua", res) where +val res = +( +case+ +x0.node() of +| IR0GUAexp(ir0e) => + jsonify("IR0GUAexp", "ir0e", jsonize(ir0e)) +| IR0GUAmat(ir0e, ir0p) => + jsonify("IR0GUAmat", ("ir0e", "ir0p"), + ( + jsonize(ir0e), + jsonize(ir0p) + ) + ) +) (* end of [jsonize_ir0gua] *) +end + +implement +jsonize_ir0clau + (x0) = +node("ir0clau", res) where +val res = +( +case+ +x0.node() of +// +| IR0CLAUpat(ir0gp) => + jsonify("IR0CLAUpat", "ir0gp", jsonize(ir0gp)) +// +| IR0CLAUexp(ir0gp, d0e0) => + jsonify("IR0CLAUpat", ("ir0gp", "d0e0"), + (jsonize(ir0gp), jsonize(d0e0)) + ) +// +) (* end of [jsonize_ir0clau] *) +end + +implement jsonize_val = jsonize_ir0gua + +implement +jsonize_ir0gpat + (x0) = +node("ir0gpat", res) where +val res = +( +case+ +x0.node() of +// +| IR0GPATpat(ir0p) => + jsonify("IR0GPATpat", "ir0p", jsonize(ir0p)) +| IR0GPATgua(ir0p, ir0gs) => + jsonify("IR0CLAUpat", ("ir0p", "ir0gs"), + ( + jsonize(ir0p), + jsonize_list(ir0gs) + ) + ) +// +) (* end of [jsonize_ir0gpat] *) +end + +implement jsonize_val = jsonize_ir0dcl +implement jsonize_val = jsonize_ir0fundecl +implement jsonize_val = jsonize_tq2arg +implement jsonize_val = jsonize_sq2arg +implement jsonize_val = jsonize_ti2arg +implement jsonize_val = jsonize_ir0arg +implement jsonize_val = jsonize_ir0valdecl +implement jsonize_val = jsonize_ir0vardecl + +implement +jsonize_ir0dcl(x0) = +node("ir0dcl", res) where +val res = +( +case+ x0.node() of +// +| IR0Cstatic + (tok, irc1) => + jsonify("IR0Cstatic", ("tok", "irc1"), (jsonize(tok), jsonize(irc1))) +| IR0Cextern + (tok, irc1) => + jsonify("IR0Cextern", ("tok", "irc1"), (jsonize(tok), jsonize(irc1))) +// +| IR0Cinclude + (tok, src, knd, fopt, body) => + jsonify("IR0Cinclude", ("tok", "src", "knd", "fopt", "body"), + ( + jsonize(tok), + jsonize(src), + jsonize(knd), + jsonize_option(fopt), + jbody + ) + ) where + val jbody = ( + case+ body of + | Some(x) => jsonize_list(x) + | None() => JSONlist(list_nil()) + ) + end +// +| IR0Clocal + (head, body) => + jsonify("IR0Clocal", ("head", "body"), + (jsonize_list(head), jsonize_list(body)) + ) +// +| IR0Cvardecl + (knd, mopt, irds) => + jsonify("IR0Cvardecl", ("knd", "mopt", "irds"), + (jsonize(knd), jsonize(mopt), jsonize_list(irds)) + ) +| IR0Cvaldecl + (knd, mopt, irds) => + jsonify("IR0Cvaldecl", ("knd", "mopt", "irds"), + (jsonize(knd), jsonize(mopt), jsonize_list(irds)) + ) +// +| IR0Cfundecl + (knd, mopt, tqas, irds) => + jsonify("IR0Cfundecl", ("knd", "mopt", "tqas", "irds"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(tqas), + jsonize_list(irds) + ) + ) +// +| IR0Cimpdecl3 + (knd, mopt, sqas, tqas, id2c, ti3a, ti2s, iras, body) => + jsonify( + "IR0Cimpdecl3", + ("knd", "mopt", "sqas", "tqas", "id2c", "ti3a", "ti2s", "iras", "body"), + ( + jsonize(knd), + jsonize(mopt), + jsonize_list(sqas), + jsonize_list(tqas), + jsonize(id2c), + jsonize(ti3a), + jsonize_list(ti2s), + jsonize_list(iras), + jsonize(body) + ) + ) + (* where val _ = $showtype(iras) end *) +// +| IR0Cnone0() => + jsonify("IR0Cnone0") +| IR0Cnone1(d3cl) => + jsonify("IR0Cnone1", "d3cl", jsonize("...")) +// +) // end of [jsonize_ir0dcl] +end + +implement jsonize_val = jsonize_ir0exp + +implement +jsonize_ir0vardecl + (x0) = let +// +val+IR0VARDECL(rcd) = x0 +// +in +node("ir0vardecl", res) where +val res = + jsonify ( + "IR0VARDECL", ("d2v", "ini"), + (jsonize(rcd.d2v), jsonize_option(rcd.ini)) + ) +end +end // end of [jsonize_ir0vardecl] + + +implement +jsonize_ir0valdecl + (x0) = let +// +val+IR0VALDECL(rcd) = x0 +// +in +node("ir0valdecl", res) where +val res = + jsonify("IR0VALDECL", ("pat", "def"), ( + jsonize(rcd.pat), + defopt + ) + ) where + val defopt = ( + case+ rcd.def of + | None() => jsonize("None") + | Some(x) => jsonize(x) + ) + end +end +end // end of [jsonize_ir0valdecl] + + +implement jsonize_val = jsonize_f2arg + +implement +jsonize_ir0fundecl + (x0) = let +// +val+IR0FUNDECL(rcd) = x0 +// +in +node("ir0fundecl", res) where +val res = + jsonify( + "IR0FUNDECL", ("nam", "d2c", "a2g", "a3g", "def"), + (jsonize(rcd.nam), jsonize(rcd.d2c), jsonize_list(rcd.a2g), ja3g, jdef) + ) + where + val ja3g = ( + case+ rcd.a3g of + | None() => JSONlist(list_nil()) + | Some(x) => jsonize_list(rcd.a2g) + ) + val jdef = ( + case+ rcd.def of + | None() => JSONlist(list_nil()) + | Some(x) => jsonize_list(rcd.a2g) + ) + end +end +end // end of [jsonize_ir0fundecl] diff --git a/contrib/sparverius/xjsonize/DATS/json.dats b/contrib/sparverius/xjsonize/DATS/json.dats new file mode 100644 index 000000000..e00f256a4 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/json.dats @@ -0,0 +1,826 @@ +#staload "./../SATS/json.sats" + +#include +"share/atspre_staload.hats" +#staload +UN = "prelude/SATS/unsafe.sats" + +implement +jsonval_int (i) = JSONint (i) + +(* +implement +jsonval_intinf (i) = JSONintinf (i) +*) + +implement +jsonval_bool (b) = JSONbool (b) + +implement +jsonval_double (d) = JSONfloat (d) + +implement +jsonval_string (str) = JSONstring (str) + +(* ****** ****** *) +// +#define nil list_nil +// +#define :: list_cons +#define cons list_cons +// +(* ****** ****** *) + +implement +jsonval_nil() = JSONlist (list_nil()) + +implement +jsonval_sing (x) = JSONlist (list_sing(x)) +implement +jsonval_pair (x1, x2) = JSONlist (list_pair(x1, x2)) + +(* ****** ****** *) +// +implement +jsonval_labval1 (l, x) = + JSONlablist (list_cons((l, x), list_nil)) +implement +jsonval_labval2 (l1, x1, l2, x2) = + JSONlablist (list_cons((l1, x1), list_cons((l2, x2), list_nil))) +implement +jsonval_labval3 +( + l1, x1, l2, x2, l3, x3 +) = JSONlablist ((l1, x1) :: (l2, x2) :: (l3, x3) :: list_nil(*void*)) +implement +jsonval_labval4 +( + l1, x1, l2, x2, l3, x3, l4, x4 +) = JSONlablist ((l1, x1) :: (l2, x2) :: (l3, x3) :: (l4, x4) :: list_nil) +// +implement +jsonval_labval5 +( + l1, x1, l2, x2, l3, x3, l4, x4, l5, x5 +) = JSONlablist +( + (l1, x1) :: (l2, x2) :: (l3, x3) :: (l4, x4) :: (l5, x5) :: list_nil +) +implement +jsonval_labval6 +( + l1, x1, l2, x2, l3, x3, l4, x4, l5, x5, l6, x6 +) = JSONlablist +( + (l1, x1) :: (l2, x2) :: (l3, x3) :: (l4, x4) :: (l5, x5) :: (l6, x6) :: list_nil +) +implement +jsonval_labval7 +( + l1, x1, l2, x2, l3, x3, l4, x4, l5, x5, l6, x6, l7, x7 +) = JSONlablist +( + (l1, x1) :: (l2, x2) :: (l3, x3) :: (l4, x4) :: (l5, x5) :: (l6, x6) :: (l7, x7) :: list_nil +) +implement +jsonval_labval8 +( + l1, x1, l2, x2, l3, x3, l4, x4, l5, x5, l6, x6, l7, x7, l8, x8 +) = JSONlablist +( + (l1, x1) :: (l2, x2) :: (l3, x3) :: (l4, x4) :: (l5, x5) :: (l6, x6) :: (l7, x7) :: (l8, x8) :: list_nil +) +implement +jsonval_labval9 +( + l1, x1, l2, x2, l3, x3, l4, x4, l5, x5, l6, x6, l7, x7, l8, x8, l9, x9 +) = JSONlablist +( + (l1, x1) :: (l2, x2) :: (l3, x3) :: (l4, x4) :: (l5, x5) :: (l6, x6) :: (l7, x7) :: (l8, x8) + :: (l9, x9) :: list_nil +) +implement +jsonval_labval10 +( + l1, x1, l2, x2, l3, x3, l4, x4, l5, x5, l6, x6, l7, x7, l8, x8, l9, x9, l10, x10 +) = JSONlablist +( + (l1, x1) :: (l2, x2) :: (l3, x3) :: (l4, x4) :: (l5, x5) :: (l6, x6) :: (l7, x7) :: (l8, x8) + :: (l9, x9) :: (l10, x10) :: list_nil +) +// +(* ****** ****** *) +// +implement +jsonval_conarg0 + (con) = jsonval_conarglst (con, list_nil) +implement +jsonval_conarg1 + (con, arg1) = + jsonval_conarglst (con, list_sing (arg1)) +implement +jsonval_conarg2 + (con, arg1, arg2) = + jsonval_conarglst (con, list_pair (arg1, arg2)) +implement +jsonval_conarg3 + (con, arg1, arg2, arg3) = + jsonval_conarglst (con, arg1 :: arg2 :: arg3 :: list_nil) +implement +jsonval_conarg4 + (con, arg1, arg2, arg3, arg4) = + jsonval_conarglst (con, arg1 :: arg2 :: arg3 :: arg4 :: list_nil()) +// +implement +jsonval_conarglst + (con, arglst) = jsonval_labval1 (con, JSONlist (arglst)) +// end of [jsonval_conarglst] + +(* ****** ****** *) +// +implement +jsonval_none () = JSONoption (None()) +implement +jsonval_some (x) = JSONoption (Some(x)) + +local + +fun +fprint_jsonval_string +( + out: FILEref, str: string +) : void = let +// +fun +auxch +( + out: FILEref, c: char +) : void = let +in +// +case+ c of +| '"' => fprint_string (out, "\\\"") +| '\\' => fprint_string (out, "\\\\") +| '\n' => fprint_string (out, "\\n") +| '\r' => fprint_string (out, "\\r") +| '\t' => fprint_string (out, "\\t") +| '\b' => fprint_string (out, "\\b") +| '\f' => fprint_string (out, "\\f") +| _ (*rest-of-char*) => + ( + if isprint_char(c) + then fprint_char(out, c) + else let + (* val uc = uchar_of_char(c) *) + in + (* fprintf (out, "\\u00%.2X", @($UN.cast2uint(uc))) *) + exit(1); + end // end of [else] + // end of [if] + ) (* end of [_] *) +// +end // end of [auxch] +// +fun +loop +( + out: FILEref, p: ptr +) : void = let +// +val c = $UN.ptr0_get (p) +// +in +// +if c != '\000' +(* +then (auxch(out, c); loop (out, p+sizeof)) else () +*) + then (auxch(out, c); loop (out, nxtptr)) where + val nxtptr = ptr0_add_guint(p, sizeof) + end + else () +// +end // end of [loop] +// +in +// +fprint_char (out, '"'); +loop (out, $UN.cast{ptr}(str)); +fprint_char (out, '"'); +// +end // end of [fprint_jsonval_string] + +in (* in-of-local *) + +implement +fprint_jsonval + (out, x0) = let +// +macdef +prstr (str) = fprint_string (out, ,(str)) +// +in +// +case+ x0 of +// +| JSONnul () => prstr "{}" +// +| JSONint (i) => fprint_int (out, i) +(* +| JSONintinf (i) => + { + val () = fprint_char (out, '"') + val () = $INTINF.fprint_intinf (out, i) + val () = fprint_char (out, '"') + } +*) +// +| JSONbool (b) => fprint_bool (out, b) +| JSONfloat (d) => fprint_double (out, d) +// +| JSONstring (str) => fprint_jsonval_string (out, str) +| JSONlist (xs) => + { + val () = prstr "[" + val () = fprint_jsonvalist (out, xs) + val () = prstr "]" + } +| JSONlablist (lxs) => + { + val () = prstr "{" + val () = fprint_labjsonvalist (out, lxs) + val () = prstr "}" + } +// +| JSONoption (opt) => + { + val () = prstr "[" + val () = + ( + case+ opt of + | Some x => fprint_jsonval (out, x) | None () => () + ) : void // end of [val] + val () = prstr "]" + } +(* +| JSONobject (lst) => + { + val () = prstr "{" +(* + val () = + ( + case+ opt of + | Some x => fprint_jsonval (out, x) | None () => () + ) : void // end of [val] +*) + val () = prstr "}" + } +*) + +// +end // end of [fprint_jsonval] + +end // end of [local] + +(* ****** ****** *) + +implement +fprint_jsonvalist + (out, xs0) = let +// +fun aux +( + out: FILEref +, xs0: jsonvalist, i: int +) : void = let +in +// +case+ xs0 of +| list_nil () => () +| list_cons (x, xs) => let + val () = + if i > 0 + then fprint (out, ", ") + // end of [if] + val () = fprint_jsonval (out, x) + in + aux (out, xs, i+1) + end // end of [list_cons] +// +end // end of [aux] +// +in + aux (out, xs0, 0) +end // end of [fprint_jsonvalist] + +(* ****** ****** *) + +implement +fprint_labjsonvalist + (out, lxs0) = let +// +fun aux +( + out: FILEref +, lxs0: labjsonvalist, i: int +) : void = let +in +// +case+ lxs0 of +| list_nil () => () +| list_cons + (lx, lxs) => let + val () = + if i > 0 + then fprint (out, ", ") + // end of [if] + (* + val () = + fprintf (out, "\"%s\"", @(lx.0)) + *) + val () = + fprintf (out, "\"%s\"", $vararg(lx.0)) + + val () = fprint_string (out, ": ") + val () = fprint_jsonval (out, lx.1) + in + aux (out, lxs, i+1) + end // end of [list_cons] +// +end // end of [aux] +// +in + aux (out, lxs0, 0) +end // end of [fprint_labjsonvalist] + +(* ****** ****** *) + +implement +print_jsonval(x) = fprint_jsonval(stdout_ref, x) +implement +prerr_jsonval(x) = fprint_jsonval(stderr_ref, x) + +implement fprint_val = fprint_jsonval + + +(* ****** ****** *) +// +implement +jsonize_ignored(x0) = JSONnul((*void*)) +// +(* ****** ****** *) + +implement +{a}(*tmp*) +jsonize_list_fun(xs, f) = let +// +(* +val () = + println! ("jsonize_list_fun") +*) +// +(* +val +jsvs = list_map_fun (xs, f) +*) +val +jsvs = list_map(xs) where + implement list_map$fopr(a) = f(a) end +val +jsvs = list_of_list_vt(jsvs) + +in + JSONlist (jsvs) +end // end of [jsonize_list_fun] + +(* ****** ****** *) + +implement +{a}(*tmp*) +jsonize_option_fun(opt, f) = let +// +(* +val () = + println! ("jsonize_option_fun") +*) +// +in +// +case+ opt of +| None() => jsonval_none() | Some(x) => jsonval_some(f(x)) +// +end // end of [jsonize_option_fun] + + +implement lab(x:string, rst:jsonval): jsonval = jsonval_labval1(x, rst) + +implement jnul() = JSONnul() + +implement jint(x:int) = JSONint(x) + +implement jbool(x:bool) = JSONbool(x) + +implement jfloat(x:double) = JSONfloat(x) + +implement jstr(x:string) = JSONstring(x) + +implement jsonize_int(x) = JSONint(x) + +implement jsonize_char(x) = JSONstring(tostring_char(x)) + +implement jsonize_string(x) = JSONstring(x) + +implement jsonize_bool(x) = JSONbool(x) + +implement jsonize_double(x) = JSONstring(tostring_val(x)) + +implement jsonize_val(x) = jsonize_int(x) + +implement jsonize_val(x) = jsonize_string(x) + +implement jsonize_val(x) = jsonize_bool(x) + +implement jsonize_val(x) = jsonize_double(x) + +(* implement jsonize_val(x) = jsonize_float(x) *) + + +implement{a} jsonize_list(xs) = JSONlist(res) where +{ + val xys = list_map(xs) where + { + implement list_map$fopr(x) = jsonize_val(x) + } + val res = list_of_list_vt{jsonval}(xys) +} + + +implement{a} jsonize_option(xs) = +( + case+ xs of + | None() => jsonize("None") + | Some(x) => jsonval_labval1("Some", jsonize_val(x)) +) + +implement{a} jsonize_option_vt(xs) = +( + case+ xs of + | ~None_vt() => jsonize("None") + | ~Some_vt(x) => jsonval_labval1("Some_vt", jsonize_val(x)) +) + + +(* +implement(a:t@ype) jsonize_list(xs) = JSONlist(res) where +{ + (* val _ = $showtype(xs) *) + val xys = list_map(xs) where + { + implement list_map$fopr(x) = jsonize_val(x) + } + val res = list_of_list_vt{jsonval}(xys) +} +*) + +(* +implement(a:t@ype) jsonize_val(xs) = jsonize_list(xs) +*) + +implement listj(x) = JSONlist(list_sing(x)) + +implement listj2(x, y) = JSONlist(cons(x, cons(y, nil()))) + + +implement node(x, y) = + jsonval_labval1(x, y) + (* jsonval_labval2("node", jsonize(x), "json", y) *) + (* jsonval_labval2("node", jsonize(x), "val", y) *) + + +implement node2(x, y, z) = + jsonval_labval1(x, z) + (* jsonval_labval3("name", jsonize(x), "loc", y, "node", z) *) + (* jsonval_labval2("node", jsonize(x), "json", z) *) + +implement jsonify0(guard_name) = JSONstring(guard_name) + +implement jsonify1(guard_name, name, json) = + jsonval_labval1(guard_name, json) +(* +jsonval_labval1(guard_name, jsonval_labval1(name, json)) +*) + + +fun jsontyp(xs: jsonval): string = +( + case+ xs of + | JSONnul() => "JSONnul" + | JSONint(int) => "JSONint" + | JSONbool(bool) => "JSONbool" + | JSONfloat(double) => "JSONfloat" + | JSONstring(string) => "JSONstring" + | JSONlist(jsonvalist) => "JSONlist" + | JSONlablist(labjsonvalist) => "JSONlablist" + | JSONoption(jsonvalopt) => "JSONoption" +) + +#define JSON_OUTPUT 0 + +implement jsonify2(guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => JSONlist($list{jsonval}(json.0, json.1)) + | 1 => + ( + jsonval_labval2 ( + names.0, json.0, + names.1, json.1 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1) + )) + ) + ) +end + +implement jsonify3(guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | + 0 => ( + JSONlist($list{jsonval}(json.0, json.1, json.2)) + ) + | 1 => ( + jsonval_labval3 ( + names.0, json.0, + names.1, json.1, + names.2, json.2 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2) + )) + ) + )end + +implement jsonify4(guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => ( + JSONlist($list{jsonval}(json.0, json.1, json.2, json.3)) + ) + | 1 => ( + jsonval_labval4 ( + names.0, json.0, + names.1, json.1, + names.2, json.2, + names.3, json.3 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2), + (names.3, json.3) + )) + ) + ) +end + +implement jsonify5 (guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => ( + JSONlist($list{jsonval}(json.0, json.1, json.2, json.3, json.4)) + ) + | 1 => ( + jsonval_labval5 ( + names.0, json.0, + names.1, json.1, + names.2, json.2, + names.3, json.3, + names.4, json.4 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2), + (names.3, json.3), + (names.4, json.4) + )) + ) + ) +end + +implement jsonify6 (guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => ( + JSONlist($list{jsonval}(json.0, json.1, json.2, json.3, json.4, json.5)) + ) + | 1 => ( + jsonval_labval6 ( + names.0, json.0, + names.1, json.1, + names.2, json.2, + names.3, json.3, + names.4, json.4, + names.5, json.5 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2), + (names.3, json.3), + (names.4, json.4), + (names.5, json.5) + )) + ) + ) +end + +implement jsonify7 (guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => ( + JSONlist($list{jsonval}(json.0, json.1, json.2, json.3, json.4, json.5, json.6)) + ) + | 1 => ( + jsonval_labval7 ( + names.0, json.0, + names.1, json.1, + names.2, json.2, + names.3, json.3, + names.4, json.4, + names.5, json.5, + names.6, json.6 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2), + (names.3, json.3), + (names.4, json.4), + (names.5, json.5), + (names.6, json.6) + )) + ) + ) +end + +implement jsonify8 (guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => ( + JSONlist($list{jsonval}(json.0, json.1, json.2, json.3, json.4, json.5, json.6, json.7)) + ) + | 1 => ( + jsonval_labval8 ( + names.0, json.0, + names.1, json.1, + names.2, json.2, + names.3, json.3, + names.4, json.4, + names.5, json.5, + names.6, json.6, + names.7, json.7 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2), + (names.3, json.3), + (names.4, json.4), + (names.5, json.5), + (names.6, json.6), + (names.7, json.7) + )) + ) + ) +end + +implement jsonify9 (guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => ( + JSONlist($list{jsonval}( + json.0, + json.1, + json.2, + json.3, + json.4, + json.5, + json.6, + json.7, + json.8 + )) + ) + | 1 => ( + jsonval_labval9 ( + names.0, json.0, + names.1, json.1, + names.2, json.2, + names.3, json.3, + names.4, json.4, + names.5, json.5, + names.6, json.6, + names.7, json.7, + names.8, json.8 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2), + (names.3, json.3), + (names.4, json.4), + (names.5, json.5), + (names.6, json.6), + (names.7, json.7), + (names.8, json.8) + )) + ) + ) +end + +implement jsonify10 (guard_name, names, json) = +jsonval_labval1(guard_name, rst) where + val rst = + ( + case JSON_OUTPUT of + | 0 => ( + JSONlist($list{jsonval}( + json.0, + json.1, + json.2, + json.3, + json.4, + json.5, + json.6, + json.7, + json.8, + json.9 + )) + ) + | 1 => ( + jsonval_labval10 ( + names.0, json.0, + names.1, json.1, + names.2, json.2, + names.3, json.3, + names.4, json.4, + names.5, json.5, + names.6, json.6, + names.7, json.7, + names.8, json.8, + names.9, json.9 + ) + ) + | _ => ( + JSONlablist($list{labjsonval}( + (names.0, json.0), + (names.1, json.1), + (names.2, json.2), + (names.3, json.3), + (names.4, json.4), + (names.5, json.5), + (names.6, json.6), + (names.7, json.7), + (names.8, json.8), + (names.9, json.9) + )) + ) + ) +end diff --git a/contrib/sparverius/xjsonize/DATS/jsonize0.dats b/contrib/sparverius/xjsonize/DATS/jsonize0.dats new file mode 100644 index 000000000..73be5feef --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/jsonize0.dats @@ -0,0 +1,1332 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) +// +// Author: Hongwei Xi +// Start Time: November, 2019 +// Authoremail: gmhwxiATgmailDOTcom +// +(* ****** ****** *) +// +%{^ +// +extern +void +libxatsopt_dynloadall(); +// +%} (* %{^ *) +val () = +$extfcall +(void, "libxatsopt_dynloadall") +// +(* ****** ****** *) +// +#include +"share/atspre_staload.hats" +#staload +UN = "prelude/SATS/unsafe.sats" +// +(* ****** ****** *) +// +#include +"./../HATS/libxatsopt.hats" +// +(* ****** ****** *) +// +#staload "./../SATS/json.sats" +#staload "./../SATS/basics.sats" +#staload "./../SATS/fixity.sats" +#staload "./../SATS/label0.sats" +#staload "./../SATS/locinfo.sats" +#staload "./../SATS/lexing.sats" +#staload "./../SATS/stamp0.sats" +#staload "./../SATS/symbol.sats" +#staload "./../SATS/filpath.sats" +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/dynexp0.sats" +#staload "./../SATS/staexp1.sats" +#staload "./../SATS/dynexp1.sats" +#staload "./../SATS/statyp2.sats" +#staload "./../SATS/staexp2.sats" +#staload "./../SATS/dynexp2.sats" +#staload "./../SATS/dynexp3.sats" +(* #staload "./../SATS/trans01.sats" *) + + +#staload _ = "./json.dats" +#staload _ = "./basics.dats" +#staload _ = "./label0.dats" +#staload _ = "./locinfo.dats" +#staload _ = "./lexing_token.dats" +#staload _ = "./stamp0.dats" +#staload _ = "./symbol.dats" +#staload _ = "./filpath.dats" +#staload _ = "./staexp0.dats" +#staload _ = "./dynexp0.dats" +#staload _ = "./staexp1.dats" +#staload _ = "./dynexp1.dats" +#staload _ = "./statyp2.dats" +#staload _ = "./staexp2.dats" +#staload _ = "./dynexp2.dats" +#staload _ = "./dynexp3.dats" + +#staload _ = "./json.dats" + +#staload "./../SATS/jsonize0.sats" + + +implement jsonize_val = jsonize_d0ecl +implement jsonize_val = jsonize_d1ecl +implement jsonize_val = jsonize_d2ecl +// + +(* ****** ****** *) +// +#staload +STDIO = "libats/libc/SATS/stdio.sats" +// +(* ****** ****** *) +// +datatype +commarg = +| COMMARG of (int, string) +// +typedef +commarglst + (n:int) = list(commarg, n) +// +(* ****** ****** *) +// +extern +fun +parse_commarg +( string +) :<> commarg +and +parse_commarglst + {n:nat} +( argc: int(n) +, argv: !argv(n) +) : commarglst(n) +// +(* ****** ****** *) + +implement +parse_commarg + (inp) = let +// +fun +loop +{n,i:nat|i <= n} .. +( + inp: string n, n: int n, i: int i +) :<> commarg = +( +if +(i < n) +then ( +if (inp[i] != '-') + then COMMARG(i, inp) else loop(inp, n, i+1) +) else COMMARG(n, inp) +// end of [if] +) (* end of [if] *) +// end of [loop] +// +in +// +if +(inp = "-") +then +( +COMMARG(0, inp) +) +else +( + loop(inp, sz2i(len), 0) +) where +{ + val inp = g1ofg0(inp); val len = string_length(inp) +} +// +end // end of [parse_commarg] +// +(* ****** ****** *) + +implement +parse_commarglst + {n}(argc, argv) = let +// +vtypedef +arglst(n:int) = list_vt(commarg, n) +// +fun +loop +{i:nat | i <= n}{l:addr} .. +( pf0: arglst(0) @ l +| argv: !argv(n), i: int i, p0: ptr l +) : (arglst(n-i) @ l | void) = +( +// +if +i < argc +then let + val+~list_vt_nil() = !p0 + val x = parse_commarg(argv[i]) + val () = + ( !p0 := + list_vt_cons(x, list_vt_nil()) + ) (* end of [val] *) + val+@list_vt_cons(_, xs) = !p0 + val (pf | ()) = + loop (view@xs | argv, i+1, addr@xs) // tail-call + // end of [val] +in + fold@(!p0); (pf0 | ()) +end // end of [then] +else (pf0 | ()) // end of [else] +// +) (* end of [loop] *) +// +in +// +list_vt2t +( +res where +{ +var res: ptr? +// +val () = +res := list_vt_nil{commarg}() +val +(pf | ()) = +loop +(view@res | argv, 0, addr@res) +// end of [val] +prval ((*void*)) = view@res := pf +// +} +) (* end of [list_vt2t] *) +// +end // end of [parse_commarglst] + +(* ****** ****** *) +// +extern +fun +print_commarg(commarg): void +extern +fun +prerr_commarg(commarg): void +extern +fun +fprint_commarg +(out: FILEref, x0: commarg): void +// +(* ****** ****** *) +// +implement +print_commarg(x0) = +fprint_commarg(stdout_ref, x0) +implement +prerr_commarg(x0) = +fprint_commarg(stderr_ref, x0) +implement +fprint_commarg(out, x0) = +( +case+ x0 of +| COMMARG(i, k) => + fprint!(out, "COMMARG(", i, ", ", k, ")") +) (* end of [fprint_commarg] *) +// +(* ****** ****** *) +// +extern +fun +xatsopt_usage +( out: FILEref +, arg0: commarg): void +implement +xatsopt_usage + (out, arg0) = let +// +val+COMMARG(_, cmdname) = arg0 +// +in +// +fprintln! +(out, "Usage: ", cmdname, " ... \n"); +fprintln! +(out, "where a is of one of the following forms:\n"); +// +fprintln! (out, " -h (for printing out this help usage)"); +fprintln! (out, " --help (for printing out this help usage)"); +// +fprintln! (out, " -v (for printing out the version)"); +fprintln! (out, " --version (for printing out the version)"); +// +fprintln! (out, " -s (for compiling static filenames)"); +fprintln! (out, " --static (for compiling static filenames)"); +// +fprintln! (out, " -d (for compiling dynamic filenames)"); +fprintln! (out, " --dynamic (for compiling dynamic filenames)"); +// +fprintln! (out, " -o (output into filename)"); +fprintln! (out, " --output (output into filename)"); +fprintln! (out, " --output-w (output-write into filename)"); +fprintln! (out, " --output-a (output-append into filename)"); +// +(* +fprintln! (out, " -cc (for compiling into C)"); +fprintln! (out, " --compile (for compiling into C)"); +*) +// +(* +fprintln! (out, " -tc (for typechecking only)"); +fprintln! (out, " --tycheck (for typechecking only)"); +*) +// +fprint_newline (out); // HX: needed for flushing out the output +// +end // end of [xatsopt_usage] +// +(* ****** ****** *) +// +extern +fun +xatsopt_version + (out: FILEref): void +implement +xatsopt_version + (out) = let + val MAJOR = 0 + val MINOR = 0 + val MICRO = 0 +in + fprint!(out, "ATS/Xanadu version "); + fprint!(out, MAJOR, ".", MINOR, ".", MICRO); + fprintln!(out, " Copyright (c) 2018-20?? Hongwei Xi") +end // end of [xatsopt_version] +// +(* ****** ****** *) +// +extern +fun +the_fixity_load +( +XATSHOME: string +) : void = + "ext#libxatsopt_the_fixity_load" +extern +fun +the_basics_load +( +XATSHOME: string +, +stadyn: int, given: string +) : void = + "ext#libxatsopt_the_basics_load" +// +extern +fun +the_prelude_load +( +XATSHOME: string +, +stadyn: int, given: string +) : void = + "ext#libxatsopt_the_prelude_load" +// +extern +fun +the_preludes_load +( + XATSHOME: string +) : void = + "ext#libxatsopt_the_preludes_load" +extern +fun +the_preludes_load_if +( + XATSHOME: string, flag: &int +) : void = + "ext#libxatsopt_the_preludes_load_if" +// +(* ****** ****** *) +// +datatype +waitknd = + | WTKnone of () + | WTKoutput of () // -o ... + | WTKinpsta of () // -s ... + | WTKinpdyn of () // -d ... + | WTKdefine of () // -DATS ... + | WTKinpath of () // -IATS ... +// end of [waitkind] +// +fun +waitknd_get_stadyn +(knd: waitknd): int = +( +case+ knd of +| WTKinpsta() => 0 +| WTKinpdyn() => 1 +| _ (*rest-of-WTK*) => ~1 +) // end of [waitkind_get_stadyn] +// +(* ****** ****** *) +// +datatype +outchan = +| OUTCHANref of (FILEref) +| OUTCHANptr of (FILEref) +// end of [outchan] + +fun +outchan_get_filref + (x0: outchan): FILEref = +( +case+ x0 of +| OUTCHANref(filr) => filr +| OUTCHANptr(filr) => filr +) (* end of [outchan_get_filref] *) +// +(* ****** ****** *) +// +typedef +cmdstate = @{ +// +arg0= commarg +, +wtk0= waitknd +, +ATSHOME= string +, +prelude= int +, +inpfil0=fpath_t +, +// the number of inputs +ninpfil= int // processed +// +, outmode= fmode +, outchan= outchan +// +// the number of caught +, nxerror= int // errors +// +} (* end of [cmdstate] *) +// +(* ****** ****** *) +// +fun +isinpwait +( + st0: cmdstate +) : bool = +( +case+ +st0.wtk0 +of // case+ + | WTKinpsta() => true + | WTKinpdyn() => true +(* + | WTKinpdyns() => true +*) + | _ (*non-WTKinput*) => false +) // end of [isinpwait] + +fun +isoutwait + (st0: cmdstate): bool = +( +case+ +st0.wtk0 of +| WTKoutput() => true +| _(*non-WTKoutput*) => false +) (* end of [isoutwait] *) + +fun +isdatswait + (st0: cmdstate): bool = +( +case+ +st0.wtk0 of +| WTKdefine() => true +| _(*non-WTKdefine*) => false +) (* end of [isdatswait] *) + +fun +isiatswait + (st0: cmdstate): bool = +( +case+ +st0.wtk0 of +| WTKinpath() => true +| _(*non-WTKinpath*) => false +) (* end of [isiatswait] *) +// +(* ****** ****** *) + +local + +extern +praxi +vbox_make_view_ptr +{a:vt0ype}{l:addr} +// statically allocated reference +(a @ l | ptr(l)):<> vbox(a @ l) + +var +theOutFname: Stropt = stropt_none() +// +prval pf0 = +vbox_make_view_ptr +{Stropt}{..} +(view@theOutFname | addr@theOutFname) +// end of [val] + +in (* in-of-local *) + +fun +theOutFname_get +( +// argless +) : Stropt = out where +{ +// +prval vbox(pf) = pf0 +// + val out = theOutFname +// + val ((*void*)) = + theOutFname := stropt_none() +// +} // end of [theOutFname_get] + +fun +theOutFname_set + (fname: Stropt) = () where +{ +// +prval vbox(pf) = pf0 +// + val () = theOutFname := fname +// +} // end of [theOutFname_set] + +end // end of [local] + +(* ****** ****** *) + +fun +cmdstate_set_outchan +( +st0: &cmdstate >> _, out1: outchan +) : void = let + val out0 = st0.outchan + val ((*void*)) = st0.outchan := out1 +in +// +case+ out0 of +| OUTCHANref _ => () +| OUTCHANptr(filr) => let + val err = $STDIO.fclose0(filr) in (*nothing*) + end // end of [OUTCHANptr] +// +end // end of [cmdstate_set_outchan] + +(* ****** ****** *) +// +extern +fun +outchan_make_fname +( st0 +: &cmdstate, fname: string +) : outchan // end-of-fun +implement +outchan_make_fname + (st0, fname) = +( +case+ fname of +| "-" => OUTCHANref(stdout_ref) +// +| _(*unspecial*) => auxmain(st0, fname) +// +) where +{ +fun +auxmain +( st0 +: &cmdstate, fname: string +) : outchan = let +// +val +filp = +$STDIO.fopen(fname, st0.outmode) +// +in +// +if +$STDIO.iseqz(filp) +then +( + OUTCHANref(stderr_ref) +) where +{ +prval () = +$STDIO.FILEptr_free_null(filp) +} (* end of [then] *) +else +( + OUTCHANptr + ($UN.castvwtp0{FILEref}(filp)) +) (* end of [else] *) +// +end // end of [auxmain] +// +} (* end of [outchan_make_path] *) + +(* ****** ****** *) +// +extern +fun +xatsopt_commarg_warning + (out: FILEref, arg: string): void +implement +xatsopt_commarg_warning + (out, arg) = () where +{ +// +val () = +fprint(out, "WARNING(ATS)") +val () = +fprintln! +( out +, ": unrecognized command-line argument [", arg, "] is skipped." +) (* end of [val] *) +// +} (* end of [xatsopt_commarg_warning] *) +// +(* ****** ****** *) + +local +// +static +fun +process_stdin +(st0: &cmdstate >> _): void +static +fun +process_fpath +( st0 +: &cmdstate >> _, fp0: fpath_t): void +static +fun +process_given +( st0 +: &cmdstate >> _, given: string): void +// +static +fun +process_cmdline + {n:nat} +( st0: &cmdstate >> _ +, args: commarglst(n)): void +and +process_cmdline2 + {n:nat} +( st0: &cmdstate >> _ +, arg0: commarg, args: commarglst(n)): void +// +implement +process_stdin + (st0) = +( +process_fpath(st0, fp0) +) where +{ + val + fp0 = $FP0.the_filpath_stdin +} +implement +process_fpath + (st0, fp0) = let +// +val +wtk0 = st0.wtk0 +val +stadyn = +waitknd_get_stadyn(wtk0) +// +val +XATSHOME = st0.ATSHOME +// +val () = +ifcase +| +$FP0.filpath_is_stdin(fp0) => +$FP0.the_dirpathlst_ppush_cwd() +| _ (* regular filename *) => +let +val +dp0 = +$FP0.dirpath_make +($FP0.filpath_get_dirname(fp0)) +val () = +let +val out = stdout_ref +in +fprint(out, "dirpath = "); +$FP0.fprintln_dirpath(out, dp0) +end +in + $FP0.the_filpathlst_ppush(fp0); + $FP0.the_dirpathlst_ppush(dp0) +end (* let *) // end of [ifcase] +// +in +// +if +( +stadyn >= 0 +) +then +{ +// +val () = +the_preludes_load_if +(XATSHOME, st0.prelude) +// end of [val] +// +val () = (st0.inpfil0 := fp0) +val +(pf0 | ()) = +$FP0.the_filpathlst_push(fp0) +val +d0cs = +let +val opt = +parse_from_filpath_toplevel + (stadyn, fp0) +in +case+ opt of +| ~Some_vt(d0cs) => d0cs +| ~None_vt((*void*)) => list_nil() +end : d0eclist // end-of-val +// +prval () = $UN.castview0{void}(pf0) +(* +val +((*popped*)) = +$FP0.the_filpathlst_pout(pf0 | (*none*)) +*) +// +(* +val () = +println! +("process_fpath: d0cs = ", d0cs) +*) +// +val () = println!("\n\n", "JSONIZED", "\n\n") +val json = jsonize_list(d0cs) +val () = fprint_jsonval(stdout_ref, json) +val () = println!() + + + +val () = synread_main(d0cs) +// +val +d1cs = trans01_declist(d0cs) +(* +val () = +println! +("process_fpath: d1cs = ", d1cs) +*) +val () = println!("\n\n", "JSONIZED", "\n\n") +val json = jsonize_list(d1cs) +val () = fprint_jsonval(stdout_ref, json) +val () = println!() +// +val () = t1xread_main(d1cs) +// +val +d2cs = trans12_declist(d1cs) + +(* val _ = $showtype(d2cs) *) +val () = println!("\n\n", "JSONIZED", "\n\n") +val json = jsonize_list(d2cs) +val () = fprint_jsonval(stdout_ref, json) +val () = println!() + +(* +val () = +println! +("process_fpath: d2cs = ", d2cs) +*) +// +val () = t2xread_main(d2cs) +// +val +d3cs = trans23_declist(d2cs) + + + +val () = println!("\n\n", "JSONIZED", "\n\n") +val json = jsonize_list(d3cs) +val () = fprint_jsonval(stdout_ref, json) +val () = println!() + + +(* +val () = +println! +("process_fpath: d3cs = ", d3cs) +*) +val +d3cs = trans33_declist(d3cs) +(* +val () = +println! +("process_fpath: d3cs = ", d3cs) +*) +val () = t3xread_main(d3cs) +// +val +d3cs = trans3t_program(d3cs) + +val () = println!("\n\n", "JSONIZED", "\n\n") +val json = jsonize_list(d3cs) +val () = fprint_jsonval(stdout_ref, json) +val () = println!() + +(* +(* +val () = +println! +("process_fpath: d3cs = ", d3cs) +*) +// +val () = +println! +("process_fpath: the_sortenv:") +val () = +( + the_sortenv_println((*void*)) +) +// +val () = +println! +("process_fpath: the_sexpenv:") +val () = +( + the_sexpenv_println((*void*)) +) +// +val () = +println! +("process_fpath: the_dexpenv:") +val () = +( + the_dexpenv_println((*void*)) +) +// +(* +val +irdcls = irerase_declist(d3cs) +val () = +println! +("process_fpath: irdcls = ", irdcls) +*) +// +*) + + +val () = fprint_newline(stdout_ref) +// +} (* end of [then] *) +else +{ +// ~(stadyn >= 0) // not for loading code +} (* end of [else] *) +// +end // end of [process_fpath] +// +implement +process_given + (st0, arg0) = let +// +val fp0 = +let +val given = arg0 +val fname = arg0 +in +fpath_make(given, fname) +end +// +(* +val () = +println! +("process_given: arg0 = ", arg0) +*) +// +in + process_fpath(st0, fp0) +end // end of [process_given] +// +implement +process_cmdline + (st0, args) = let +in +// +case+ args of +// +| list_nil() => + ( + if + st0.ninpfil = 0 + then process_stdin(st0) else () + ) +// +| list_cons + (arg0, args) => + ( + process_cmdline2(st0, arg0, args) + ) +// +end // end of [process_cmdline] +// +implement +process_cmdline2 + (st0, arg0, args) = let +// +(* +val () = +println! +("process_cmdline2: arg0 = ", arg0) +*) +// +fun +auxkey1 +( st0: + &cmdstate >> _ +, key: string): void = let +// +val () = +(st0.wtk0 := WTKnone()) +// +val () = +( +case+ key of +// +| "-o" => + { + val () = + (st0.wtk0 := WTKoutput()) + } (* end of [-o] *) +| "-s" => + { + val () = + (st0.ninpfil := 0) + val () = + (st0.wtk0 := WTKinpsta()) + } (* end of [-s] *) +| "-d" => + { + val () = + (st0.ninpfil := 0) + val () = + (st0.wtk0 := WTKinpdyn()) + } (* end of [-d] *) +(* +| "-dd" => + { + val () = + (st0.ninpfil := 0) + val () = + (st0.waitknd := WTKinpdyns()) + } (* end of [-dd] *) +*) +// +(* +| "-cc" => (st0.tcflag := 0) +| "-tc" => (st0.tcflag := 1) +*) +// +(* +| "-dep" => (st0.depgen := 1) +| "-tag" => (st0.taggen := 1) +*) +// +(* +| _ when + is_DATS_flag(key) => let + val def = DATS_extract(key) + val issome = stropt_is_some(def) + in + if + issome + then + ( + process_DATS_def(def) where + { + val def = stropt_unsome(def) + } + ) + else let + val () = + (st0.wtk0 := WTKdefine(*void*)) + // end of [val] + in + // nothing + end // end of [else] // end of [if] + end // end of [is_DATS_flag] +*) +(* +| _ when + is_IATS_flag(key) => let + val path = IATS_extract(key) + val issome = stropt_is_some(path) + in + if + issome + then + ( + process_IATS_dir(path) where + { + val path = stropt_unsome(path) + } + ) + else let + val () = + (st0.wtk0 := WTKinclude(*void*)) + // end of [val] + in + // nothing + end // end of [else] // end of [if] + end // end of [is_IATS_flag] +*) +// +| "-h" => + ( + xatsopt_usage + (stdout_ref, st0.arg0) + // xatsopt_usage + ) +| "-v" => + ( + xatsopt_version(stdout_ref) + ) +// +| _ (*rest*) => + ( // + // HX: unrecognized key + // + xatsopt_commarg_warning(stderr_ref, key) + ) (* end of [rest] *) +// +) : void // end of [val] +// +in + process_cmdline(st0, args) +end // end of [auxkey1] +// +fun +auxkey2 +( st0: + &cmdstate >> _ +, key: string): void = let +// +val () = + (st0.wtk0 := WTKnone()) +// +val () = +( +case+ key of +// +| "--output" => + ( + st0.wtk0 := WTKoutput() + ) +| "--output-w" => + { + val () = st0.wtk0 := WTKoutput() + val () = st0.outmode := file_mode_w + } // end of [--output-w] +| "--output-a" => + { + val () = st0.wtk0 := WTKoutput() + val () = st0.outmode := file_mode_a + } // end of [--output-a] +// +| "--static" => + { + val () = st0.wtk0 := WTKinpsta() + } // end of [--static] +| "--dynamic" => + { + val () = st0.wtk0 := WTKinpdyn() + } // end of [--dynamic] +// +(* +| "--dynamics" => + { + val () = st0.wtk0 := WTKinpdyns() + } // end of [--dynamics] +*) +// +(* +| "--compile" => (st0.tycheckflag := 0) +| "--tycheck" => (st0.tycheckflag := 1) +*) +// +(* +| "--gline" => + { + val () = + $GLOB.the_DEBUGATS_dbgline_set(1) + } // end of [--gline] // mostly for debugging +*) +// +(* +| "--debug1" => + { + val () = debug_flag_set(1) + } // end of [--debug] // more informative errmsgs +| "--debug2" => { + val () = debug_flag_set(1) + val () = $GLOB.the_DEBUGATS_dbgflag_set(1) + } // end of [--debug2] // for generating debugging info +*) +// +(* +| "--depgen" => (st0.depgen := 1) +| "--taggen" => (st0.taggen := 1) +*) +// +(* +| "--codegen-2" => + { + val () = st0.codegen2 := 2 + } +| "--jsonize-2" => + { + val () = st0.jsonize2 := 2 + } +*) +// +(* +| "--no-tailcallopt" => + { + val () = + $GLOB.the_CCOMPATS_tailcallopt_set(0) + } +*) +// +(* +| "--constraint-export" => + { + val () = st0.constraint := 1 + } +| "--constraint-ignore" => + { + val () = st0.constraint := ~1 + } +*) +// +| "--help" => + ( + xatsopt_usage + (stdout_ref, st0.arg0) + // xatsopt_usage + ) +| "--version" => + ( + xatsopt_version(stdout_ref) + ) +// +| _ (*rest-of-key2*) => + ( // + // HX: unrecognized key + // + xatsopt_commarg_warning(stderr_ref, key) + ) (* end of [rest-of-key2] *) +// +) : void // end of [val] +// +in + process_cmdline(st0, args) +end // end of [auxkey2] +// +in +// +case+ arg0 of +| _ when + isinpwait(st0) => let + val + stadyn = + waitknd_get_stadyn(st0.wtk0) + val nif = st0.ninpfil + in + case+ arg0 of +// + | COMMARG(1, key) + when nif > 0 => + ( + auxkey1(st0, key) + ) + | COMMARG(2, key) + when nif > 0 => + ( + auxkey2(st0, key) + ) +// + | COMMARG(_, "-") => + ( + process_cmdline(st0, args) + ) where + { + val () = + (st0.ninpfil := nif+1) + val () = process_stdin(st0) + } (* end of [COMMARG(_,-)] *) +// + | COMMARG(_, given) => + ( + process_cmdline(st0, args) + ) where + { + val () = + (st0.ninpfil := nif+1) + val () = + ( + process_given(st0, given) + ) + } (* end of [COMMARG(_,_)] *) + end // end of [isinpwait] +// +| _ when + isoutwait(st0) => let + val () = + st0.wtk0 := WTKnone() +// + val+COMMARG(_, given) = arg0 +// + val ((*void*)) = + ( + theOutFname_set(opt) + ) where + { + val opt = stropt_some(given) + } +// + val _new_ = + outchan_make_fname(st0, given) + val ((*void*)) = + cmdstate_set_outchan(st0, _new_) +// + in + process_cmdline(st0, args) + end // end of [_ when isoutwait] +// +| COMMARG(1, key) => auxkey1(st0, key) +| COMMARG(2, key) => auxkey2(st0, key) +// +| COMMARG(_, key) => + ( + process_cmdline(st0, args) + ) where + { + val () = + st0.wtk0 := WTKnone() + val () = + xatsopt_commarg_warning(stderr_ref, key) + } (* end of [COMMARG] *) +// +end // end of [process_cmdline2] +// +in (* in-of-local *) + +implement +jsonize0_main0 + (argc, argv) = let +// +val +XATSHOME = +$GLO.the_XATSHOME_get((*void*)) +// +val () = +$FP0.the_includes_push(XATSHOME) +// +val+ +list_cons +(arg0, args) = args where +{ + val + args = + parse_commarglst(argc, argv) +} (* end of [val] *) +// +var +st0: cmdstate = +@{ + arg0= arg0 +, wtk0= WTKnone() +// +, ATSHOME= XATSHOME +// +, prelude= 0(*~loaded*) +// +, inpfil0= + $FP0.the_filpath_dummy +// +, ninpfil= 0(*initset*) +// +// load status of prelude files +// +, outmode= file_mode_w +, outchan= OUTCHANref(stdout_ref) +// +, nxerror= 0(*initset*) +// +} (* end of [var] *) +// +val () = +process_cmdline(st0, args) +// +in +// +if (st0.nxerror > 0) then $ERR.abort() +// +end // end of [xatsopt_main0] + +end // end of [local] + +(* ****** ****** *) + +(* end of [jsonize0.dats] *) diff --git a/contrib/sparverius/xjsonize/DATS/label0.dats b/contrib/sparverius/xjsonize/DATS/label0.dats new file mode 100644 index 000000000..71c784c86 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/label0.dats @@ -0,0 +1,37 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" + +#staload "{$XATS}/SATS/label0.sats" +#staload "{$XATS}/DATS/label0.dats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/label0.sats" +#staload "./../SATS/symbol.sats" + + +implement +jsonize_label + (l0) = +node("label", rst) where +val rst = +( + case+ label_get_int(l0) of + | ~None_vt() => ( + case+ label_get_sym(l0) of + | ~None_vt() => jsonize("None") + | ~Some_vt(sym) => + jsonify("LABsym", "s0", jsonize(sym)) + ) + | ~Some_vt(int) => + jsonify("LABint", "i0", jsonize(int)) +) +end diff --git a/contrib/sparverius/xjsonize/DATS/lexing_token.dats b/contrib/sparverius/xjsonize/DATS/lexing_token.dats new file mode 100644 index 000000000..7fdbe5bdd --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/lexing_token.dats @@ -0,0 +1,289 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/lexing.sats" +#staload "./../SATS/locinfo.sats" +#staload "./../SATS/basics.sats" + +#staload SYM_J = "./../SATS/symbol.sats" + +overload jsonize with $SYM_J.jsonize_symbol + + +implement +jsonize_tnode(tnd) = //labval2(jsonize("tnode"), res) where +//jsonval_labval1("tnode", res) where +(* res where *) +node("tnode", res) where +val res = +( +case+ tnd of +// +| T_EOF() => jsonize("EOF") +| T_ERR() => jsonize("ERR") +// +| T_EOL() => jsonize("EOL") +// +| T_BLANK(x) => + jsonify("BLANK", "x", jsonize(x)) +// +| T_CLNLT(x) => + jsonify("CLNLT", "x", jsonize(x)) +| T_DOTLT(x) => + jsonify("DOTLT", "x", jsonize(x)) +// +| T_IDENT_alp(x) => + jsonify("IDENT_alp", "x", jsonize(x)) +| T_IDENT_sym(x) => + jsonify("IDENT_sym", "x", jsonize(x)) +// +| T_IDENT_srp(x) => + jsonify("IDENT_srp", "x", jsonize(x)) +| T_IDENT_dlr(x) => + jsonify("IDENT_dlr", "x", jsonize(x)) +// +| T_IDENT_qual(x) => + jsonify("IDENT_qual", "x", jsonize(x)) +// +| T_INT1(rep) => + jsonify("INT1", "rep", jsonize(rep)) +| T_INT2(base, rep) => + jsonify("INT3", ("base", "rep"), (jsonize(base), jsonize(rep))) +| T_INT3(base, rep, k0(*sfx*)) => + jsonify("INT3", ("base", "rep", "k0"), + (jsonize(base), jsonize(rep), jsonize(k0))) +// +| T_FLOAT1(rep) => + jsonify("FLOAT1", "rep", jsonize(rep)) +| T_FLOAT2(base, rep) => + jsonify("FLOAT2", ("base", "rep"), (jsonize(base), jsonize(rep))) + +| T_FLOAT3(base, rep, k0(*sfx*)) => + jsonify("FLOAT3", ("base", "rep", "k0"), + (jsonize(base), jsonize(rep), jsonize(k0))) +// +(* +| T_CHAR(chr) => + let + val chr = int2char0(chr) + in + jsonify("CHAR"), jnul()) // chr, ")") + end +*) +| T_CHAR_nil(rep) => + jsonify("CHAR_nil", "rep", jsonize(rep)) +| T_CHAR_char(rep) => + jsonify("CHAR_char", "rep", jsonize(rep)) +| T_CHAR_slash(rep) => + jsonify("CHAR_slash", "rep", jsonize(rep)) +// +| T_STRING_closed(str) => + jsonify("STRING_closed", "str", jsonize(str)) +| T_STRING_unclsd(str) => + jsonify("STRING_unclsd", "str", jsonize(str)) +// +(* +| T_CDATA(cdata, asz) => jsonify(("CDATA(...)") +*) +// +| T_SPECHAR(c) => + jsonify("SPECHAR", "c", jsonize(int2char0(c))) +// +| T_COMMENT_line + (init, content) => + jsonify("T_COMMENT_line", ("init", "content"), + (jsonize(init), jsonize(content))) +| T_COMMENT_rest + (init, content) => + jsonify("T_COMMENT_rest", ("init", "content"), + (jsonize(init), jsonize(content))) +| T_COMMENT_cblock + (level, content) => + jsonify("T_COMMENT_cblock", ("level", "content"), + (jsonize(level), jsonize(content))) +| T_COMMENT_mlblock + (level, content) => + jsonify("T_COMMENT_mlblock", ("level", "content"), + (jsonize(level), jsonize(content))) +// +| T_AT() => jsonize("AT") +// +| T_BAR() => jsonize("BAR") +| T_CLN() => jsonize("CLN") +| T_DOT() => jsonize("DOT") +// +| T_EQ() => jsonize("EQ") +// +| T_LT() => jsonize("LT") +| T_GT() => jsonize("GT") +// +| T_DLR() => jsonize("DLR") +| T_SRP() => jsonize("SRP") +// +| T_EQLT() => jsonize("EQLT") +| T_EQGT() => jsonize("EQGT") +// +| T_LTGT() => jsonize("LTGT") +| T_GTLT() => jsonize("GTLT") +// +| T_MSLT() => jsonize("MSLT") +(* +| T_MSGT() => jsonize("MSGT") +| T_MSLTGT() => jsonize("MSLTGT") +*) +// +(* +| T_DOTLT() => jsonize("DOTLT") +*) +| T_GTDOT() => jsonize("GTDOT") +// +| T_COMMA() => jsonize("COMMA") +| T_SMCLN() => jsonize("SMCLN") +// +| T_BSLASH() => jsonize("BSLASH") +// +| T_LPAREN() => jsonize("LPAREN") +| T_RPAREN() => jsonize("RPAREN") +| T_LBRACE() => jsonize("LBRACE") +| T_RBRACE() => jsonize("RBRACE") +// +| T_LBRACK() => jsonize("LBRACK") +| T_RBRACK() => jsonize("RBRACK") +// +| T_EXISTS(knd) => + jsonify("EXISTS", "knd", jsonize(knd)) +// +| T_TUPLE(knd) => + jsonify("TUPLE", "knd", jsonize(knd)) +| T_RECORD(knd) => + jsonify("RECORD", "knd", jsonize(knd)) +(* +| T_STRUCT() => jsonize("STRUCT") +*) +// +| T_AS() => jsonize("AS") +// +| T_OF() => jsonize("OF") +// +| T_OP() => jsonize("OP") +// +| T_OP_par() => + jsonify("OP_par") +| T_OP_sym(id) => + jsonify("OP_sym", "id",jsonize(id)) +// +| T_IN() => jsonify("IN") +// +| T_AND() => jsonify("AND") +| T_END() => jsonify("END") +// +| T_IF() => jsonify("IF") +| T_SIF() => jsonify("SIF") +| T_THEN() => jsonify("THEN") +| T_ELSE() => jsonify("ELSE") +// +| T_WHEN() => jsonify("WHEN") +| T_WITH() => jsonify("WITH") +// +| T_CASE(k0) => + jsonify("CASE", "k0", jsonize(k0)) +// +| T_SCASE() => jsonify("SCASE") +// +| T_ENDIF() => jsonify("ENDIF") +| T_ENDSIF() => jsonify("ENDSIF") +| T_ENDCASE() => jsonify("ENDCASE") +| T_ENDSCASE() => jsonify("ENDSCASE") +// +| T_LAM(knd) => + jsonify("LAM", "knd", jsonize(knd)) +| T_FIX(knd) => + jsonify("FIX", "knd", jsonize(knd)) +// +| T_LET() => jsonify("LET") +| T_WHERE() => jsonify("WHERE") +| T_LOCAL() => jsonify("LOCAL") +// +| T_ENDLAM() => jsonify("ENDLAM") +| T_ENDLET() => jsonify("ENDLET") +| T_ENDWHERE() => jsonify("ENDWHERE") +| T_ENDLOCAL() => jsonify("ENDLOCAL") +// +| T_VAL(vlk) => + jsonify("VAL", "vlk", jsonize(vlk)) +| T_VAR() => jsonify("VAR") +// +| T_FUN(fnk) => + jsonify("FUN", "fnk", jsonize(fnk)) +// +| T_IMPLMNT(knd) => + jsonify("IMPLMNT", "knd", jsonize(knd)) +// +| T_ABSSORT() => + jsonify("ABSSORT") +// +| T_SORTDEF() => + jsonify("SORTDEF") +// +| T_SEXPDEF(srt) => + jsonify("SEXPDEF", "srt", jsonize(srt)) +// +| T_ABSTYPE(srt) => + jsonify("ABSTYPE", "srt", jsonize(srt)) +// +| T_ABSIMPL() => + jsonify("ABSIMPL") +| T_ABSOPEN() => + jsonify("ABSOPEN") +// +| T_DATASORT() => + jsonify("DATASORT") +| T_DATATYPE(srt) => + jsonify("DATATYPE", "srt", jsonize(srt)) +// +| T_WITHTYPE(srt) => + jsonify("WITHTYPE", "srt", jsonize(srt)) +// +| T_SRP_NONFIX() => + jsonify("#NONFIX") +| T_SRP_FIXITY(knd) => + jsonify("#FIXIXTY", "knd", jsonize(knd)) +// +| T_SRP_STACST() => jsonify("#STACST") +// +| T_SRP_STATIC() => jsonify("#STATIC") +| T_SRP_EXTERN() => jsonify("#EXTERN") +// +| T_SRP_DEFINE() => jsonify("#DEFINE") +| T_SRP_MACDEF() => jsonify("#MACDEF") +// +| T_SRP_INCLUDE() => jsonify("#INCLUDE") +// +| T_SRP_STALOAD() => jsonify("#STALOAD") +| T_SRP_DYNLOAD() => jsonify("#DYNLOAD") +// +| T_SRP_SYMLOAD() => jsonify("#SYMLOAD") +// +) (* end of [jsonize_tnode] *) +end + +implement +jsonize_token(tok) = + (* labval2(jsonize("token"), jsonize_tnode(tok.node())) *) + (* jsonval_labval1("token", jsonize_tnode(tok.node())) *) + (* jsonify("token", ("loc", "tok"), (jsonize(tok.loc()), jsonize_tnode(tok.node()))) *) +(* + node("token", JSONlist( + $list{jsonval}( + jsonize_location(tok.loc()), + jsonize_tnode(tok.node()) + ) + )) +*) + +node2("token", jsonize_location(tok.loc()), jsonize_tnode(tok.node())) diff --git a/contrib/sparverius/xjsonize/DATS/locinfo.dats b/contrib/sparverius/xjsonize/DATS/locinfo.dats new file mode 100644 index 000000000..a01dbc6be --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/locinfo.dats @@ -0,0 +1,113 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + + +#define XATS_targetloc "./../../../../srcgen/xats" + + +#staload "{$XATS}/SATS/locinfo.sats" + + +#staload "./../SATS/locinfo.sats" + + +implement labify_loc_t(loc) = @("loc", jsonize_loc_t(loc)) + +implement +jsonize_loc_t(loc) = +( + JSONlablist($list{labjsonval}( + ("path", + jsonize($FIL.filpath_get_full1(loc.filpath())) + ), + ("beg", jsonize(loc.beg_ntot()+1)) + (* JSONlablist($list{labjsonval}( *) + (* ("chrs", jsonize(loc.beg_ntot()+1)), *) + (* ("line", jsonize(loc.beg_nrow()+1)), *) + (* ("offs", jsonize(loc.beg_ncol())) *) + (* )) *) + (* ) *) + , + ("end", jsonize(loc.end_ntot()+1)) + (* JSONlablist($list{labjsonval}( *) + (* ("chrs", jsonize(loc.end_ntot()+1)), *) + (* ("line", jsonize(loc.end_nrow()+1)), *) + (* ("offs", jsonize(loc.end_ncol())) *) + (* )) *) + (* ) *) + )) +) + + +implement +jsonize_locrange(loc) = +( + (* jsonval_labval1("pos", *) +(* + JSONlablist($list{labjsonval}( + ("beg", + JSONlablist($list{labjsonval}( + ("chrs", jsonize(loc.beg_ntot()+1)), + ("line", jsonize(loc.beg_nrow()+1)), + ("offs", jsonize(loc.beg_ncol())) + )) + ), + ("end", + JSONlablist($list{labjsonval}( + ("chrs", jsonize(loc.end_ntot()+1)), + ("line", jsonize(loc.end_nrow()+1)), + ("offs", jsonize(loc.end_ncol())) + )) + ) + )) +*) + JSONlablist($list{labjsonval}( + ("path", jsonize($FIL.filpath_get_full1(loc.filpath()))), + ("beg", jsonize(loc.beg_ntot()+1)), + ("end", jsonize(loc.end_ntot()+1)) + )) + + (* ) *) +) + +(* +implement +jsonize_location(loc) = res where + val fp0 = location_filpath(loc) + val jfil = jsonize($FIL.filpath_get_full1(fp0)) + val res = jsonval_labval1("loc", jfil) +end +*) + +(* +implement +jsonize_location(loc) = res where + val fp0 = location_filpath(loc) + val jfil = jsonize($FIL.filpath_get_full1(fp0)) + val res = jsonval_labval1("loc", jfil) + + val res = node("loc", rst) where + val fst = ("path", jfil) + val snd = ("pos", jsonize_locrange(loc)) + val rst = JSONlablist($list{labjsonval}(fst, snd)) + end +end +*) + +implement +jsonize_location(loc) = res where + val fp0 = location_filpath(loc) + val jfil = jsonize($FIL.filpath_get_full1(fp0)) + (* val res = jsonval_labval1("loc", jfil) *) + + (* val fst = ("path", jfil) *) + (* val snd = ("pos", jsonize_locrange(loc)) *) + (* val res = JSONlablist($list{labjsonval}(fst, snd)) *) + + val res = jsonize_locrange(loc) +end diff --git a/contrib/sparverius/xjsonize/DATS/staexp0.dats b/contrib/sparverius/xjsonize/DATS/staexp0.dats new file mode 100644 index 000000000..1c0322606 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/staexp0.dats @@ -0,0 +1,773 @@ + +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/staexp0.sats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/dynexp0.sats" +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/label0.sats" +#staload "./../SATS/lexing.sats" + + +implement +jsonize_val = jsonize_token + +implement +jsonize_t0int + (x0) = +( +case+ x0.node() of +| T0INTnone(tok) => + jsonify("T0INTnone", "tok", jsonize(tok)) +| T0INTsome(tok) => + jsonify("T0INTsome", "tok", jsonize(tok)) +) + +implement +jsonize_t0chr + (x0) = +( +case+ x0.node() of +| T0CHRnone(tok) => + jsonify("T0CHRnone", "tok", jsonize(tok)) +| T0CHRsome(tok) => + jsonify("T0CHRsome", "tok", jsonize(tok)) +) + + +implement +jsonize_t0flt + (x0) = +( +case+ x0.node() of +| T0FLTnone(tok) => + jsonify("T0FLTnone", "tok", jsonize(tok)) +| T0FLTsome(tok) => + jsonify("T0FLTsome", "tok", jsonize(tok)) +) + + +implement +jsonize_t0str + (x0) = +( +case+ x0.node() of +| T0STRnone(tok) => + jsonify("T0STRnone", "tok", jsonize(tok)) +| T0STRsome(tok) => + jsonify("T0STRsome", "tok", jsonize(tok)) +) + + +implement +jsonize_i0dnt + (x0) = +( +case+ x0.node() of +| I0DNTnone(tok) => + jsonify("I0DNTnone", "tok", jsonize(tok)) +| I0DNTsome(tok) => + jsonify("I0DNTsome", "tok", jsonize(tok)) +) + + +implement +jsonize_l0abl + (l0) = +( +case+ +l0.node() of +| L0ABLsome(lab) => + jsonify("L0ABLsome", "lab", jsonize(lab)) +| L0ABLnone(tok) => + jsonify("L0ABLnone", "tok", jsonize(tok)) +) + + +implement +jsonize_s0ymb + (x0) = +( +case+ +x0.node() of +// +| S0YMBi0dnt(id0) => + jsonify("S0YMBi0dnt", "id0", jsonize(id0)) +// +| S0YMBdtlab(dot1, lab2) => + jsonify("S0YMBdtlab", ("dot1", "lab2"), (jsonize(dot1), jsonize(lab2))) +| S0YMBbrack(tok1, tok2) => + jsonify("S0YMBbrack", ("tok1", "tok2"), (jsonize(tok1), jsonize(tok2))) +// +) (* end of [jsonize_s0ymb] *) + + + +implement +jsonize_sq0eid + (x0) = +( +case+ x0 of +| SQ0EIDnone(sid) => + jsonify("SQ0EIDnone", "sid", jsonize(sid)) +| SQ0EIDsome(tok, sid) => + jsonify("SQ0EIDsome", ("tok", "sid"), (jsonize(tok), jsonize(sid))) +) + + +implement +jsonize_dq0eid + (x0) = +( +case+ x0 of +| DQ0EIDnone(sid) => + jsonify("DQ0EIDnone", "sid", jsonize(sid)) +| DQ0EIDsome(tok, sid) => + jsonify("DQ0EIDsome", ("tok", "sid"), (jsonize(tok), jsonize(sid))) +) + + + +local + +implement +jsonize_val = jsonize_g0exp + +in (* in-of-local *) + +implement +jsonize_g0exp + (x0) = +( +case+ x0.node() of +// +| G0Eid(tid) => + jsonify("GOEid", "tid", jsonize(tid)) +// +| G0Eint(int) => + jsonify("GOEint", "int", jsonize(int)) +// +| G0Eapps(s0ts) => + jsonify("GOEapps", "s0ts", jsonize_list(s0ts)) +// +| G0Elist(t0, g0es, t1) => + jsonify("GOElist", ("t0", "g0es", "t1"), + (jsonize(t0), jsonize_list(g0es), jsonize(t1)) + ) +// +| G0Enone(tok) => + jsonify("G0Enone", "tok", jsonize(tok)) +// +) (* end of [jsonize_g0exp] *) + +end + + +local + +implement +jsonize_val = jsonize_i0dnt + +in (* in-of-local *) + +implement +jsonize_g0marg + (x0) = +( +case+ +x0.node() of +| G0MARGnone(tok) => + jsonify("G0MARGnone", "tok", jsonize(tok)) +| G0MARGsarg(tbeg, g0as, tend) => + jsonify("G0MARGsarg", ("tbeg", "g0as", "tend"), rst) where + val rst = (jsonize(tbeg), jsonize_list(g0as), jsonize(tend)) + end +| G0MARGdarg(tbeg, g0as, tend) => + jsonify("G0MARGdarg", ("tbeg", "g0as", "tend"), rst) where + val rst = (jsonize(tbeg), jsonize_list(g0as), jsonize(tend)) + end +) (* jsonize_g0marg *) + +end // end of [local] + + +local + +implement +jsonize_val = jsonize_sort0 + +in (* in-of-local *) + +implement +jsonize_sort0 + (x0) = +( +case+ x0.node() of +// +| S0Tid(tid) => + jsonify("S0Tid", "tid", jsonize(tid)) +// +| S0Tint(int) => + jsonify("S0Tint", "tid", jsonize(int)) +// +| S0Tapps(s0ts) => + jsonify("S0Tapps", "s0ts", jsonize_list(s0ts)) +// +| S0Tlist(t0, s0ts, t1) => + jsonify("S0Tlist", ("t0", "s0ts", "t1"), rst) where + val js0ts = jsonize_list(s0ts) + val rst = (jsonize(t0), js0ts, jsonize(t1)) + end +// +| S0Tqual(q0, s0t) => + jsonify("S0Tqid", ("q0", "s0t"), (jsonize(q0), jsonize(s0t))) +// +| S0Tnone(tok) => + jsonify("S0Tnone", "tok", jsonize(tok)) +// +) (* end of [jsonize_sort0] *) + +end // end of [local] + +implement +jsonize_val = jsonize_sort0 + +implement +jsonize_s0rtcon + (x0) = +( +case+ x0.node() of +| S0RTCON(sid, opt) => + jsonify("S0RTCON", ("sid", "opt"), + (jsonize(sid), jsonize_option(opt)) + ) +) (* end of [jsonize_s0rtcon] *) + + +local + +implement jsonize_val = jsonize_s0rtcon + +in + +implement +jsonize_d0tsort + (x0) = +( +case+ x0.node() of +| D0TSORT(tid, tok, s0cs) => + jsonify("D0RTCON", ("tid", "tok", "s0cs"), ( + jsonize(tid), + jsonize(tok), + jsonize_list(s0cs) + ) + ) +) (* end of [jsonize_d0tsort] *) + +end + + +implement +jsonize_val = jsonize_s0exp + + +implement +jsonize_s0rtdef + (x0) = +( +case+ x0.node() of +| S0RTDEFsort(s0t) => + jsonify("S0RTDEFsort", "s0t", jsonize(s0t)) +| S0RTDEFsbst(tbeg, s0a0, tbar, s0es, tend) => + jsonify("S0RTDEFsbst", args, rst) where + val args = ("tbeg", "s0a0", "tbar", "s0es", "tend") + val rst = ( + jsonize(tbeg), + jsonize(s0a0), + jsonize(tbar), + jsonize_list(s0es), + jsonize(tend) + ) + end +) (* end of [jsonize_s0rtdef] *) + + +implement +jsonize_s0arg + (x0) = +( +case+ +x0.node() of +| S0ARGnone(tok) => + jsonify("S0ARGnone", "tok", jsonize(tok)) +| S0ARGsome(sid, opt) => + jsonify("S0ARGsome", ("sid", "opt"), + (jsonize(sid), jsonize_option(opt)) + ) +) (* jsonize_s0arg *) + + +implement +jsonize_val = jsonize_s0arg + +implement +jsonize_s0marg + (x0) = +( +case+ +x0.node() of +| S0MARGnone(tok) => + jsonify("S0MARGnone", "tok", jsonize(tok)) +| S0MARGsing(tid) => + jsonify("S0MARGsing", "tid", jsonize(tid)) +| S0MARGlist(tbeg, s0as, tend) => + jsonify("S0MARGlist", ("tbeg", "s0as", "tend"), + ( + jsonize(tbeg), + jsonize_list(s0as), + jsonize(tend) + ) + ) +) (* jsonize_s0marg *) + + +implement +jsonize_t0arg + (x0) = +( +case+ +x0.node() of +| T0ARGsome(tid, opt) => + jsonify("T0ARGsome", ("sid", "opt"), + (jsonize(tid), jsonize_option(opt)) + ) +) (* jsonize_t0arg *) + + +implement +jsonize_val = jsonize_t0arg + +implement +jsonize_t0marg + (x0) = +( +case+ +x0.node() of +| T0MARGnone(tok) => + jsonify("T0MARGnone", "tok", jsonize(tok)) +| T0MARGlist(tbeg, t0as, tend) => + jsonify("T0MARGlist", ("tbeg", "t0as", "tend"), + ( + jsonize(tbeg), + jsonize_list(t0as), + jsonize(tend) + ) + ) +) (* jsonize_t0marg *) + +implement +jsonize_val = jsonize_i0dnt + +implement +jsonize_s0qua + (x0) = +( +case+ x0.node() of +| S0QUAprop(s0e) => + jsonify("S0QUAprop", "s0e", jsonize(s0e)) +| S0QUAvars(ids, opt) => + jsonify("S0QUAprop", ("ids", "opt"), + (jsonize_list(ids), jsonize_option(opt)) + ) +) + +implement +jsonize_val = jsonize_s0qua + + +implement +jsonize_s0uni + (x0) = +( +case+ x0.node() of +| S0UNInone(tok) => + jsonify("S0UNInone", "tok", jsonize(tok)) +| S0UNIsome(tbeg, s0qs, tend) => + jsonify("S0UNIsome", ("tbeg", "s0qs", "tend"), ( + jsonize(tbeg), + jsonize_list(s0qs), + jsonize(tend) + ) + ) +) + +implement +jsonize_val = jsonize_sl0abled + + +implement +{a}(*tmp*) +jsonize_sl0abled + (x0) = let +// +val+SL0ABLED(l0, t0, x1) = x0 +// +in +node("sl0abled", res) where +val res = + jsonify("SL0ABLED", ("l0", "t0", "x1"), rst) where + val rst = ( + jsonize(l0), + jsonize(t0), + jsonize_val(x1) + ) + end +end + +end // end of [jsonize_sl0abled] + + + +local + +implement jsonize_val = jsonize_s0exp +implement jsonize_val = jsonize_s0marg +(* +implement(a:t@ype) +jsonize_val = jsonize_sl0abled +*) + +in (* in-of-local *) + +implement +jsonize_s0exp + (x0) = +( +case+ x0.node() of +// +| S0Eid(sid) => + jsonify("S0Eid", "sid", jsonize(sid)) +// +| S0Eop1(opid) => + jsonify("S0Eop1", "opid", jsonize(opid)) +| S0Eop2(tbeg, opid, tend) => + jsonify( + "S0Eop1", ( + "tbeg", + "opid", + "tend" + ), ( + jsonize(tbeg), + jsonize(opid), + jsonize(tend) + ) + ) +// +| S0Eint(i0) => + jsonify("S0Eint", "i0", jsonize(i0)) +| S0Echr(c0) => + jsonify("S0Echr", "c0", jsonize(c0)) +| S0Eflt(f0) => + jsonify("S0Eflt", "f0", jsonize(f0)) +| S0Estr(s0) => + jsonify("S0Estr", "s0", jsonize(s0)) +// +| S0Eapps(s0es) => + jsonify("S0Eapps", "s0es", jsonize_list(s0es)) +// +| S0Eimp(tbeg, s0es, tend) => + jsonify( + "S0Eimp", ( + "tbeg", + "s0es", + "tend" + ), ( + jsonize(tbeg), + jsonize_list(s0es), + jsonize(tend) + ) + ) +| S0Eparen + (tbeg, s0es, tend) => + jsonify( + "S0Eparen", ( + "tbeg", + "s0es", + "tend" + ), ( + jsonize(tbeg), + jsonize_list(s0es), + jsonize(tend) + ) + ) + +// +| S0Eforall(tbeg, s0qs, tend) => + jsonify( + "S0Eforall", ( + "tbeg", + "s0qs", + "tend" + ), ( + jsonize(tbeg), + jsonize_list(s0qs), + jsonize(tend) + ) + ) + +| S0Eexists(tbeg, s0qs, tend) => + jsonify( + "S0Eexists", ( + "tbeg", + "s0qs", + "tend" + ), ( + jsonize(tbeg), + jsonize_list(s0qs), + jsonize(tend) + ) + ) +// +| S0Etuple + (tbeg, topt, s0es, tend) => + jsonify( + "S0Etuple", ( + "tbeg", + "topt", + "s0es", + "tend" + ), ( + jsonize(tbeg), + jsonize_option(topt), + jsonize_list(s0es), + jsonize(tend) + ) + ) +| S0Erecord + (tbeg, topt, s0es, tend) => + jsonify( + "S0Erecord", ( + "tbeg", + "topt", + "s0es", + "tend" + ), ( + jsonize(tbeg), + jsonize_option(topt), + jsonize_list(s0es), + jsonize(tend) + ) + ) +// +| S0Elam + ( tbeg + , arg0, res1 + , tok1, s0e0, tend) => + jsonify( + "S0Elam", ( + "tbeg", + "arg0", + "res1", + "tok1", + "s0e0", + "tend" + ), ( + jsonize(tbeg), + jsonize_list(arg0), + jsonize_option(res1), + jsonize(tok1), + jsonize(s0e0), + jsonize_option(tend) + ) + ) +// +| S0Eanno + (s0e, ann) => + jsonify( + "S0Eanno", ( + "s0e", + "ann" + ), ( + jsonize(s0e), + jsonize(ann) + ) + ) +// +| S0Equal + (tok, s0e) => + jsonify( + "S0Equal", ( + "tok", + "s0e" + ), ( + jsonize(tok), + jsonize(s0e) + ) + ) +// +| S0Enone(tok) => + jsonify("S0Enone", "tok", jsonize(tok)) +// +) (* end of [jsonize_s0exp] *) + +end // end of [local] + + + +local + +implement +jsonize_val = jsonize_s0exp + +in (* in-of-local *) + +implement +jsonize_s0exp_RPAREN + (x0) = +( +case+ x0 of +| s0exp_RPAREN_cons0(tok) => + jsonify("s0exp_RPAREN_cons0", "tok", jsonize(tok)) +| s0exp_RPAREN_cons1(tok1, s0es, tok2) => + jsonify("s0exp_RPAREN_cons1", ( + "tok1", + "s0es", + "tok2" + ), ( + jsonize(tok1), + jsonize_list(s0es), + jsonize(tok2) + ) + ) +) (* end of [jsonize_s0exp_RPAREN] *) + +end // end of [local] + + + +local + +implement +jsonize_val = jsonize_s0exp + +in (* in-of-local *) + +implement +jsonize_labs0exp_RBRACE + (x0) = +( +case+ x0 of +| labs0exp_RBRACE_cons0(tok) => + jsonify("labs0exp_RBRACE_cons0", "tok", jsonize(tok)) +| labs0exp_RBRACE_cons1(tok1, ls0es, tok2) => + jsonify("labs0exp_RBRACE_cons0", ( + "tok1", + "ls0es", + "tok2" + ), ( + jsonize(tok1), + jsonize_list(ls0es), + jsonize(tok2) + ) + ) +) (* end of [jsonize_labs0exp_RBRACE] *) + +end // end of [local] + + + +implement +jsonize_effs0expopt + (x0) = +( +case+ x0 of +| EFFS0EXPnone() => + jsonify("EFFS0EXPnone") +| EFFS0EXPsome(s0e) => + jsonify("EFFS0EXPsome", "s0e", jsonize(s0e)) +(* +| EFFS0EXPsome(s0f, s0e) => + jsonify("EFFS0EXPsome", ("s0f", "s0e"), (jsonize(s0f), jsonize(s0e))) +*) +) (* end of [jsonize_effs0expopt] *) + + + +implement jsonize_val = jsonize_t0marg +implement jsonize_val = jsonize_d0atcon +implement jsonize_val = jsonize_sort0 + +implement +jsonize_d0atype + (x0) = +( +case+ x0.node() of +| D0ATYPE(tid, arg, res, teq, d0cs) => + jsonify ( + "D0ATYPE", + ( + "tid", + "arg", + "res", + "teq", + "d0cs" + ), + ( + jsonize(tid), + jsonize_list(arg), + jsonize_option(res), + jsonize(teq), + jsonize_list(d0cs) + ) + ) +) (* end of [jsonize_d0atype] *) + + +local + +implement jsonize_val = jsonize_s0uni +implement jsonize_val = jsonize_s0exp + +in + +implement +jsonize_d0atcon + (x0) = +( +case+ x0.node() of +| D0ATCON(s0us, dcon, s0is, argopt) => + jsonify( + "D0ATCON", + ( + "s0us", + "dcon", + "s0is", + "argopt" + ), + ( + jsonize_list(s0us), + jsonize(dcon), + jsonize_list(s0is), + jsonize_option(argopt) + ) + ) + where + val jargopt = ( + case+ argopt of + | None() => jsonify("None") + | Some(x) => jsonize(x) + ) + end +) (* end of [jsonize_d0atcon] *) + +end diff --git a/contrib/sparverius/xjsonize/DATS/staexp1.dats b/contrib/sparverius/xjsonize/DATS/staexp1.dats new file mode 100644 index 000000000..d65412d1a --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/staexp1.dats @@ -0,0 +1,530 @@ + +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/staexp0.sats" +#staload "{$XATS}/SATS/staexp1.sats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/dynexp0.sats" +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/label0.sats" +#staload "./../SATS/lexing.sats" +#staload "./../SATS/locinfo.sats" + +#staload "./../SATS/staexp1.sats" +#staload _ = "./staexp0.dats" + +#staload SYM_J = "./../SATS/symbol.sats" +overload jsonize with $SYM_J.jsonize_symbol + + +implement +jsonize_val = jsonize_s1exp +implement +jsonize_val = jsonize_sl0abled + + +implement +jsonize_val = jsonize_token + + +local + +implement +jsonize_val = jsonize_g1exp + +in (* in-of-local *) + +implement +jsonize_g1exp + (x0) = +node("g1exp", res) where +val res = +( +case+ x0.node() of +// +| G1Eid(tok) => + jsonify("G1Eid", "tok", jsonize(tok)) +// +| G1Eint(int) => + jsonify("G1Eint", "int", jsonize(int)) +// +| G1Eapp() => + jsonify("G1Eapp") +// +| G1Eapp1 + (g1e0, g1e1) => + jsonify("G1Eapp1", ("g1e0", "g1e1"), (jsonize(g1e0), jsonize(g1e1))) +| G1Eapp2 + (g1e0, g1e1, g1e2) => + jsonify("G1Eapp2", ("g1e0", "g1e1", "g1e2"), + (jsonize(g1e0), jsonize(g1e1), jsonize(g1e2)) + ) +// +| G1Elist(g1es) => + jsonify("G1Elist", "g1es", jsonize_list(g1es)) +// +| G1Enone(loc) => + jsonify("G1Enone") +// +) (* end of [jsonize_g1exp] *) +end + +end // end of [local] + + +local + +implement +jsonize_val = jsonize_token + +in(* in-of-local *) + +implement +jsonize_g1marg + (x0) = +node("g1marg", res) where +val res = +( +case+ +x0.node() of +| G1MARGsarg(g1as) => + jsonify("G1MARGsarg", "g1as", jsonize_list(g1as)) +| G1MARGdarg(g1as) => + jsonify("G1MARGdarg", "g1as", jsonize_list(g1as)) +) (* end of [jsonize_g1marg] *) +end + +end // end of [local] + + + +local + +implement +jsonize_val = jsonize_sort1 + +in (* in-of-local *) + +implement +jsonize_sort1 + (x0) = +node("sort1", res) where +val res = +( +case+ x0.node() of +// +| S1Tid(id) => + jsonify("S1Tid", "id", jsonize(id)) +// +| S1Tint(int) => + jsonify("S1Tapp", "int", jsonize(int)) +// +| S1Tapp() => + jsonify("S1Tapp") +// +(* +| S1Ttype(knd) => + jsonify("S1Ttype", "knd", jsonize(knd)) +*) +// +(* +| S1Tapp(s1t0, s1ts) => + jsonify("S1Tapp", ("s1t0", "s1ts"), (jsonize(s1t0), jsonize(s1ts))) +*) +// +| S1Tapp1 + (s1t0, s1t1) => + jsonify("S1Tapp1", ("s1t0", "s1t1"), (jsonize(s1t0), jsonize(s1t1))) +| S1Tapp2 + (s1t0, s1t1, s1t2) => + jsonify("S1Tapp2", ("s1t0", "s1t1", "s1t2"), + ( + jsonize(s1t0), + jsonize(s1t1), + jsonize(s1t2) + ) + ) +// +| S1Tlist(s1ts) => + jsonify("S1Tlist", "s1ts", jsonize_list(s1ts)) +// +| S1Tqual(tok0, s1t1) => + jsonify("S1Tnone", ("tok0", "s1t1"), (jsonize(tok0), jsonize(s1t1))) +// +| S1Tnone((*void*)) => + jsonify("S1Tnone") +// +) (* end of [jsonize_sort1] *) +end + +end // end of [local] + + +implement +jsonize_val = jsonize_sort1 +implement +jsonize_val = jsonize_s1rtcon + + +implement +jsonize_s1rtcon + (x0) = +node("s1rtcon", res) where +val res = +( +case+ x0.node() of +| S1RTCON(sid, opt) => + jsonify("S1RTCON", ("sid", "opt"), + ( + jsonize(sid), + jsonize_option(opt) + ) + ) +) (* end of [jsonize_s1rtcon] *) +end + + + +implement +jsonize_d1tsort + (x0) = +node("d1sort", res) where +val res = +( +case+ x0.node() of +| D1TSORT(tid, s1cs) => + jsonify("D1TSORT", ("tid", "s1cs"), + (jsonize(tid), jsonize_list(s1cs)) + ) +) (* end of [jsonize_d1tsort] *) +end + +implement +jsonize_s1rtdef + (x0) = +node("s1rtdef", res) where +val res = +( +case+ x0.node() of +| S1RTDEFsort(s1t) => + jsonify("S1RTDEFsort", "s1t", jsonize(s1t)) +| S1RTDEFsbst(s1a0, s1es) => + jsonify("S1RTDEFsbst(", ("s1a0", "s1es"), + (jsonize(s1a0), jsonize_list(s1es)) + ) +) (* end of [jsonize_s1rtdef] *) +end + +implement +jsonize_s1arg + (x0) = +node("s1arg", res) where +val res = +( +case+ +x0.node() of +(* +| S1ARGnone() => + jsonify("S1ARGnone()") +*) +| S1ARGsome(tok, opt) => + jsonify("S1ARGsome(", ("tok", "opt"), + (jsonize(tok), jsonize_option(opt)) + ) +) (* jsonize_s1arg *) +end + +local + +implement +jsonize_val = jsonize_s1arg + +in (* in-of-local *) + +implement +jsonize_s1marg + (x0) = +node("s1marg", res) where +val res = +( +case+ +x0.node() of +(* +| S1MARGnone _ => ... +| S1MARGsing _ => ... +*) +| S1MARGlist(s1as) => + jsonify("S1MARGlist", "s1as", jsonize_list(s1as)) +) (* jsonize_s1marg *) +end + +end // end of [local] + + +implement jsonize_val = jsonize_t1arg + +implement +jsonize_t1arg + (x0) = +node("t1arg", res) where +val res = +( +case+ +x0.node() of +(* +| T1ARGnone() => + jsonify("T1ARGnone") +*) +| T1ARGsome(tok, opt) => + jsonify("T1ARGsome", ("tok", "opt"), + (jsonize(tok), jsonize_option(opt)) + ) +) (* jsonize_t1arg *) +end + +local + +implement +jsonize_val = jsonize_t1arg + +in (* in-of-local *) + +implement +jsonize_t1marg + (x0) = +node("t1marg", res) where +val res = +( +case+ +x0.node() of +(* +| T1MARGnone _ => ... +*) +| T1MARGlist(t1as) => + jsonify("T1MARGlist", "t1as", jsonize_list(t1as)) +) (* jsonize_t1marg *) +end + +end // end of [local] + + +implement +jsonize_s1qua + (x0) = +node("", res) where +val res = +( +case+ x0.node() of +| S1QUAprop(s1e) => + jsonify("S1QUAprop(", "s1e", jsonize(s1e)) +| S1QUAvars(ids, opt) => + jsonify("S1QUAvars(", ("ids", "opt"), + (jsonize_list(ids), jsonize_option(opt)) + ) +) +end + +implement +jsonize_val = jsonize_s1qua + +implement +jsonize_s1uni + (x0) = +node("s1uni", res) where +val res = +( +case+ x0.node() of +| S1UNIsome(s1qs) => + jsonify("S1UNIsome", "s1qs", jsonize_list(s1qs)) +) +end + + +local + +implement +jsonize_val = jsonize_s1exp +implement +jsonize_val = jsonize_s1marg +implement +jsonize_val = jsonize_s1qua + +in (* in-of-local *) + +implement +jsonize_s1exp + (x0) = +node("", res) where +val res = +( +case+ x0.node() of +// +| S1Eid(sid) => + jsonify("S1Eid", "sid", jsonize(sid)) +// +| S1Eint(tok) => + jsonify("S1Eint", "tok", jsonize(tok)) +| S1Echr(tok) => + jsonify("S1Echr", "tok", jsonize(tok)) +| S1Eflt(tok) => + jsonify("S1Eflt", "tok", jsonize(tok)) +| S1Estr(tok) => + jsonify("S1Estr", "tok", jsonize(tok)) +// +| S1Eapp() => + jsonify("S1Eapp") +// +| S1Eapp1 + (s1e0, s1e1) => + jsonify("S1Eapp1", ("s1e0", "s1e1"), (jsonize(s1e0), jsonize(s1e1))) +| S1Eapp2 + (s1e0, s1e1, s1e2) => + jsonify("S1Eapp2", ("s1e0", "s1e1", "s1e2"), + (jsonize(s1e0), jsonize(s1e1), jsonize(s1e2)) + ) +// +| S1Ebs0() => + jsonify("S1Ebs0") +| S1Ebs1(s1e) => + jsonify("S1Ebs1", "s1e", jsonize(s1e)) +// +| S1Eimp(s1es) => + jsonify("S1Eimp", "s1es", jsonize_list(s1es)) +// +(* +| S1Eapp(s1e0, s1es) => + jsonify("S1Eimp", ("s1e0", "s1es"), (jsonize(s1e0), jsonize(s1es))) +*) +// +| S1Elist(s1es) => + jsonify("S1Elist", "s1es", jsonize_list(s1es)) +| S1Elist(s1es1, s1es2) => + jsonify("S1Elist", ("s1es1", "s1es2"), + (jsonize_list(s1es1), jsonize_list(s1es2)) + ) +// +| S1Etuple(k0, s1es) => + jsonify("S1Etuple", ("k0", "s1es"), + (jsonize(k0), jsonize_list(s1es)) + ) +| S1Etuple(k0, s1es1, s1es2) => + jsonify("S1Etuple", ("k0", "s1es1", "s1es2"), + (jsonize(k0), jsonize_list(s1es1), jsonize_list(s1es2)) + ) +// +| S1Erecord(k0, ls1es) => + jsonify("S1Erecord", ("k0", "ls1es"), + (jsonize(k0), jsonize_list(ls1es)) + ) +| S1Erecord(k0, ls1es1, ls1es2) => + jsonify("S1Erecord", ("k0", "ls1es1", "ls1es2"), + ( + jsonize(k0), + jsonize_list(ls1es1), + jsonize_list(ls1es2) + ) + ) +// +| S1Eforall(s1qs) => + jsonify("S1Eforall", "s1qs", jsonize_list(s1qs)) +| S1Eexists(k0, s1qs) => + jsonify("S1Eexists", ("k0", "s1qs"), + (jsonize(k0), jsonize_list(s1qs)) + ) +// +| S1Elam(arg, res, s1e) => + jsonify("S1Elam", ("arg", "res", "s1e"), + ( + jsonize_list(arg), + jsonize_option(res), + jsonize(s1e) + ) + ) +// +| S1Eanno(s1e, s1t) => + jsonify("S1Eanno", ("s1e", "s1t"), (jsonize(s1e), jsonize(s1t))) +// +| S1Equal(tok, s1e) => + jsonify("S1Equal", ("tok", "s1e"), (jsonize(tok), jsonize(s1e))) +// +| S1Enone(loc) => + jsonify("S1Enone", "loc", jsonize(loc)) +// +) (* jsonize_s0exp *) +end + +end // end of [local] + + +implement +jsonize_effs1expopt + (x0) = +node("effs1expopt", res) where +val res = +( +case+ x0 of +| EFFS1EXPnone() => + jsonify("EFFS1EXPnone") +| EFFS1EXPsome(s1e) => + jsonify("EFFS1EXPsome", "s1e", jsonize(s1e)) +(* +| EFFS1EXPsome(s1f, s1e) => + jsonify("EFFS1EXPsome", ("s1f", "s1e"), (jsonize(s1f), jsonize(s1e))) +*) +) (* end of [jsonize_effs1expopt] *) +end + +implement +jsonize_val = jsonize_t1marg +implement +jsonize_val = jsonize_d1atcon +implement +jsonize_val = jsonize_s1uni + +implement +jsonize_d1atype + (x0) = +node("d1atype", res) where +val res = +( +case+ x0.node() of +| D1ATYPE(tok, arg, res, d1cs) => + jsonify("D1ATYPE", ("tok", "arg", "res", "d1cs"), + ( + jsonize(tok), + jsonize_list(arg), + jsonize_option(res), + jsonize_list(d1cs) + ) + ) +) (* end of [jsonize_d1atype] *) +end + +implement +jsonize_d1atcon + (x0) = +node("d1atcon", res) where +val res = +( +case+ x0.node() of +| D1ATCON(s1us, tok, s1is, argopt) => + jsonify("D1ATCON", ("s1us", "tok", "s1is", "argopt"), + ( + jsonize_list(s1us), + jsonize(tok), + jsonize_list(s1is), + jsonize_option(argopt) + ) + ) +) (* end of [jsonize_d1atcon] *) +end diff --git a/contrib/sparverius/xjsonize/DATS/staexp2.dats b/contrib/sparverius/xjsonize/DATS/staexp2.dats new file mode 100644 index 000000000..5e56ef000 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/staexp2.dats @@ -0,0 +1,571 @@ + +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/staexp0.sats" +#staload "{$XATS}/SATS/staexp1.sats" +#staload "{$XATS}/SATS/staexp2.sats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#staload "./../SATS/basics.sats" + + +#staload "./../SATS/dynexp0.sats" +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/label0.sats" +#staload "./../SATS/lexing.sats" + +#staload "./../SATS/staexp1.sats" +#staload "./../SATS/staexp2.sats" + +#staload SYM = "./../SATS/symbol.sats" +#staload LOC = "./../SATS/locinfo.sats" +#staload STM = "./../SATS/stamp0.sats" +#staload LAB = "./../SATS/label0.sats" + +overload jsonize with $LOC.jsonize_location +overload jsonize with $SYM.jsonize_symbol +overload jsonize with $STM.jsonize_stamp + +overload jsonize with $LAB.jsonize_label + +overload labify with $SYM.labify_symbol + + +local + +implement +jsonize_val = jsonize_sort2 + +in (* in-of-local *) + +implement +jsonize_sort2 + (s2t0) = +node("sort2", res) where +val res = +( +case+ s2t0 of +// +| S2Tid(id) => + jsonify("S2Tid", "id", jsonize(id)) +| S2Tint(i0) => + jsonify("S2Tint", "i0", jsonize(i0)) +| S2Tbas(s2tb) => + jsonify("S2Tbas", "s2tb", jsonize(s2tb)) +| S2Ttup() => + jsonify("S2Ttup") +| S2Ttup(s2ts) => + jsonify("S2tup", "s2ts", jsonize_list(s2ts)) +| S2Tfun() => + jsonify("S2Tfun") +| S2Tfun(s2ts, s2t1) => + jsonify("S2Tfun", + ("s2ts", "s2t1"), + ( + jsonize_list(s2ts), + jsonize(s2t1) + ) + ) + (* where val _ = $showtype(s2t1) end *) +| S2Tapp(s2t1, s2ts) => + jsonify("S2Tapp", + ("s2t1", "s2ts"), + ( + jsonize(s2t1), + jsonize_list(s2ts) + ) + ) +| S2Tnone0() => + jsonify("S2Tnone0") +| S2Tnone1(s1tsrc) => + jsonify("S2Tnone1", "s1tsrc", jsonize(s1tsrc)) +) (* end of [jsonize_sort2] *) +end + + +implement +labify_sort2 + (s2t0) = +@("sort2", res) where +val res = +( +case+ s2t0 of +// +| S2Tid(id) => + jsonify("S2Tid", "id", jsonize(id)) +| S2Tint(i0) => + jsonify("S2Tint", "i0", jsonize(i0)) +| S2Tbas(s2tb) => + jsonify("S2Tbas", "s2tb", jsonize(s2tb)) +| S2Ttup() => + jsonify("S2Ttup") +| S2Ttup(s2ts) => + jsonify("S2tup", "s2ts", jsonize_list(s2ts)) +| S2Tfun() => + jsonify("S2Tfun") +| S2Tfun(s2ts, s2t1) => + jsonify("S2fun", + ("s2ts", "s2t1"), + ( + jsonize_list(s2ts), + jsonize(s2t1) + ) + ) +| S2Tapp(s2t1, s2ts) => + jsonify("S2app", + ("s2t1", "s2ts"), + ( + jsonize(s2t1), + jsonize_list(s2ts) + ) + ) +| S2Tnone0() => + jsonify("S2Tnone0") +| S2Tnone1(s1tsrc) => + jsonify("S2Tnone1", "s1tsrc", jsonize(s1tsrc)) +) (* end of [labify_sort2] *) +end + +end // end of [local] + + +implement +jsonize_t2bas + (s2tb) = +node("t2bas", res) where +val res = +( +case+ s2tb of +| T2BASpre(sym) => + jsonify("T2BASpre", "sym", jsonize(sym)) +| T2BASabs(abs) => + jsonify("T2BASabs", "sym", jsonize(abs)) +| T2BASdat(dat) => + jsonify("T2BASabs", "dat", jsonize(dat)) +| T2BASimp(knd, sym) => +(* + jsonify("T2BASimp", ("knd", "sym"), + ( + jsonval_labval1("knd", jsonize(knd)), // jsonize(knd), + jsonize(sym) + ) + ) +*) + jsonval_labval1("T2BASabs", + JSONlablist($list{labjsonval}( + ("knd", jsonize(knd)), + labify(sym) + ) + ) + ) +) +end + +implement +jsonize_t2abs(x0) = +(* jsonval_labval1("t2abs", jsonize(x0.sym())) *) +node("t2abs", jsonize(x0.sym())) + + +implement +jsonize_t2dat(x0) = +(* jsonval_labval1("t2dat", $SYM.jsonize_symbol(x0.sym())) *) +node("t2dat", $SYM.jsonize_symbol(x0.sym())) + + +implement +jsonize_s2cst + (x0) = + (* jsonval_labval1("s2cst", rst) where *) + node("s2cst", rst) where + val lst = $list{labjsonval}( + $SYM.labify_symbol(x0.sym()), $STM.labify_stamp(x0.stamp()) + ) + val rst = JSONlablist(lst) + end +// (* end of [jsonize_s2cst] *) + + +implement +jsonize_s2var + (x0) = +node("s2var", rst) where + val lst = $list{labjsonval}( + $SYM.labify_symbol(x0.sym()), + $STM.labify_stamp(x0.stamp()), + labify_sort2(x0.sort()) + ) + val rst = JSONlablist(lst) + (* val jsrt = jsonize(x0.sort()) *) + end + + + +local + +implement +jsonize_val = jsonize_s2txt +implement +jsonize_val = jsonize_s2exp + +in (* in-of-local *) + +implement +jsonize_s2txt + (s2tx) = +( +case+ s2tx of +| S2TXTsrt(s2t) => + jsonify("S2TXTsrt", "s2t", jsonize(s2t)) +| S2TXTsub(s2v, s2ps) => + jsonify("S2TXTsub", ("s2v", "s2ps"), + (jsonize(s2v), jsonize_list(s2ps)) + ) +// +(* +| S2TXTerr(loc0) => jsonify("S2TXTerr(...)") +*) +// +) (* end of [jsonize_s2txt] *) + +end // end of [local] + + +implement +jsonize_tyrec + (knd) = +node("tyrec", res) where +val res = +( +case+ knd of +// +| TYRECbox0() => + jsonify("TYRECbox0") +| TYRECbox1() => + jsonify("TYRECbox1") +// +| TYRECflt0() => + jsonify("TYRECflt0") +(* +| TYRECflt1(stm) => + jsonize("TYRECflt1", "stm", jsonize(stm)) +*) +| TYRECflt2(nam) => + jsonify("TYRECflt2", "nam", jsonize(nam)) +// +) (* end of [jsonize_tyrec] *) +end + + + +local + +implement +jsonize_val = jsonize_s2exp +implement +jsonize_val = jsonize_s2var +implement +jsonize_val = jsonize_labs2exp + +in (* in-of-local *) + +implement +jsonize_s2exp + (s2e0) = +node("s2exp", res) where +val res = +( +case+ +s2e0.node() of +// +| S2Eint(i0) => + jsonify("S2Eint", "i0", jsonize(i0)) +| S2Echr(c0) => + jsonify("S2Echr", "c0", jsonize(c0)) +// +| S2Estr(s0) => + jsonify("S2Estr", "s0", jsonize(s0)) +// +| S2Ecst(s2c) => + jsonify("S2Ecst", "s2c", jsonize(s2c)) //jsonize(s2c.sort())) // s2c + (* where val _ = $showtype(s2c) end *) +| S2Evar(s2v) => + jsonify("S2Evar", "s2v", jsonize(s2v)) +// +| S2Extv(xtv) => + let + val s2e = s2xtv_get_sexp(xtv) + in + jsonify("S2Extv", "xtv", jsonize(s2e)) + end +// +| S2Eapp + (s2fn, s2es) => + jsonify ( + "S2Eapp", + ( + "s2fn", + "s2es" + ), + ( + jsonize(s2fn), + jsonize_list(s2es) + ) + ) +| S2Elam + (s2vs, body) => + jsonify ("S2Elam", ("s2vs", "body"), + ( + jsonize_list(s2vs), + jsonize(body) + ) + ) +// +| S2Eany(knd) => + jsonify("S2Eany", "knd", jsonize(knd)) +// +| S2Etop(knd, s2e) => + jsonify("S2Eany", ("knd", "s2e"), (jsonize(knd), jsonize(s2e))) +// +| S2Earg(knd, s2e) => + jsonify("S2Earg", ("knd", "s2e"), (jsonize(knd), jsonize(s2e))) +| S2Eatx(bef, aft) => + jsonify("S2Eatx", ("bef", "aft"), (jsonize(bef), jsonize(aft))) +// +| S2Efun + (fc2, npf, arg, res) => + jsonify( + "S2Efun", + ( + "fc2", + "npf", + "arg", + "res" + ), + ( + jsonize(fc2), + jsonval_labval1("npf", jsonize(npf)), //jsonize(npf), + jsonize_list(arg), + jsonize(res) + ) + ) + +// +| S2Ecimp(loc, s2e) => + jsonify( + "S2Ecimp", + ( + "loc", + "s2e" + ), + ( + jsonize(loc), + jsonize(s2e) + ) + ) +| S2Ecprf(loc, s2e) => + jsonify( + "S2Ecprf", + ( + "loc", + "s2e" + ), + ( + jsonize(loc), + jsonize(s2e) + ) + ) + +| S2Ectcd(loc, s2e) => + jsonify( + "S2Ectcd", + ( + "loc", + "s2e" + ), + ( + jsonize(loc), + jsonize(s2e) + ) + ) + +| S2Ecast(loc, s2e, s2t) => + jsonify( + "S2Ecast", + ( + "loc", + "s2e", + "s2t" + ), + ( + jsonize(loc), + jsonize(s2e), + jsonize(s2t) + ) + ) +// +| S2Emet + (s2es, body) => + jsonify("S2Emet", ("s2es", "body"), (jsonize_list(s2es), jsonize(body))) +// +| S2Eexi + (s2vs, s2ps, body) => + jsonify( + "S2Eexi", + ( + "s2vs", + "s2ps", + "body" + ), + ( + jsonize_list(s2vs), + jsonize_list(s2ps), + jsonize(body) + ) + ) +| S2Euni + (s2vs, s2ps, body) => + jsonify( + "S2Euni", + ( + "s2vs", + "s2ps", + "body" + ), + ( + jsonize_list(s2vs), + jsonize_list(s2ps), + jsonize(body) + ) + ) + +// +(* +| S2Elist(s2es) => + jsonify("S2Elist", "s2es", jsonize(s2es)) +*) +// +| S2Etyrec + (knd, npf, ls2es) => + jsonify( + "S2Etyrec", + ( + "knd", + "npf", + "ls2es" + ), + ( + jsonize(knd), + jsonval_labval1("npf", jsonize(npf)), // jsonize(npf), + jsonize_list(ls2es) + ) + ) + + (* where val _ = $showtype(ls2es) end *) +// +| S2Etyext(tnm1, s2es) => + jsonify("S2Etyext", + ( + "tnm1", + "s2es" + ), + ( + jsonize(tnm1), + jsonize_list(s2es) + ) + ) +// +| S2Enone0() => + jsonify("S2Enone") +| S2Enone1(s1esrc) => + jsonify("S2Enone1", "s1esrc", jsonize(s1esrc)) +) (* end of [jsonize_s2exp] *) +end + +end // end of [local] + + +implement +jsonize_labs2exp + (ls2e) = +node("labs2exp", res) where +val res = +( +case+ ls2e of +| SLABELED(l0, s2e) => + jsonify("SLABELED", ("l0", "s2e"), ( + jsonize(l0), + jsonize(s2e)) + ) +) (* end of [jsonize_labs2exp] *) +end + + +local implement jsonize_val = jsonize_s2cst in + +implement +jsonize_s2itm + (x0) = +node("s2itm", res) where +val res = +( +case+ x0 of +// +| S2ITMvar(s2v) => + jsonify("S2ITMvar", "s2v", jsonize(s2v)) +// +| S2ITMcst(s2cs) => + jsonify("S2ITMcst", "s2cs", jsonize_list(s2cs)) +// +| S2ITMfmodenv(fmod) => + jsonify("S2ITMcst", "fmod", jsonize("...")) +) +end + +end + + +implement +jsonize_abstdf2 + (x0) = +node("abstdf2", res) where +val res = +( +case+ x0 of +| ABSTDF2none() => + jsonify("ABSTDF2none") +| ABSTDF2some() => + jsonify("ABSTDF2some") +| ABSTDF2lteq(s2e) => + jsonify("ABSTDF2lteq", "s2e", jsonize(s2e)) +| ABSTDF2eqeq(s2e) => + jsonify("ABSTDF2eqeq", "s2e", jsonize(s2e)) +) +end + +implement +jsonize_effs2expopt + (x0) = +node("effs2expopt", res) where +val res = +( +case+ x0 of +| EFFS2EXPnone() => + jsonify("EFFS2EXPnone") +| EFFS2EXPsome(s2e) => + jsonify("EFFS2EXPsome", "s2e", jsonize(s2e)) +(* +| EFFS2EXPsome(s2f, s2e) => + jsonify("EFFS2EXPsome", ("s2f", "s2e"), (jsonize(s2f), jsonize(s2e))) +*) +) (* end of [jsonize_effs2expopt] *) +end diff --git a/contrib/sparverius/xjsonize/DATS/stamp0.dats b/contrib/sparverius/xjsonize/DATS/stamp0.dats new file mode 100644 index 000000000..5e8159e44 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/stamp0.dats @@ -0,0 +1,29 @@ + + +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +(* +#include "./../HATS/libxatsopt.hats" +*) +#staload "./../SATS/stamp0.sats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/stamp0.sats" +#staload _ = "{$XATS}/DATS/stamp0.dats" + + + + +implement +jsonize_stamp(x0) = +node("stamp", jsonize(tostring_uint(stamp2uint(x0)))) +(* jsonval_labval1("stamp", jsonize(tostring_uint(stamp2uint(x0)))) *) + + +implement +labify_stamp(x0) = ("stamp", jsonize(tostring_uint(stamp2uint(x0)))) diff --git a/contrib/sparverius/xjsonize/DATS/statyp2.dats b/contrib/sparverius/xjsonize/DATS/statyp2.dats new file mode 100644 index 000000000..362896206 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/statyp2.dats @@ -0,0 +1,160 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/staexp0.sats" +#staload "{$XATS}/SATS/staexp1.sats" +#staload "{$XATS}/SATS/staexp2.sats" +#staload "{$XATS}/SATS/statyp2.sats" + +#staload "./../SATS/staexp2.sats" +#staload "./../SATS/statyp2.sats" + +#staload SYM = "./../SATS/symbol.sats" +#staload LOC = "./../SATS/locinfo.sats" +#staload STM = "./../SATS/stamp0.sats" +#staload LAB = "./../SATS/label0.sats" + +overload jsonize with $LOC.jsonize_location +overload jsonize with $SYM.jsonize_symbol +overload jsonize with $STM.jsonize_stamp + +overload jsonize with $LAB.jsonize_label + + +local + +implement +jsonize_val = jsonize_labt2ype +implement +jsonize_val = jsonize_t2ype +implement +jsonize_val = jsonize_s2var + +in (* in-of-local *) +// +implement +jsonize_t2ype + (x0) = +node("t2ype", res) where +val res = +( +case+ +x0.node() of +// +| T2Pbas(sym) => + jsonify("T2Pbas", "sym", jsonize(sym)) +| T2Pcst(s2c) => + jsonify("T2Pcst", "s2c", jsonize(s2c)) +| T2Pvar(s2v) => + jsonify("T2Pvar", "s2v", jsonize(s2v)) +// +| T2Pxtv(xtv) => + let +(* + val t2p = "..." +*) + val t2p = t2xtv_get_type(xtv) + in + case+ + t2p.node() of + | T2Pnone0() => + ( + jsonify("T2Pxtv", "xtv", rst) + where + { + val stm = xtv.stamp((*void*)) + val rst = $STM.jsonize_stamp(stm) + } + ) + | _ (* else *) => + jsonify("T2Pxtv", "xtv", rst) + where + { + val rst = jsonize(t2p) + } + + end +// +| T2Papp(t2p1, t2ps) => + jsonify( + "T2Papp", ("t2p1", "t2ps"), + (jsonize(t2p1), jsonize_list(t2ps)) + ) +| T2Plft(t2p1) => + jsonify("T2Plft", "t2p1", jsonize("...")) + +| T2Plam(s2vs, t2p1) => + jsonify( + "T2Plam", ("s2vs", "t2p1"), + (jsonize_list(s2vs),jsonize(t2p1)) + ) +// +| T2Pfc2(fc2) => + jsonify("T2pfc2", "fc2", jstr("...")) +| T2Pfun(fc2, npf, arg, res) => + jsonify( + "T2Pfun", ("fc2", "npf", "arg", "res"), + ( + jsonize(fc2), + jsonize(npf), + jsonize_list(arg), + jsonize(res) + ) + ) +// +| T2Pexi(s2vs, body) => + jsonify( + "T2Pexi", ("s2vs","body"), + (jsonize_list(s2vs), jsonize(body)) + ) + +| T2Puni(s2vs, body) => + jsonify( + "T2Puni", ("s2vs","body"), + (jsonize_list(s2vs), jsonize(body)) + ) +// +| T2Ptyext(tnm1, t2ps) => + jsonify( + "T2Ptyext", ("tnm1", "t2ps"), + (jsonize(tnm1), jsonize_list(t2ps)) + ) +| T2Ptyrec(knd1, npf2, lt2ps) => + jsonify( + "T2Ptyrec", ("knd1", "npf2", "lt2ps"), + ( + jsonize((*knd1*)"..."), + jsonize(npf2), + jsonize_list(lt2ps) + ) + ) +// +| T2Pnone0() => + jsonify("T2Pnone0") +| T2Pnone1(s2e) => + jsonify("T2Pnone1", "s2e", jsonize(s2e)) + +// +) +end + +end + + +implement +jsonize_labt2ype + (lt2p) = +node("labt2ype", res) where +val res = +( +case+ lt2p of +| TLABELED(l0, t2p) => + jsonify("TLABELED", ("l0", "t2p"), (jsonize(l0), jsonize(t2p))) +) (* end of [jsonize_labt2ype] *) +end diff --git a/contrib/sparverius/xjsonize/DATS/symbol.dats b/contrib/sparverius/xjsonize/DATS/symbol.dats new file mode 100644 index 000000000..9cf543971 --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/symbol.dats @@ -0,0 +1,21 @@ +#include "share/atspre_staload.hats" +#staload UN = "prelude/SATS/unsafe.sats" + +#include "./../HATS/libxatsopt.hats" + +#staload "./../SATS/json.sats" +#staload _ = "./json.dats" + +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/symbol.sats" + +#staload "./../SATS/symbol.sats" + + +implement +jsonize_symbol(x0) = + node("symbol", jsonize(x0.name())) +(* jsonval_labval1("symbol", jsonize(x0.name())) *) + +implement +labify_symbol(x0) = ("symbol", jsonize(x0.name())) diff --git a/contrib/sparverius/xjsonize/DATS/xjsonize.dats b/contrib/sparverius/xjsonize/DATS/xjsonize.dats new file mode 100644 index 000000000..42cd6312b --- /dev/null +++ b/contrib/sparverius/xjsonize/DATS/xjsonize.dats @@ -0,0 +1,130 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) +// +// Author: Hongwei Xi +// Start Time: November, 2019 +// Authoremail: gmhwxiATgmailDOTcom +// +(* ****** ****** *) +// +#include +"share/atspre_staload.hats" +#staload +UN = "prelude/SATS/unsafe.sats" +// +(* ****** ****** *) +// + +#staload "./../SATS/json.sats" +#staload "./../SATS/basics.sats" +#staload "./../SATS/fixity.sats" +#staload "./../SATS/label0.sats" +#staload "./../SATS/locinfo.sats" +#staload "./../SATS/lexing.sats" +#staload "./../SATS/stamp0.sats" +#staload "./../SATS/symbol.sats" +#staload "./../SATS/filpath.sats" +#staload "./../SATS/staexp0.sats" +#staload "./../SATS/dynexp0.sats" +#staload "./../SATS/staexp1.sats" +#staload "./../SATS/dynexp1.sats" +#staload "./../SATS/statyp2.sats" +#staload "./../SATS/staexp2.sats" +#staload "./../SATS/dynexp2.sats" +#staload "./../SATS/dynexp3.sats" +#staload "./../SATS/jsonize0.sats" +(* #staload "./../SATS/trans01.sats" *) + +(* #staload _ = "./json.dats" *) +(* #staload _ = "./basics.dats" *) +(* #staload _ = "./label0.dats" *) +(* #staload _ = "./locinfo.dats" *) +(* #staload _ = "./lexing_token.dats" *) +(* #staload _ = "./filpath.dats" *) +(* #staload _ = "./staexp0.dats" *) +(* #staload _ = "./dynexp0.dats" *) +(* #staload _ = "./stamp0.dats" *) +(* #staload _ = "./symbol.dats" *) +(* #staload _ = "./staexp1.dats" *) +(* #staload _ = "./dynexp1.dats" *) +(* #staload _ = "./statyp2.dats" *) +(* #staload _ = "./staexp2.dats" *) +(* #staload _ = "./dynexp2.dats" *) +(* #staload _ = "./dynexp3.dats" *) + +#ifdef +_LIBXJSONIZE_ +#then +#define +ATS_MAINATSFLAG 1 +#define +ATS_DYNLOADNAME "libxjsonize_dynloadall" +#endif // #ifdef + + + +#dynload "./json.dats" +#dynload "./basics.dats" +#dynload "./stamp0.dats" +#dynload "./symbol.dats" +#dynload "./label0.dats" +#dynload "./locinfo.dats" +#dynload "./lexing_token.dats" +#dynload "./filpath.dats" +#dynload "./staexp0.dats" +#dynload "./dynexp0.dats" +#dynload "./staexp1.dats" +#dynload "./dynexp1.dats" +#dynload "./statyp2.dats" +#dynload "./staexp2.dats" +#dynload "./dynexp2.dats" +#dynload "./dynexp3.dats" +#dynload "./jsonize0.dats" +// +(* ****** ****** *) +// +#ifdef +_LIBXJSONIZE_ +#then +#else +implement +main0(argc, argv) = +( +// +if +(argc >= 2) +then jsonize0_main0(argc, argv) +else prerrln! ("Hello from ATS3(xjsonize)!") +// end of [if] +) (* end of [main] *) +#endif // ifdef(_LIBXJSONIZE_) +// +(* ****** ****** *) + +(* end of [xjsonize.dats] *) diff --git a/contrib/sparverius/xjsonize/HATS/libxatsopt.hats b/contrib/sparverius/xjsonize/HATS/libxatsopt.hats new file mode 100644 index 000000000..7a838e200 --- /dev/null +++ b/contrib/sparverius/xjsonize/HATS/libxatsopt.hats @@ -0,0 +1,120 @@ +(* ****** ****** *) +// +#staload +ERR = +"./../../../../srcgen/xats/SATS/xerrory.sats" +// +(* ****** ****** *) +// +#staload +STM = +"./../../../../srcgen/xats/SATS/stamp0.sats" +#staload +SYM = +"./../../../../srcgen/xats/SATS/symbol.sats" +// +(* ****** ****** *) +// +#staload +FP0 = +"./../../../../srcgen/xats/SATS/filpath.sats" +// + typedef + fpath_t = $FP0.filpath + macdef + dirbase = + $FP0.filpath_dirbase + macdef + fpath_make = $FP0.filpath_make +// +(* ****** ****** *) +// +#staload +GLO = +"./../../../../srcgen/xats/SATS/global.sats" +#staload +FS0 = +"./../../../../srcgen/xats/SATS/filsrch.sats" +// +(* ****** ****** *) +// +(* +#staload +"./../../../../srcgen/xats/SATS/json.sats" +*) +#staload +"./../../../../srcgen/xats/SATS/lexing.sats" +// +#staload +"./../../../../srcgen/xats/SATS/parsing.sats" +// +#staload +"./../../../../srcgen/xats/SATS/synread.sats" +// +#staload +"./../../../../srcgen/xats/SATS/trans01.sats" +#staload +"./../../../../srcgen/xats/SATS/t1xread.sats" +// +#staload +"./../../../../srcgen/xats/SATS/trans12.sats" +#staload +"./../../../../srcgen/xats/SATS/t2xread.sats" +// +#staload +"./../../../../srcgen/xats/SATS/trans23.sats" +#staload +"./../../../../srcgen/xats/SATS/trans33.sats" +// +#staload +"./../../../../srcgen/xats/SATS/t3xread.sats" +// +#staload +"./../../../../srcgen/xats/SATS/trans3t.sats" +// +(* ****** ****** *) +// +#staload S2E = +"./../../../../srcgen/xats/SATS/staexp2.sats" +#staload D2E = +"./../../../../srcgen/xats/SATS/dynexp2.sats" +// +(* ****** ****** *) +// +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/staexp0_print.dats" +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/dynexp0_print.dats" +// +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/staexp1_print.dats" +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/dynexp1_print.dats" +// +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/staexp2_print.dats" +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/statyp2_print.dats" +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/dynexp2_print.dats" +// +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/dynexp3_print.dats" +// +(* ****** ****** *) +// +#staload +_(*TMP*) = +"./../../../../srcgen/xats/DATS/trans12_envmap.dats" +// +(* ****** ****** *) + +(* end of [libxatsopt.hats] *) diff --git a/contrib/sparverius/xjsonize/Makefile b/contrib/sparverius/xjsonize/Makefile new file mode 100644 index 000000000..a3f16e456 --- /dev/null +++ b/contrib/sparverius/xjsonize/Makefile @@ -0,0 +1,159 @@ +###### +# +# For building xjsonize +# +###### + +CC=gcc +SED=sed +CP=cp +RMF=rm -f + +###### + +PATSCC=$(PATSHOME)/bin/patscc +PATSOPT=$(PATSHOME)/bin/patsopt + +###### +# +CFLAGS= +# +# CFLAGS=-g +# CFLAGS=-g -O +# CFLAGS=-g -O2 +# +GCFLAG= +GCFLAG=-DATS_MEMALLOC_LIBC +GCFLAG=-DATS_MEMALLOC_GCBDW +# +LIBGC= +LIBGC=-lgc +# +###### + +SRCSATS := \ +json.sats \ +basics.sats \ +stamp0.sats \ +symbol.sats \ +label0.sats \ +locinfo.sats \ +lexing.sats \ +filpath.sats \ +dynexp0.sats \ +staexp0.sats \ +dynexp1.sats \ +staexp1.sats \ +statyp2.sats \ +staexp2.sats \ +dynexp2.sats \ +dynexp3.sats \ +fixity.sats \ +jsonize0.sats \ + +SRCDATS := \ +json.dats \ +basics.dats \ +stamp0.dats \ +symbol.dats \ +label0.dats \ +locinfo.dats \ +lexing_token.dats \ +filpath.dats \ +staexp0.dats \ +dynexp0.dats \ +staexp1.dats \ +dynexp1.dats \ +statyp2.dats \ +staexp2.dats \ +dynexp2.dats \ +dynexp3.dats \ +jsonize0.dats \ + +###### + +OBJSATS := \ +$(patsubst %.sats, BUILD/%_sats.o, $(SRCSATS)) +OBJDATS := \ +$(patsubst %.dats, BUILD/%_dats.o, $(SRCDATS)) + +###### + +INCLUDE:= +INCLUDE+=-I"." +INCLUDE+=-I"./BUILD/xats" +LIBRARY:=-L./../../../lib/ -lxatsopt + +###### +# +all: \ +xjsonize +xjsonize: \ +DATS/xjsonize.dats \ +$(OBJSATS) $(OBJDATS) ; \ +$(PATSCC) -cleanaft -o xjsonize \ +$(INCLUDE) $(CFLAGS) $(GCFLAG) $^ $(LIBGC) $(LIBRARY) +# +###### + +libxjsonize: \ +$(OBJSATS) $(OBJDATS) \ +BUILD/libxjsonize_dats.o ; \ +($(AR) -r $@.a $^ && $(CP) -f $@.a ./../../../lib) +BUILD/libxjsonize_dats.o: \ +DATS/xjsonize.dats; $(PATSCC) -DATS _LIBXJSONIZE_ -o $@ -c $< + +###### + +BUILD/%_sats.c: \ +./SATS/%.sats ; $(PATSOPT) -o $@ --static $< +BUILD/%_dats.c: \ +./DATS/%.dats ; $(PATSOPT) -o $@ --dynamic $< + +###### + +BUILD/%_sats.o: \ +BUILD/%_sats.c; \ +$(PATSCC) $(INCLUDE) $(CFLAGS) -o $@ -c $< +BUILD/%_dats.o: \ +BUILD/%_dats.c; \ +$(PATSCC) $(INCLUDE) $(CFLAGS) $(GCFLAG) -o $@ -c $< + +###### +# +# HX-2018-10-07: +# '--output-a .depend' means +# appending instead of overwriting +# +SATS_SRCSATS := \ +$(patsubst %.sats, SATS/%.sats, $(SRCSATS)) +DATS_SRCDATS := \ +$(patsubst %.dats, DATS/%.dats, $(SRCDATS)) +# +depend:: ; $(RMF) .depend +# +depend:: ; \ +$(PATSOPT) --output-a .depend --depgen -s $(SATS_SRCSATS) +depend:: ; \ +$(PATSOPT) --output-a .depend --depgen -d $(DATS_SRCDATS) +depend:: ; \ +$(PATSOPT) --output-a .depend --depgen -d DATS/xjsonize.dats +# +depend:: ; \ +$(SED) -i -e 's/^SATS/BUILD/' -e 's/^DATS/BUILD/' .depend +# +-include .depend +# +###### + +clean:: ; $(RMF) BUILD/*_?ats.c +clean:: ; $(RMF) BUILD/*_?ats.o +clean:: ; $(RMF) xjsonize_dats.o +clean:: ; $(RMF) xjsonize_dats.c + +cleanall:: clean +cleanall:: ; $(RMF) xjsonize + +###### + +###### end of [Makefile] ###### diff --git a/contrib/sparverius/xjsonize/SATS/basics.sats b/contrib/sparverius/xjsonize/SATS/basics.sats new file mode 100644 index 000000000..cfe45d628 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/basics.sats @@ -0,0 +1,24 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload BAS = "{$XATS}/SATS/basics.sats" + +#staload "./json.sats" + +fun +jsonize_dctkind : jsonize_type($BAS.dctkind) +overload jsonize with jsonize_dctkind + +fun +jsonize_valkind : jsonize_type($BAS.valkind) +overload jsonize with jsonize_valkind + +fun +jsonize_funkind : jsonize_type($BAS.funkind) +overload jsonize with jsonize_funkind + +fun +jsonize_impkind : jsonize_type($BAS.impkind) +overload jsonize with jsonize_impkind + +fun +jsonize_funclo2: jsonize_type($BAS.funclo2) +overload jsonize with jsonize_funclo2 diff --git a/contrib/sparverius/xjsonize/SATS/dynexp0.sats b/contrib/sparverius/xjsonize/SATS/dynexp0.sats new file mode 100644 index 000000000..a3a568d96 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/dynexp0.sats @@ -0,0 +1,143 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/dynexp0.sats" + +#staload "./json.sats" + +fun{a:type} +jsonize_dl0abeled : jsonize_type(dl0abeled(a)) + +fun +jsonize_q0arg : jsonize_type(q0arg) +overload jsonize with jsonize_q0arg + +fun +jsonize_sq0arg : jsonize_type(sq0arg) +overload jsonize with jsonize_sq0arg + +fun +jsonize_tq0arg : jsonize_type(tq0arg) +overload jsonize with jsonize_tq0arg + +fun +jsonize_ti0arg : jsonize_type(ti0arg) +overload jsonize with jsonize_ti0arg + +fun +jsonize_a0typ : jsonize_type(a0typ) +overload jsonize with jsonize_a0typ + +fun +jsonize_d0arg : jsonize_type(d0arg) +overload jsonize with jsonize_d0arg + +fun +jsonize_f0arg : jsonize_type(f0arg) +overload jsonize with jsonize_f0arg + +fun +jsonize_d0pat : jsonize_type(d0pat) +overload jsonize with jsonize_d0pat + +fun +jsonize_d0pat_RPAREN : jsonize_type(d0pat_RPAREN) +overload jsonize with jsonize_d0pat_RPAREN + +fun +jsonize_labd0pat_RBRACE : jsonize_type(labd0pat_RBRACE) +overload jsonize with jsonize_labd0pat_RBRACE + +fun +jsonize_d0exp : jsonize_type(d0exp) +overload jsonize with jsonize_d0exp + +fun +jsonize_d0exp_RPAREN : jsonize_type(d0exp_RPAREN) +overload jsonize with jsonize_d0exp_RPAREN + +fun +jsonize_labd0exp_RBRACE : jsonize_type(labd0exp_RBRACE) +overload jsonize with jsonize_labd0exp_RBRACE + +fun +jsonize_d0exp_THEN : jsonize_type(d0exp_THEN) +overload jsonize with jsonize_d0exp_THEN + +fun +jsonize_d0exp_ELSE : jsonize_type(d0exp_ELSE) +overload jsonize with jsonize_d0exp_ELSE + +fun +jsonize_endwhere : jsonize_type(endwhere) +overload jsonize with jsonize_endwhere + +fun +jsonize_d0eclseq_WHERE : jsonize_type(d0eclseq_WHERE) +overload jsonize with jsonize_d0eclseq_WHERE + +fun +jsonize_f0unarrow : jsonize_type(f0unarrow) +overload jsonize with jsonize_f0unarrow + +fun +jsonize_d0gua : jsonize_type(d0gua) +overload jsonize with jsonize_d0gua + +fun +jsonize_decmodopt : jsonize_type(decmodopt) +overload jsonize with jsonize_decmodopt + +fun +jsonize_teqd0expopt : jsonize_type(teqd0expopt) +overload jsonize with jsonize_teqd0expopt + +fun +jsonize_wths0expopt : jsonize_type(wths0expopt) +overload jsonize with jsonize_wths0expopt + +fun +jsonize_v0aldecl : jsonize_type(v0aldecl) +overload jsonize with jsonize_v0aldecl + +fun +jsonize_v0ardecl : jsonize_type(v0ardecl) +overload jsonize with jsonize_v0ardecl + +fun +jsonize_f0undecl : jsonize_type(f0undecl) +overload jsonize with jsonize_f0undecl + +fun +jsonize_d0cstdecl : jsonize_type(d0cstdecl) +overload jsonize with jsonize_d0cstdecl + +fun +jsonize_d0ecl : jsonize_type(d0ecl) +overload jsonize with jsonize_d0ecl + +fun +jsonize_precopt : jsonize_type(precopt) +overload jsonize with jsonize_precopt + +fun +jsonize_precmod : jsonize_type(precmod) +overload jsonize with jsonize_precmod + +fun +jsonize_signint : jsonize_type(signint) +overload jsonize with jsonize_signint + +fun +jsonize_abstdf0 : jsonize_type(abstdf0) +overload jsonize with jsonize_abstdf0 + +fun +jsonize_g0expdef : jsonize_type(g0expdef) +overload jsonize with jsonize_g0expdef + +fun +jsonize_d0macdef : jsonize_type(d0macdef) +overload jsonize with jsonize_d0macdef + +fun +jsonize_wd0eclseq : jsonize_type(wd0eclseq) +overload jsonize with jsonize_wd0eclseq diff --git a/contrib/sparverius/xjsonize/SATS/dynexp1.sats b/contrib/sparverius/xjsonize/SATS/dynexp1.sats new file mode 100644 index 000000000..8325908e1 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/dynexp1.sats @@ -0,0 +1,92 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/dynexp1.sats" + +#staload "./json.sats" + +fun +jsonize_q1arg : jsonize_type(q1arg) +overload jsonize with jsonize_q1arg + +fun +jsonize_sq1arg : jsonize_type(sq1arg) +overload jsonize with jsonize_sq1arg + +fun +jsonize_tq1arg : jsonize_type(tq1arg) +overload jsonize with jsonize_tq1arg + +fun +jsonize_ti1arg : jsonize_type(ti1arg) +overload jsonize with jsonize_ti1arg + +fun +jsonize_a1typ : jsonize_type(a1typ) +overload jsonize with jsonize_a1typ + +fun +jsonize_d1arg : jsonize_type(d1arg) +overload jsonize with jsonize_d1arg + +fun +jsonize_f1arg : jsonize_type(f1arg) +overload jsonize with jsonize_f1arg + +fun +jsonize_d1pat : jsonize_type(d1pat) +overload jsonize with jsonize_d1pat + +fun +jsonize_d1gua : jsonize_type(d1gua) +overload jsonize with jsonize_d1gua + +fun +jsonize_d1clau : jsonize_type(d1clau) +overload jsonize with jsonize_d1clau + +fun +jsonize_d1gpat : jsonize_type(d1gpat) +overload jsonize with jsonize_d1gpat + +fun +jsonize_d1exp : jsonize_type(d1exp) +overload jsonize with jsonize_d1exp + +fun +jsonize_f1unarrow : jsonize_type(f1unarrow) +overload jsonize with jsonize_f1unarrow + +fun +jsonize_teqd1expopt : jsonize_type(teqd1expopt) +overload jsonize with jsonize_teqd1expopt + +fun +jsonize_wths1expopt : jsonize_type(wths1expopt) +overload jsonize with jsonize_wths1expopt + +fun +jsonize_v1aldecl : jsonize_type(v1aldecl) +overload jsonize with jsonize_v1aldecl + +fun +jsonize_v1ardecl : jsonize_type(v1ardecl) +overload jsonize with jsonize_v1ardecl + +fun +jsonize_f1undecl : jsonize_type(f1undecl) +overload jsonize with jsonize_f1undecl + +fun +jsonize_d1cstdecl : jsonize_type(d1cstdecl) +overload jsonize with jsonize_d1cstdecl + +fun +jsonize_d1ecl : jsonize_type(d1ecl) +overload jsonize with jsonize_d1ecl + +fun +jsonize_abstdf1 : jsonize_type(abstdf1) +overload jsonize with jsonize_abstdf1 + +fun +jsonize_wd1eclseq : jsonize_type(wd1eclseq) +overload jsonize with jsonize_wd1eclseq diff --git a/contrib/sparverius/xjsonize/SATS/dynexp2.sats b/contrib/sparverius/xjsonize/SATS/dynexp2.sats new file mode 100644 index 000000000..d29575d93 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/dynexp2.sats @@ -0,0 +1,85 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/dynexp2.sats" + +#staload "./json.sats" + + +fun +jsonize_sq2arg : jsonize_type(sq2arg) +overload jsonize with jsonize_sq2arg + +fun +jsonize_tq2arg : jsonize_type(tq2arg) +overload jsonize with jsonize_tq2arg + +fun +jsonize_d2con : jsonize_type(d2con) +overload jsonize with jsonize_d2con + +fun +jsonize_d2cst : jsonize_type(d2cst) +overload jsonize with jsonize_d2cst + +fun +jsonize_d2var : jsonize_type(d2var) +overload jsonize with jsonize_d2var + +fun +jsonize_d2itm : jsonize_type(d2itm) +overload jsonize with jsonize_d2itm + +fun +jsonize_d2pitm : jsonize_type(d2pitm) +overload jsonize with jsonize_d2pitm + +fun +jsonize_d2pat : jsonize_type(d2pat) +overload jsonize with jsonize_d2pat + +fun +jsonize_f2arg : jsonize_type(f2arg) +overload jsonize with jsonize_f2arg + +fun +jsonize_ti2arg : jsonize_type(ti2arg) +overload jsonize with jsonize_ti2arg + +fun +jsonize_d2gua : jsonize_type(d2gua) +overload jsonize with jsonize_d2gua + +fun +jsonize_d2clau : jsonize_type(d2clau) +overload jsonize with jsonize_d2clau + +fun +jsonize_d2gpat : jsonize_type(d2gpat) +overload jsonize with jsonize_d2gpat + +fun +jsonize_d2exp : jsonize_type(d2exp) +overload jsonize with jsonize_d2exp + +fun +jsonize_v2aldecl : jsonize_type(v2aldecl) +overload jsonize with jsonize_v2aldecl + +fun +jsonize_v2ardecl : jsonize_type(v2ardecl) +overload jsonize with jsonize_v2ardecl + +fun +jsonize_f2undecl : jsonize_type(f2undecl) +overload jsonize with jsonize_f2undecl + +fun +jsonize_d2ecl : jsonize_type(d2ecl) +overload jsonize with jsonize_d2ecl + +fun +jsonize_impls2cst : jsonize_type(impls2cst) +overload jsonize with jsonize_impls2cst + +fun +jsonize_impld2cst : jsonize_type(impld2cst) +overload jsonize with jsonize_impld2cst diff --git a/contrib/sparverius/xjsonize/SATS/dynexp3.sats b/contrib/sparverius/xjsonize/SATS/dynexp3.sats new file mode 100644 index 000000000..b10446747 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/dynexp3.sats @@ -0,0 +1,53 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/dynexp3.sats" + +#staload "./json.sats" + +fun +jsonize_ti3arg : jsonize_type(ti3arg) +overload jsonize with jsonize_ti3arg + +fun +jsonize_d3pat : jsonize_type(d3pat) +overload jsonize with jsonize_d3pat + + +fun +jsonize_f3arg : jsonize_type(f3arg) +overload jsonize with jsonize_f3arg + +fun +jsonize_d3gua : jsonize_type(d3gua) +overload jsonize with jsonize_d3gua + +fun +jsonize_d3clau : jsonize_type(d3clau) +overload jsonize with jsonize_d3clau + +fun +jsonize_d3gpat : jsonize_type(d3gpat) +overload jsonize with jsonize_d3gpat + +fun +jsonize_d3exp : jsonize_type(d3exp) +overload jsonize with jsonize_d3exp + +fun +jsonize_t2pcast : jsonize_type(t2pcast) +overload jsonize with jsonize_t2pcast + +fun +jsonize_v3aldecl : jsonize_type(v3aldecl) +overload jsonize with jsonize_v3aldecl + +fun +jsonize_v3ardecl : jsonize_type(v3ardecl) +overload jsonize with jsonize_v3ardecl + +fun +jsonize_f3undecl : jsonize_type(f3undecl) +overload jsonize with jsonize_f3undecl + +fun +jsonize_d3ecl : jsonize_type(d3ecl) +overload jsonize with jsonize_d3ecl diff --git a/contrib/sparverius/xjsonize/SATS/filpath.sats b/contrib/sparverius/xjsonize/SATS/filpath.sats new file mode 100644 index 000000000..15f2124e5 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/filpath.sats @@ -0,0 +1,13 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/filpath.sats" + +#staload "./json.sats" + +(* +implement +fprint_val = fprint_filpath_full2 +*) + +fun +jsonize_filpath : jsonize_type(filpath) +overload jsonize with jsonize_filpath diff --git a/contrib/sparverius/xjsonize/SATS/fixity.sats b/contrib/sparverius/xjsonize/SATS/fixity.sats new file mode 100644 index 000000000..526c5dc72 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/fixity.sats @@ -0,0 +1,16 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/fixity.sats" + +#staload "./json.sats" + +fun +jsonize_assoc: jsonize_type(assoc) +overload jsonize with jsonize_assoc + +fun +jsonize_prcdv: jsonize_type(prcdv) +overload jsonize with jsonize_prcdv + +fun +jsonize_fixty: jsonize_type(fixty) +overload jsonize with jsonize_fixty diff --git a/contrib/sparverius/xjsonize/SATS/json.sats b/contrib/sparverius/xjsonize/SATS/json.sats new file mode 100644 index 000000000..1626ab51d --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/json.sats @@ -0,0 +1,338 @@ +datatype +jsonval = +// + | JSONnul of () + | JSONint of (int) + | JSONbool of (bool) + | JSONfloat of (double) + | JSONstring of (string) +// + | JSONlist of (jsonvalist) + | JSONlablist of labjsonvalist + | JSONoption of (jsonvalopt) +// + (* | JSONintinf of (intinf) *) +// +// end of [jsonval] +where +jsonvalist = List (jsonval) +and +labjsonval = @(string, jsonval) +and +labjsonvalist = List0 (labjsonval) +and +jsonvalopt = Option (jsonval) + +typedef jsonize_type(a:t@ype) = a -> jsonval +typedef labify_type(a:t@ype) = a -> (string, jsonval) + +(* ****** ****** *) +// +fun jsonval_int (x: int): jsonval +(* fun jsonval_intinf (x: intinf): jsonval *) +// +fun jsonval_bool (x: bool): jsonval +fun jsonval_double (x: double): jsonval +fun jsonval_string (x: string): jsonval +// +(* ****** ****** *) +// +fun jsonval_nil (): jsonval +fun jsonval_sing (x: jsonval): jsonval +fun jsonval_pair (x1: jsonval, x2: jsonval): jsonval +// +(* ****** ****** *) +// +fun jsonval_labval1 + (l1: string, x1: jsonval): jsonval +// +fun jsonval_labval2 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +) : jsonval // end of [jsonval_labval2] +// +fun +jsonval_labval3 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +) : jsonval // end of [jsonval_labval3] +// +fun +jsonval_labval4 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +, l4: string, x4: jsonval +) : jsonval // end of [jsonval_labval4] +// +fun +jsonval_labval5 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +, l4: string, x4: jsonval +, l5: string, x5: jsonval +) : jsonval // end of [jsonval_labval5] +// +fun +jsonval_labval6 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +, l4: string, x4: jsonval +, l5: string, x5: jsonval +, l6: string, x6: jsonval +) : jsonval // end of [jsonval_labval6] +// +fun +jsonval_labval7 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +, l4: string, x4: jsonval +, l5: string, x5: jsonval +, l6: string, x6: jsonval +, l7: string, x7: jsonval +) : jsonval // end of [jsonval_labval7] +// +fun +jsonval_labval8 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +, l4: string, x4: jsonval +, l5: string, x5: jsonval +, l6: string, x6: jsonval +, l7: string, x7: jsonval +, l8: string, x8: jsonval +) : jsonval // end of [jsonval_labval8] +// +fun +jsonval_labval9 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +, l4: string, x4: jsonval +, l5: string, x5: jsonval +, l6: string, x6: jsonval +, l7: string, x7: jsonval +, l8: string, x8: jsonval +, l9: string, x9: jsonval +) : jsonval // end of [jsonval_labval8] +// +fun +jsonval_labval10 +( + l1: string, x1: jsonval +, l2: string, x2: jsonval +, l3: string, x3: jsonval +, l4: string, x4: jsonval +, l5: string, x5: jsonval +, l6: string, x6: jsonval +, l7: string, x7: jsonval +, l8: string, x8: jsonval +, l9: string, x9: jsonval +, l10: string, x10: jsonval +) : jsonval // end of [jsonval_labval8] +// +(* ****** ****** *) +// +fun +jsonval_conarglst + (con: string, arglst: jsonvalist): jsonval +// +(* ****** ****** *) +// +fun +jsonval_conarg0 (con: string): jsonval +fun +jsonval_conarg1 (con: string, arg: jsonval): jsonval +fun +jsonval_conarg2 + (con: string, arg1: jsonval, arg2: jsonval): jsonval +// +fun +jsonval_conarg3 +( + con: string, arg1: jsonval, arg2: jsonval, arg3: jsonval +) : jsonval // end of [jsonval_conarg3] +fun +jsonval_conarg4 +( + con: string +, arg1: jsonval, arg2: jsonval, arg3: jsonval, arg4: jsonval +) : jsonval // end of [jsonval_conarg4] +// +(* ****** ****** *) +// +fun jsonval_none (): jsonval +fun jsonval_some (x: jsonval): jsonval +// +(* ****** ****** *) +// +fun fprint_jsonval + (out: FILEref, x: jsonval): void +fun fprint_jsonvalist + (out: FILEref, xs: jsonvalist): void +fun fprint_labjsonvalist + (out: FILEref, lxs: labjsonvalist): void +// +overload fprint with fprint_jsonval +overload fprint with fprint_jsonvalist +overload fprint with fprint_labjsonvalist + + +fun print_jsonval(x: jsonval): void +fun prerr_jsonval(x: jsonval): void + +overload print with print_jsonval +overload prerr with prerr_jsonval + +// +(* +fun print_jsonval(x: jsonval): void +fun print_jsonvalist(xs: jsonvalist): void +fun print_labjsonvalist(lxs: labjsonvalist): void +*) +// +(* ****** ****** *) + +typedef +jsonize_ftype (a:t@ype) = (a) -> jsonval +typedef +labify_ftype (a:t@ype) = (a) -> @() + +(* ****** ****** *) + +fun jsonize_ignored{a:type} (x: a): jsonval + +(* ****** ****** *) +// +fun{a:t@ype} +jsonize_list_fun + (* (xs: List0 (a), f: jsonize_ftype (a)): jsonval *) + (xs: List (a), f: jsonize_ftype (a)): jsonval +// end of [jsonize_list_fun] +// +fun{a:t@ype} +jsonize_option_fun + (xs: Option (a), f: jsonize_ftype (a)): jsonval + +(* ****** ****** *) + +symintr jsonize +symintr labify +(* symintr jsonize_list *) + +fun{a:t@ype} jsonize_val: (a) -> jsonval + +fun{a:t@ype} jsonize_list: (List(a)) -> jsonval +fun{a:t@ype} jsonize_option: (Option(a)) -> jsonval +fun{a:t@ype} jsonize_option_vt: (Option_vt(a)) -> jsonval + +fun jsonize_int(x:int): jsonval + +fun jsonize_char(x:char): jsonval + +fun jsonize_string(x:string): jsonval + +fun jsonize_bool(x:bool): jsonval + +fun jsonize_double(x:double): jsonval + +(* fun jsonize_float(x:float): jsonval = JSONstring(tostring_val(x)) *) + +overload jsonize with jsonize_int + +overload jsonize with jsonize_char + +overload jsonize with jsonize_string + +overload jsonize with jsonize_bool + +overload jsonize with jsonize_double + +(* overload jsonize with jsonize_float *) + +fun lab(x:string, rst:jsonval): jsonval + +fun jnul(): jsonval + +fun jint(x:int): jsonval + +fun jbool(x:bool): jsonval + +fun jfloat(x:double): jsonval + +fun jstr(x:string): jsonval + +fun listj(x: jsonval): jsonval + +fun listj2(x: jsonval, y: jsonval): jsonval + + +fun labval2(x: jsonval, y: jsonval): jsonval +fun node(x: string, y: jsonval): jsonval +fun node2(x: string, y: jsonval, z: jsonval): jsonval + + +fun fprintf {ts:types} ( + out: FILEref, + fmt: string, + args: ts +): void = "mac#fprintf" + + +typedef str_arg2 = (string, string) +typedef str_arg3 = (string, string, string) +typedef str_arg4 = (string, string, string, string) +typedef str_arg5 = (string, string, string, string, string) +typedef str_arg6 = (string, string, string, string, string, string) +typedef str_arg7 = (string, string, string, string, string, string, string) +typedef str_arg8 = (string, string, string, string, string, string, string, string) +typedef str_arg9 = (string, string, string, string, string, string, string, string, string) +typedef str_arg10 = (string, string, string, string, string, string, string, string, string, string) + +typedef json_arg2 = (jsonval, jsonval) +typedef json_arg3 = (jsonval, jsonval, jsonval) +typedef json_arg4 = (jsonval, jsonval, jsonval, jsonval) +typedef json_arg5 = (jsonval, jsonval, jsonval, jsonval, jsonval) +typedef json_arg6 = (jsonval, jsonval, jsonval, jsonval, jsonval, jsonval) +typedef json_arg7 = (jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval) +typedef json_arg8 = (jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval) +typedef json_arg9 = (jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval) +typedef json_arg10 = (jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval, jsonval) + +fun jsonify0 (guard_name: string): jsonval +fun jsonify1 (guard_name: string, arg_name: string, arg_json: jsonval): jsonval +fun jsonify2 (guard_name: string, arg_names: str_arg2, arg_json: json_arg2): jsonval +fun jsonify3 (guard_name: string, arg_names: str_arg3, arg_json: json_arg3): jsonval +fun jsonify4 (guard_name: string, arg_names: str_arg4, arg_json: json_arg4): jsonval +fun jsonify5 (guard_name: string, arg_names: str_arg5, arg_json: json_arg5): jsonval +fun jsonify6 (guard_name: string, arg_names: str_arg6, arg_json: json_arg6): jsonval +fun jsonify7 (guard_name: string, arg_names: str_arg7, arg_json: json_arg7): jsonval +fun jsonify8 (guard_name: string, arg_names: str_arg8, arg_json: json_arg8): jsonval +fun jsonify9 (guard_name: string, arg_names: str_arg9, arg_json: json_arg9): jsonval +fun jsonify10 (guard_name: string, arg_names: str_arg10, arg_json: json_arg10): jsonval + +overload jsonify with jsonify0 +overload jsonify with jsonify1 +overload jsonify with jsonify2 +overload jsonify with jsonify3 +overload jsonify with jsonify4 +overload jsonify with jsonify5 +overload jsonify with jsonify6 +overload jsonify with jsonify7 +overload jsonify with jsonify8 +overload jsonify with jsonify9 +overload jsonify with jsonify10 +(* fun jsonify(guard_name: string, List(@(string, json))): jsonval *) diff --git a/contrib/sparverius/xjsonize/SATS/jsonize0.sats b/contrib/sparverius/xjsonize/SATS/jsonize0.sats new file mode 100644 index 000000000..8d71df0eb --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/jsonize0.sats @@ -0,0 +1,46 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Xanadu - Unleashing the Potential of Types! +** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS is distributed in the hope that it will be useful, but WITHOUT ANY +** WARRANTY; without even the implied warranty of MERCHANTABILITY or +** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +** for more details. +** +** You should have received a copy of the GNU General Public License +** along with ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) +// +// Author: Hongwei Xi +// Start Time: November, 2019 +// Authoremail: gmhwxiATgmailDOTcom +// +(* ****** ****** *) + +#define XATS_targetloc "./../../../../srcgen/xats" + +(* ****** ****** *) + +fun +jsonize0_main0 +{n:int | n >= 1}(int(n), !argv(n)): void +// +(* ****** ****** *) + +(* end of [xint_interp0.sats] *) diff --git a/contrib/sparverius/xjsonize/SATS/label0.sats b/contrib/sparverius/xjsonize/SATS/label0.sats new file mode 100644 index 000000000..ba5ed14c2 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/label0.sats @@ -0,0 +1,8 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/label0.sats" + +#staload "./json.sats" + +fun +jsonize_label : jsonize_type(label) +overload jsonize with jsonize_label diff --git a/contrib/sparverius/xjsonize/SATS/lexing.sats b/contrib/sparverius/xjsonize/SATS/lexing.sats new file mode 100644 index 000000000..895930e28 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/lexing.sats @@ -0,0 +1,12 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/lexing.sats" + +#staload "./json.sats" + +fun +jsonize_tnode : jsonize_type(tnode) +overload jsonize with jsonize_tnode + +fun +jsonize_token : jsonize_type(token) +overload jsonize with jsonize_token diff --git a/contrib/sparverius/xjsonize/SATS/locinfo.sats b/contrib/sparverius/xjsonize/SATS/locinfo.sats new file mode 100644 index 000000000..7133b083a --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/locinfo.sats @@ -0,0 +1,22 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/locinfo.sats" + +#staload "./json.sats" + + + +fun +jsonize_location : jsonize_type(location) +overload jsonize with jsonize_location + +fun +jsonize_loc_t : jsonize_type(loc_t) +overload jsonize with jsonize_loc_t of 1 + +fun +labify_loc_t : labify_type(loc_t) +overload labify with labify_loc_t + +fun +jsonize_locrange : jsonize_type(location) +(* overload jsonize with jsonize_locrange *) diff --git a/contrib/sparverius/xjsonize/SATS/staexp0.sats b/contrib/sparverius/xjsonize/SATS/staexp0.sats new file mode 100644 index 000000000..470cbaba7 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/staexp0.sats @@ -0,0 +1,88 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/staexp0.sats" + +#staload "./json.sats" + +fun jsonize_t0int : jsonize_type(t0int) +overload jsonize with jsonize_t0int + +fun jsonize_t0chr : jsonize_type(t0chr) +overload jsonize with jsonize_t0chr + +fun jsonize_t0flt : jsonize_type(t0flt) +overload jsonize with jsonize_t0flt + +fun jsonize_t0str : jsonize_type(t0str) +overload jsonize with jsonize_t0str + +fun jsonize_i0dnt : jsonize_type(i0dnt) +overload jsonize with jsonize_i0dnt + +fun jsonize_l0abl : jsonize_type(l0abl) +overload jsonize with jsonize_l0abl + +fun jsonize_s0ymb : jsonize_type(s0ymb) +overload jsonize with jsonize_s0ymb + +fun{a:type} jsonize_sl0abled : jsonize_type(sl0abled(a)) +overload jsonize with jsonize_sl0abled + +fun jsonize_sq0eid : jsonize_type(sq0eid) +overload jsonize with jsonize_sq0eid + +fun jsonize_dq0eid : jsonize_type(dq0eid) +overload jsonize with jsonize_dq0eid + +fun jsonize_g0exp : jsonize_type(g0exp) +overload jsonize with jsonize_g0exp + +fun jsonize_g0marg : jsonize_type(g0marg) +overload jsonize with jsonize_g0marg + +fun jsonize_sort0 : jsonize_type(sort0) +overload jsonize with jsonize_sort0 + +fun jsonize_s0rtcon : jsonize_type(s0rtcon) +overload jsonize with jsonize_s0rtcon + +fun jsonize_d0tsort : jsonize_type(d0tsort) +overload jsonize with jsonize_d0tsort + +fun jsonize_s0rtdef : jsonize_type(s0rtdef) +overload jsonize with jsonize_s0rtdef + +fun jsonize_s0arg : jsonize_type(s0arg) +overload jsonize with jsonize_s0arg + +fun jsonize_s0marg : jsonize_type(s0marg) +overload jsonize with jsonize_s0marg + +fun jsonize_t0arg : jsonize_type(t0arg) +overload jsonize with jsonize_t0arg + +fun jsonize_t0marg : jsonize_type(t0marg) +overload jsonize with jsonize_t0marg + +fun jsonize_s0qua : jsonize_type(s0qua) +overload jsonize with jsonize_s0qua + +fun jsonize_s0uni : jsonize_type(s0uni) +overload jsonize with jsonize_s0uni + +fun jsonize_s0exp : jsonize_type(s0exp) +overload jsonize with jsonize_s0exp + +fun jsonize_s0exp_RPAREN : jsonize_type(s0exp_RPAREN) +overload jsonize with jsonize_s0exp_RPAREN + +fun jsonize_labs0exp_RBRACE : jsonize_type(labs0exp_RBRACE) +overload jsonize with jsonize_labs0exp_RBRACE + +fun jsonize_effs0expopt : jsonize_type(effs0expopt) +overload jsonize with jsonize_effs0expopt + +fun jsonize_d0atcon : jsonize_type(d0atcon) +overload jsonize with jsonize_d0atcon + +fun jsonize_d0atype : jsonize_type(d0atype) +overload jsonize with jsonize_d0atype diff --git a/contrib/sparverius/xjsonize/SATS/staexp1.sats b/contrib/sparverius/xjsonize/SATS/staexp1.sats new file mode 100644 index 000000000..e8f1b3e2b --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/staexp1.sats @@ -0,0 +1,70 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/staexp1.sats" + +#staload "./json.sats" + + +fun +jsonize_g1exp : jsonize_type(g1exp) +overload jsonize with jsonize_g1exp + +fun +jsonize_g1marg : jsonize_type(g1marg) +overload jsonize with jsonize_g1marg + +fun +jsonize_sort1 : jsonize_type(sort1) +overload jsonize with jsonize_sort1 + +fun +jsonize_s1rtcon : jsonize_type(s1rtcon) +overload jsonize with jsonize_s1rtcon + +fun +jsonize_d1tsort : jsonize_type(d1tsort) +overload jsonize with jsonize_d1tsort + +fun +jsonize_s1arg : jsonize_type(s1arg) +overload jsonize with jsonize_s1arg + +fun +jsonize_s1rtdef : jsonize_type(s1rtdef) +overload jsonize with jsonize_s1rtdef + +fun +jsonize_s1marg : jsonize_type(s1marg) +overload jsonize with jsonize_s1marg + +fun +jsonize_t1arg : jsonize_type(t1arg) +overload jsonize with jsonize_t1arg + +fun +jsonize_t1marg : jsonize_type(t1marg) +overload jsonize with jsonize_t1marg + +fun +jsonize_s1qua : jsonize_type(s1qua) +overload jsonize with jsonize_s1qua + +fun +jsonize_s1uni : jsonize_type(s1uni) +overload jsonize with jsonize_s1uni + +fun +jsonize_s1exp : jsonize_type(s1exp) +overload jsonize with jsonize_s1exp + + +fun +jsonize_effs1expopt : jsonize_type(effs1expopt) +overload jsonize with jsonize_effs1expopt + +fun +jsonize_d1atcon : jsonize_type(d1atcon) +overload jsonize with jsonize_d1atcon + +fun +jsonize_d1atype : jsonize_type(d1atype) +overload jsonize with jsonize_d1atype diff --git a/contrib/sparverius/xjsonize/SATS/staexp2.sats b/contrib/sparverius/xjsonize/SATS/staexp2.sats new file mode 100644 index 000000000..a7e650650 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/staexp2.sats @@ -0,0 +1,63 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/staexp2.sats" + +#staload "./json.sats" + +fun +jsonize_sort2: jsonize_type(sort2) +overload jsonize with jsonize_sort2 +fun +labify_sort2: labify_type(sort2) +overload labify with labify_sort2 + +fun +jsonize_t2bas: jsonize_type(t2bas) +overload jsonize with jsonize_t2bas + +fun +jsonize_t2abs: jsonize_type(t2abs) +overload jsonize with jsonize_t2abs + +fun +jsonize_t2dat: jsonize_type(t2dat) +overload jsonize with jsonize_t2dat + +fun +jsonize_s2cst: jsonize_type(s2cst) +overload jsonize with jsonize_s2cst + +fun +jsonize_s2var: jsonize_type(s2var) +overload jsonize with jsonize_s2var + +fun +jsonize_tyrec: jsonize_type(tyrec) +overload jsonize with jsonize_tyrec + +fun +jsonize_s2txt: jsonize_type(s2txt) +overload jsonize with jsonize_s2txt + +fun +jsonize_s2exp: jsonize_type(s2exp) +overload jsonize with jsonize_s2exp + +fun +jsonize_s2hnf: jsonize_type(s2hnf) +overload jsonize with jsonize_s2hnf + +fun +jsonize_labs2exp: jsonize_type(labs2exp) +overload jsonize with jsonize_labs2exp + +fun +jsonize_abstdf2: jsonize_type(abstdf2) +overload jsonize with jsonize_abstdf2 + +fun +jsonize_effs2expopt: jsonize_type(effs2expopt) +overload jsonize with jsonize_effs2expopt + +fun +jsonize_s2itm: jsonize_type(s2itm) +overload jsonize with jsonize_s2itm diff --git a/contrib/sparverius/xjsonize/SATS/stamp0.sats b/contrib/sparverius/xjsonize/SATS/stamp0.sats new file mode 100644 index 000000000..27de65623 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/stamp0.sats @@ -0,0 +1,10 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload STM = "{$XATS}/SATS/stamp0.sats" + +#staload "./json.sats" + +fun jsonize_stamp : jsonize_type($STM.stamp) +overload jsonize with jsonize_stamp + +fun labify_stamp : labify_type($STM.stamp) +overload labify with labify_stamp diff --git a/contrib/sparverius/xjsonize/SATS/statyp2.sats b/contrib/sparverius/xjsonize/SATS/statyp2.sats new file mode 100644 index 000000000..e354d3dae --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/statyp2.sats @@ -0,0 +1,12 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/statyp2.sats" + +#staload "./json.sats" + +fun +jsonize_labt2ype: jsonize_type(labt2ype) +overload jsonize with jsonize_labt2ype + +fun +jsonize_t2ype: jsonize_type(t2ype) +overload jsonize with jsonize_t2ype diff --git a/contrib/sparverius/xjsonize/SATS/symbol.sats b/contrib/sparverius/xjsonize/SATS/symbol.sats new file mode 100644 index 000000000..1bfbf6bad --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/symbol.sats @@ -0,0 +1,12 @@ +#define XATS_targetloc "./../../../../srcgen/xats" +#staload "{$XATS}/SATS/symbol.sats" + +#staload "./json.sats" + +fun +jsonize_symbol : jsonize_type(symbol) +overload jsonize with jsonize_symbol + +fun +labify_symbol : labify_type(symbol) +overload labify with labify_symbol diff --git a/contrib/sparverius/xjsonize/SATS/trans01.sats b/contrib/sparverius/xjsonize/SATS/trans01.sats new file mode 100644 index 000000000..85e1bc0e9 --- /dev/null +++ b/contrib/sparverius/xjsonize/SATS/trans01.sats @@ -0,0 +1,6 @@ +(* +fun +the_fxtyenv_println(): void +fun +jsonize_fxtyenv_fprint(FILEref): void +*) diff --git a/contrib/sparverius/xjsonize/TEST/gfact.dats b/contrib/sparverius/xjsonize/TEST/gfact.dats new file mode 100644 index 000000000..5ceb2ffef --- /dev/null +++ b/contrib/sparverius/xjsonize/TEST/gfact.dats @@ -0,0 +1,34 @@ +(* ****** ****** *) + +#include +"./../../../prelude/DATS/gnum.dats" +#include +"./../../../prelude/DATS/gord.dats" +#include +"./../../../prelude/DATS/gint.dats" + +(* ****** ****** *) + +#extern +fun + +gfact(x: a): a + +implement + +gfact = +fix +fact(x) => +if +g_gtz(x) +then +g_mul(x, fact(g_pred(x))) else g_1() + +(* ****** ****** *) + +val fact10 = +let val ans = gfact(10) in ans end + +(* ****** ****** *) + +(* end of [gfact.dats] *) diff --git a/contrib/sparverius/xjsonize/TEST/kfact.dats b/contrib/sparverius/xjsonize/TEST/kfact.dats new file mode 100644 index 000000000..cae9ac21f --- /dev/null +++ b/contrib/sparverius/xjsonize/TEST/kfact.dats @@ -0,0 +1,30 @@ +(* ****** ****** *) + +#extern +fun + +kfact +( n: int +, k: int - ans): ans + +implement + +kfact = +fix +kf(n, k0) => +if n > 0 +then kf(n-1, lam(r) => k0(n * r)) +else k0(1) // end of [if] + +val +fact = +lam(n) => kfact(n, lam r => r) + +(* ****** ****** *) + +val fact10 = +let val ans = fact(10) in ans end + +(* ****** ****** *) + +(* end of [kfact.dats] *) diff --git a/contrib/sparverius/xjsonize/TEST/kfibo.dats b/contrib/sparverius/xjsonize/TEST/kfibo.dats new file mode 100644 index 000000000..1a06fe70f --- /dev/null +++ b/contrib/sparverius/xjsonize/TEST/kfibo.dats @@ -0,0 +1,26 @@ +(* ****** ****** *) + +fun +kfibo(n, k) = +if n > 1 +then +kfibo +( n-1 +, lam(r1) => + kfibo + (n-2, lam(r2) => k(r1+r2)) +) +else k(n) + +val +fibo = +lam(n) => kfibo(n, lam r => r) + +(* ****** ****** *) + +val fibo10 = +let val ans = fibo(10) in ans end + +(* ****** ****** *) + +(* end of [kfact.dats] *) diff --git a/contrib/sparverius/xjsonize/TEST/kisevn.dats b/contrib/sparverius/xjsonize/TEST/kisevn.dats new file mode 100644 index 000000000..df069a98b --- /dev/null +++ b/contrib/sparverius/xjsonize/TEST/kisevn.dats @@ -0,0 +1,25 @@ +(* ****** ****** *) + +fun + +kisevn +( x: int +, k: int -> ans): ans = +if x > 0 +then kisodd(x-1, k) else k(1) +and +kisodd +( x: int +, k: int -> ans): ans = +if x > 0 +then kisevn(x-1, k) else k(0) + +(* ****** ****** *) + +val isevn10 = kisevn(10, lam r => r) +val isodd10 = kisodd(10, lam r => r) + +(* ****** ****** *) + +(* end of [kisevn.dats] *) + diff --git a/contrib/sparverius/xjsonize/TEST/mytest01.dats b/contrib/sparverius/xjsonize/TEST/mytest01.dats new file mode 100644 index 000000000..2d1efac2e --- /dev/null +++ b/contrib/sparverius/xjsonize/TEST/mytest01.dats @@ -0,0 +1,88 @@ + + +#extern fun +foo$helper(help: a): int + +(* #extern fun *) +(* foo(x: a): int *) + +implement foo$helper(x) = if x then 1 else 0 + +fun foo(x: a): int = foo$helper(x) + + +(* implement foo(x) = foo$helper(x) *) + +val xs = foo(false) +(* where *) +(* implement foo$helper(x) = if x then 1 else 0 *) +(* end *) + + + + +//// + +(* +fun +map (xs:list(a), f0: a -> b) = +( +case+ xs of +| list_nil() => + list_nil() +| list_cons(x0, xs) => + list_cons(f0(x0), map(xs, f0)) +) + +fun foo (a: int): bool = a = 0 + +(* +val ys = list_cons(1, list_nil()) +fun foo (a: int): bool = a = 0 +val xys = map(ys, foo) +*) +*) + +#extern fun + +foldl$fopr(res:res, x:x): res + +implement foldl$fopr(res, x) = g_add(res, x) + +fun +foldl (xs:list(x), res: res) = +( +case+ xs of +| list_cons(x0, xs) => foldl(xs, foldl$fopr(res, x0)) +| list_nil() => res +) + +val ys = list_cons(1, list_cons(2, list_nil())) + + +val res = foldl(ys, 0) +(* +where + implement foldl$fopr(res, x) = res + x +end +*) +(* +val res = foldl(ys, 0) where + implement foldl$fopr(res, x) = res + x +end +*) + + +(* +fun +foldl (xs:list(a), f0: (a, b) -> b, res: b) = +( +case+ xs of +| list_nil() => res +| list_cons(x0, xs) => foldl(xs, f0, f0(x0, res)) +) + +*) +(* val ys = list_cons(1, list_cons(2, list_nil())) *) +(* val xys = map(ys, lam a => a = 0) *) +(* val res = foldl(xys, lam(a,res) => (if a then res else res+1), 0) *) diff --git a/contrib/sparverius/xjsonize/TEST/staexp2.dats b/contrib/sparverius/xjsonize/TEST/staexp2.dats new file mode 100644 index 000000000..e69de29bb diff --git a/contrib/sparverius/xjsonize/TEST/test01.dats b/contrib/sparverius/xjsonize/TEST/test01.dats new file mode 100644 index 000000000..77feeec6d --- /dev/null +++ b/contrib/sparverius/xjsonize/TEST/test01.dats @@ -0,0 +1,236 @@ +(* ****** ****** *) + +#include +"./../../../prelude/DATS/gnum.dats" +#include +"./../../../prelude/DATS/gord.dats" +#include +"./../../../prelude/DATS/gint.dats" + +(* ****** ****** *) + +val x = g_succ(1) + +(* ****** ****** *) + +//// + +(* + +HX-2019-12-01: +This one is not yet supported. +Should it be supported? + +*) + +fun f = +fix g(x: int): int => +if x >= 2 then f(x-1) + g(x-2) else x + +val f10 = f(10) + +//// + +fun + +kfact +( n: int +, k: int -> ans): ans = +if n = 0 +then k(1) +else +kfact(n-1, lam(r) => k(n*r)) +val +fact10 = kfact(10, lam r => r) + +//// + +fun +fact2 +( nr +: @(int, int)): int = +if +nr.0 = 0 +then nr.1 +else +let +val @(n, r) = nr +in fact2(@(n-1, n*r)) end + +val fact10 = fact2(@(10, 1)) + +//// + +#extern +fun fact : int -> int +implement +fact(x) = +if x > 0 then x * fact(x-1) else 1 + +val fact10 = fact(10) + +//// + +fun +fact = +lam(x) => +( +fix f(x) => +if x > 0 +then x * fact(x-1) else 1)(x) +val fact10 = fact(10) + +//// + +fun +isevn(x: int): int = +if x > 0 +then isodd(x-1) else 1 +and +isodd(x: int): int = +if x > 0 +then isevn(x-1) else 0 + +val isevn10 = isevn(10) +val isodd10 = isodd(10) + +//// + +#extern +fun<> +fact : int -> int +implement +fact<> = +fix f(x) => +if x > 0 then x * f(x-1) else 1 + +val +fact10 = fact(10) + +//// + +fun +fact2 +( nr +: $(int, int)): int = +if +nr.0 = 0 +then nr.1 +else +let +val $(n, r) = nr +in fact2($(n-1, n*r)) end + +val fact10 = fact2($(10, 1)) + +(* ****** ****** *) +//// +val xy = @(1,2) +val xy_0 = xy.0 +val xy = $(1,2) +val xy_1 = xy.1 + +(* ****** ****** *) +//// +val +fact = +fix f(x:int):int => +if +x > 0 +then x*f(x-1) else 1 +// +(* ****** ****** *) +//// + +(* ****** ****** *) + +fun +from(n: int): list(int) = +if +(n > 0) +then +cons(n, from(n-1)) else nil() + +(* ****** ****** *) + +fun +list_mul +( xs +: list(int)): int = +case+ xs of +| nil() => 1 +| cons(x0, xs) => x0*list_mul(xs) + +(* ****** ****** *) + +fun +fact(n) = +list_mul(from(n)) + +(* ****** ****** *) + +val fact10 = fact(10) + +(* ****** ****** *) +//// +(* ****** ****** *) + +fun +tally +( xs +: list(int)): int = +case+ xs of +| nil() => 0 +| cons(x0, xs) => x0+tally(xs) + +(* ****** ****** *) + +val x0 = nil() +val x1 = cons(1,x0) +val x2 = cons(2,x1) +val x3 = cons(3,x2) +val sum = tally(x3) + +(* ****** ****** *) + +//// +(* ****** ****** *) + +val +fact10 = fact(10) where +{ +fun +fact(x: int): int = +if x > 0 then x * fact(x-1) else 1 +} + +(* ****** ****** *) +//// +val +isevn = +fix f(x:int): bool => +( +if x > 0 then g(x-1) else true +) where +{ +val g = +lam(x) => +if x > 0 then f(x-1) else false +} +val isevn100 = isevn(100) +val isevn101 = isevn(101) +//// +(* ****** ****** *) + +// (* +val x = 10 +val y = 20 +val f1 = lam(x:int) => x + x +val x2 = f(x) +val f2 = lam(x:int)(y:int) => x * y +val xy = f2(x)(y) +// *) +// +(* ****** ****** *) + +(* end of [test01.dats] *) diff --git a/srcgen/xint/DATS/interp0_print.dats b/srcgen/xint/DATS/interp0_print.dats index 2096b43ed..21dcf4c52 100644 --- a/srcgen/xint/DATS/interp0_print.dats +++ b/srcgen/xint/DATS/interp0_print.dats @@ -13,12 +13,12 @@ ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the ** Free Software Foundation; either version 3, or (at your option) any ** later version. -** +** ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY ** WARRANTY; without even the implied warranty of MERCHANTABILITY or ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ** for more details. -** +** ** You should have received a copy of the GNU General Public License ** along with ATS; see the file COPYING. If not, please write to the ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA @@ -73,10 +73,10 @@ fprint_val = fprint_ir0val (* ****** ****** *) // implement -print_ir0val(x0) = +print_ir0val(x0) = fprint_ir0val(stdout_ref, x0) implement -prerr_ir0val(x0) = +prerr_ir0val(x0) = fprint_ir0val(stderr_ref, x0) // implement @@ -113,7 +113,7 @@ case+ x0 of | IR0Vtuple(knd, irvs) => fprint! ( out - , "IR0Vtuple(", knd, "; ", irvs, ")") + , "IR0Vtuple(", knd, "; [", irvs, "])") // | IR0Vlam (fenv, iras, ire1) => diff --git a/srcgen/xint/DATS/intrep0_print.dats b/srcgen/xint/DATS/intrep0_print.dats index 1c139b7a7..98bad6f7b 100644 --- a/srcgen/xint/DATS/intrep0_print.dats +++ b/srcgen/xint/DATS/intrep0_print.dats @@ -13,12 +13,12 @@ ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the ** Free Software Foundation; either version 3, or (at your option) any ** later version. -** +** ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY ** WARRANTY; without even the implied warranty of MERCHANTABILITY or ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ** for more details. -** +** ** You should have received a copy of the GNU General Public License ** along with ATS; see the file COPYING. If not, please write to the ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA @@ -233,21 +233,21 @@ x0.node() of fprint! ( out , "IR0Etcst(" - , d2c1, "; ", ti3a, "; ", ti2s, ")") + , d2c1, "; ", ti3a, "; [", ti2s, "])") | IR0Etimp ( ire1 , targ, irc2, tsub) => fprint! ( out , "IR0Etimp(" - , ire1, "; ", targ, "; ", irc2, "; ", tsub) + , ire1, "; [", targ, "]; ", irc2, "; [", tsub, "])") // | IR0Edapp (irf0, npf1, ires) => fprint! ( out , "IR0Edapp(" - , irf0, "; ", npf1, "; ", ires, ")") + , irf0, "; ", npf1, "; [", ires, "])") // | IR0Eproj (ire1, lab2, idx2) => @@ -263,7 +263,7 @@ x0.node() of | IR0Ewhere(ire1, irds) => fprint! ( out - , "IR0Ewhere(", ire1, "; ", irds, ")") + , "IR0Ewhere(", ire1, "; [", irds, "])") // | IR0Eseqn (ires, ire1) => @@ -276,7 +276,7 @@ x0.node() of fprint! ( out , "IR0Etuple(" - , knd0, "; ", npf1, "; ", ires, ")") + , knd0, "; ", npf1, "; [", ires, "])") // | IR0Eassgn(irel, irer) => fprint! @@ -299,13 +299,13 @@ x0.node() of (knd0, farg, body) => fprint! ( out, "IR0Elam(" - , knd0, "; ", farg, "; ", body, ")") + , knd0, "; [", farg, "]; ", body, ")") | IR0Efix (knd0, d2v0, farg, body) => fprint! ( out, "IR0Efix(" , knd0, "; " - , d2v0, "; ", farg, "; ", body, ")") + , d2v0, "; [", farg, "]; ", body, ")") // | IR0Eaddr(ire1) => (