├── .gitignore ├── .travis.yml ├── Makefile_update ├── README.md ├── bin └── .keeper ├── lib └── .gitkeep ├── prelude ├── DATS │ ├── CATS │ │ ├── JS │ │ │ ├── Node │ │ │ │ ├── g_print.cats │ │ │ │ └── g_print.dats │ │ │ ├── basics.dats │ │ │ ├── g_eqref.cats │ │ │ ├── g_eqref.dats │ │ │ ├── g_print.cats │ │ │ ├── g_print.dats │ │ │ ├── jsbasics.cats │ │ │ ├── jsbasics.dats │ │ │ ├── prelude.cats │ │ │ ├── prelude.dats │ │ │ ├── runtime.cats │ │ │ └── unsafe.dats │ │ └── Xint │ │ │ ├── .keeper │ │ │ ├── basics.dats │ │ │ └── prelude.dats │ ├── array.dats │ ├── bool.dats │ ├── char.dats │ ├── gbas.dats │ ├── gflt.dats │ ├── gfor.dats │ ├── gfun.dats │ ├── gint.dats │ ├── gios.dats │ ├── gmap.dats │ ├── gnum.dats │ ├── gord.dats │ ├── gseq.dats │ ├── gseq_vt.dats │ ├── gseqn.dats │ ├── list.dats │ ├── list_vt.dats │ ├── optn.dats │ ├── optn_vt.dats │ ├── rand.dats │ ├── stream.dats │ ├── stream_vt.dats │ ├── string.dats │ ├── synougat.dats │ ├── tuple.dats │ └── unsafe.dats ├── SATS │ ├── CC │ │ ├── array.sats │ │ └── basics.sats │ ├── array.sats │ ├── bool.sats │ ├── char.sats │ ├── gbas.sats │ ├── gflt.sats │ ├── gfor.sats │ ├── gfun.sats │ ├── gint.sats │ ├── gintb.sats │ ├── gmap.sats │ ├── gnum.sats │ ├── gord.sats │ ├── gseq.sats │ ├── gseq_vt.sats │ ├── gseqn.sats │ ├── gseqn_vt.sats │ ├── list.sats │ ├── list_vt.sats │ ├── optn.sats │ ├── optn_vt.sats │ ├── stream.sats │ ├── stream_vt.sats │ ├── string.sats │ └── unsafe.sats ├── basics.sats ├── excptn.sats ├── fixity.sats ├── xparam.hats └── xsetup.sats ├── srcgen ├── xats │ ├── .depend │ ├── BUILD │ │ └── .gitkeep │ ├── CATS │ │ ├── lexbuf0.cats │ │ ├── locinfo.cats │ │ └── parsing.cats │ ├── DATS │ │ ├── CONTRIB │ │ │ ├── githwxi │ │ │ │ ├── .keeper │ │ │ │ ├── my_tread23_dynexp.dats │ │ │ │ └── my_tread33_dynexp.dats │ │ │ ├── tread23_dynexp.dats │ │ │ └── tread33_dynexp.dats │ │ ├── cstrnt0.dats │ │ ├── cstrnt0_print.dats │ │ ├── cstrnt1.dats │ │ ├── cstrnt1_print.dats │ │ ├── dmacro2_macdef.dats │ │ ├── dynexp0.dats │ │ ├── dynexp0_print.dats │ │ ├── dynexp1.dats │ │ ├── dynexp1_print.dats │ │ ├── dynexp2.dats │ │ ├── dynexp2_d2con.dats │ │ ├── dynexp2_d2cst.dats │ │ ├── dynexp2_d2var.dats │ │ ├── dynexp2_print.dats │ │ ├── dynexp3.dats │ │ ├── dynexp3_print.dats │ │ ├── dynexp3_util0.dats │ │ ├── dynexp4.dats │ │ ├── dynexp4_print.dats │ │ ├── dynexp4_stmap.dats │ │ ├── dynexp4_util0.dats │ │ ├── effect0.dats │ │ ├── filpath.dats │ │ ├── filsrch.dats │ │ ├── gmacro1_define.dats │ │ ├── intrep0.dats │ │ ├── intrep0_dynexp.dats │ │ ├── intrep0_jsoniz.dats │ │ ├── intrep0_print.dats │ │ ├── intrep0_statyp.dats │ │ ├── lexbuf0.dats │ │ ├── lexing0_kword.dats │ │ ├── lexing0_token.dats │ │ ├── lexing0_util0.dats │ │ ├── locinfo.dats │ │ ├── nmspace.dats │ │ ├── parsing_basics.dats │ │ ├── parsing_dynexp.dats │ │ ├── parsing_staexp.dats │ │ ├── parsing_tokbuf.dats │ │ ├── staexp0.dats │ │ ├── staexp0_print.dats │ │ ├── staexp1.dats │ │ ├── staexp1_print.dats │ │ ├── staexp2.dats │ │ ├── staexp2_init0.dats │ │ ├── staexp2_print.dats │ │ ├── staexp2_s2cst.dats │ │ ├── staexp2_util1.dats │ │ ├── staexp2_util2.dats │ │ ├── statyp2.dats │ │ ├── statyp2_init0.dats │ │ ├── statyp2_print.dats │ │ ├── statyp2_unify.dats │ │ ├── statyp2_util0.dats │ │ ├── synread_basics.dats │ │ ├── synread_dynexp.dats │ │ ├── synread_staexp.dats │ │ ├── tcomp30_dynexp.dats │ │ ├── tcomp30_statyp.dats │ │ ├── tcomp30_util0.dats │ │ ├── trans01_basics.dats │ │ ├── trans01_dynexp.dats │ │ ├── trans01_envmap.dats │ │ ├── trans01_staexp.dats │ │ ├── trans12_basics.dats │ │ ├── trans12_dynexp.dats │ │ ├── trans12_envmap.dats │ │ ├── trans12_staexp.dats │ │ ├── trans23_dynexp.dats │ │ ├── trans23_util0.dats │ │ ├── trans33_dynexp.dats │ │ ├── trans33_envmap.dats │ │ ├── trans33_util0.dats │ │ ├── trans34_dynexp.dats │ │ ├── trans34_envmap.dats │ │ ├── trans34_util1.dats │ │ ├── trans34_util2.dats │ │ ├── trans3t_dynexp.dats │ │ ├── trans3t_envmap.dats │ │ ├── trans3x_dynexp.dats │ │ ├── trans3x_envmap.dats │ │ ├── trans4x_dynexp.dats │ │ ├── trans4x_envmap.dats │ │ ├── tread01_dynexp.dats │ │ ├── tread01_staexp.dats │ │ ├── tread12_dynexp.dats │ │ ├── tread12_staexp.dats │ │ ├── tread23_dynexp.dats │ │ ├── tread33_dynexp.dats │ │ ├── tread34_dynexp.dats │ │ ├── tread3x_dynexp.dats │ │ ├── xatsopt.dats │ │ ├── xatsopt_main0.dats │ │ ├── xatsopt_util0.dats │ │ ├── xbasics.dats │ │ ├── xerrory.dats │ │ ├── xfixity.dats │ │ ├── xglobal.dats │ │ ├── xlabel0.dats │ │ ├── xstamp0.dats │ │ ├── xsymbol.dats │ │ ├── xsymenv.dats │ │ └── xsymmap.dats │ ├── HATS │ │ └── xatsopt.hats │ ├── Makefile │ ├── Makefile_xatsopt │ ├── SATS │ │ ├── cstrnt0.sats │ │ ├── cstrnt1.sats │ │ ├── dynexp0.sats │ │ ├── dynexp1.sats │ │ ├── dynexp2.sats │ │ ├── dynexp3.sats │ │ ├── dynexp4.sats │ │ ├── effect0.sats │ │ ├── filpath.sats │ │ ├── filsrch.sats │ │ ├── intrep0.sats │ │ ├── lexbuf0.sats │ │ ├── lexing0.sats │ │ ├── locinfo.sats │ │ ├── nmspace.sats │ │ ├── parsing.sats │ │ ├── staexp0.sats │ │ ├── staexp1.sats │ │ ├── staexp2.sats │ │ ├── statyp2.sats │ │ ├── synread.sats │ │ ├── tcomp30.sats │ │ ├── trans01.sats │ │ ├── trans12.sats │ │ ├── trans23.sats │ │ ├── trans33.sats │ │ ├── trans34.sats │ │ ├── trans3t.sats │ │ ├── trans3x.sats │ │ ├── trans4x.sats │ │ ├── tread01.sats │ │ ├── tread12.sats │ │ ├── tread23.sats │ │ ├── tread33.sats │ │ ├── tread34.sats │ │ ├── tread3t.sats │ │ ├── tread3x.sats │ │ ├── xatsopt.sats │ │ ├── xbasics.sats │ │ ├── xerrory.sats │ │ ├── xfixity.sats │ │ ├── xglobal.sats │ │ ├── xlabel0.sats │ │ ├── xstamp0.sats │ │ ├── xsymbol.sats │ │ ├── xsymenv.sats │ │ └── xsymmap.sats │ └── TEST │ │ ├── Makefile_prelude │ │ ├── Makefile_test │ │ └── Makefile_xatslib └── xutl │ ├── DATS │ ├── Posix │ │ ├── cblist.dats │ │ └── mylibc.dats │ ├── Windows │ │ └── .gitkeep │ └── cblist.dats │ ├── SATS │ ├── Posix │ │ └── cblist.sats │ ├── Windows │ │ └── cblist.sats │ ├── cblist.sats │ └── mylibc.sats │ └── TEST │ ├── Makefile │ ├── Posix │ ├── DATA │ │ └── test_cblist.txt │ ├── Makefile │ ├── test_cblist.dats │ └── test_mylibc.dats │ └── cblist.dats ├── travis-ci ├── install-ats2.sh └── travis.yml └── xatslib ├── githwxi ├── DATS │ ├── dvdcnq.dats │ ├── gtree1.dats │ ├── mygist.dats │ ├── mytest.dats │ ├── parcmbr1.dats │ └── xdebug.dats ├── SATS │ └── githwxi.sats └── TEST │ └── test-2020-03-21.dats └── libc ├── DATS ├── CATS │ ├── JS │ │ └── Node │ │ │ ├── basics.dats │ │ │ └── prelude.cats │ └── Xint │ │ └── basics.dats ├── fpath.dats ├── gios.dats ├── rand.dats └── stdio.dats └── SATS └── libc.sats /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # ignoring generated files 3 | # 4 | bin/xatsopt 5 | srcgen/xats/xatsopt 6 | 7 | ###### end of [.gitignore] ###### 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: 3 | - linux 4 | 5 | language: c 6 | 7 | node_js: 8 | - "5.10.1" 9 | 10 | env: 11 | - export NODE_VERSION="5.10.1" 12 | 13 | addons: 14 | apt: 15 | packages: 16 | - libgc-dev 17 | - libgmp-dev 18 | 19 | before_install: 20 | - date 21 | - export PATSHOME=${HOME}/ATS2 22 | - export PATH=${PATH}:${PATSHOME}/bin 23 | - export XATSHOME=${TRAVIS_BUILD_DIR} 24 | - export GCC=gcc 25 | - export CLANG=clang 26 | 27 | install: 28 | # $XATSHOME/travis-ci/install-ats2.sh 0.4.0 29 | # $XATSHOME/travis-ci/install-ats2.sh 0.4.1 30 | - $XATSHOME/travis-ci/install-ats2.sh 0.4.2 31 | 32 | after_install: 33 | - date 34 | 35 | before_script: 36 | - date 37 | 38 | script: 39 | # Building ATS2 40 | - cd ${PATSHOME} 41 | - ./configure&&make CC=${GCC} all 42 | # Building Xanadu 43 | - cd ${XATSHOME}/srcgen 44 | - echo 'building ATS-Xanadu...' 45 | - (cd xats && make all) 46 | - echo 'running xutl unit-tests...' 47 | - (cd xutl/TEST && make testall) 48 | - (cd xutl/TEST/Posix && make testall) 49 | - echo 'running xats unit-tests...' 50 | - (cd xats/TEST && make XATSOPT=./../xatsopt -f Makefile_test all) 51 | 52 | after_script: 53 | - date 54 | -------------------------------------------------------------------------------- /Makefile_update: -------------------------------------------------------------------------------- 1 | ###### 2 | # 3 | # HX-2019-12-18: 4 | # All the files in xanadu-lang/xanadu 5 | # are supposed to be copied for ATS-Xanadu 6 | # 7 | ###### 8 | 9 | CPF=cp -f 10 | CPFR=cp -f -r 11 | 12 | ###### 13 | 14 | all:: update 15 | 16 | ###### 17 | 18 | update:: MISC 19 | update:: SATS 20 | update:: DATS 21 | update:: CATS 22 | update:: HATS 23 | update:: CONTRIB 24 | 25 | ###### 26 | 27 | update:: PRETOP 28 | update:: PRESATS 29 | update:: PREDATS 30 | update:: PREDATSCATS 31 | update:: XATSLIB 32 | 33 | ###### 34 | 35 | MISC:: ; \ 36 | $(CPF) \ 37 | $(XATSHOME)/srcgen/xats/Makefile_xatsopt ./srcgen/xats/. 38 | MISC:: ; \ 39 | $(CPF) \ 40 | $(XATSHOME)/srcgen/xats/TEST/Makefile_prelude ./srcgen/xats/TEST/. 41 | MISC:: ; \ 42 | $(CPF) \ 43 | $(XATSHOME)/srcgen/xats/TEST/Makefile_xatslib ./srcgen/xats/TEST/. 44 | 45 | ###### 46 | 47 | SATS:: ; \ 48 | $(CPF) $(XATSHOME)/srcgen/xats/SATS/*.sats ./srcgen/xats/SATS/. 49 | 50 | DATS:: ; \ 51 | $(CPF) $(XATSHOME)/srcgen/xats/DATS/*.dats ./srcgen/xats/DATS/. 52 | 53 | CATS:: ; \ 54 | $(CPF) $(XATSHOME)/srcgen/xats/CATS/*.cats ./srcgen/xats/CATS/. 55 | 56 | HATS:: ; \ 57 | $(CPF) $(XATSHOME)/srcgen/xats/HATS/*.hats ./srcgen/xats/HATS/. 58 | 59 | CONTRIB:: ; \ 60 | $(CPFR) $(XATSHOME)/srcgen/xats/DATS/CONTRIB ./srcgen/xats/DATS/. 61 | 62 | ###### 63 | # 64 | PRETOP:: ; $(CPF) $(XATSHOME)/prelude/*.?ats ./prelude/. 65 | # 66 | PRESATS:: ; $(CPF) $(XATSHOME)/prelude/SATS/*.sats ./prelude/SATS/. 67 | PRESATS:: ; $(CPF) $(XATSHOME)/prelude/SATS/CC/*.sats ./prelude/SATS/CC/. 68 | # 69 | PREDATS:: ; $(CPF) $(XATSHOME)/prelude/DATS/*.dats ./prelude/DATS/. 70 | # 71 | PREDATSCATS:: \ 72 | PREDATSCATS_JS 73 | PREDATSCATS_JS:: ; \ 74 | $(CPF) $(XATSHOME)/prelude/DATS/CATS/JS/*.?ats ./prelude/DATS/CATS/JS/. 75 | PREDATSCATS_JS:: ; \ 76 | $(CPF) \ 77 | $(XATSHOME)/prelude/DATS/CATS/JS/Node/*.?ats ./prelude/DATS/CATS/JS/Node/. 78 | # 79 | PREDATSCATS:: \ 80 | PREDATSCATS_Xint 81 | PREDATSCATS_Xint:: ; \ 82 | $(CPF) $(XATSHOME)/prelude/DATS/CATS/Xint/*.dats ./prelude/DATS/CATS/Xint/. 83 | # 84 | ###### 85 | # 86 | XATSLIB:: \ 87 | XATSLIB_libc 88 | XATSLIB_libc:: ; \ 89 | $(CPF) $(XATSHOME)/xatslib/libc/SATS/*.sats ./xatslib/libc/SATS/. 90 | XATSLIB_libc:: ; \ 91 | $(CPF) $(XATSHOME)/xatslib/libc/DATS/*.dats ./xatslib/libc/DATS/. 92 | # 93 | XATSLIB_libc:: ; \ 94 | $(CPF) $(XATSHOME)/xatslib/libc/DATS/CATS/Xint/*.?ats ./xatslib/libc/DATS/CATS/Xint/. 95 | # 96 | XATSLIB_libc:: ; \ 97 | $(CPF) $(XATSHOME)/xatslib/libc/DATS/CATS/JS/Node/*.?ats ./xatslib/libc/DATS/CATS/JS/Node/. 98 | # 99 | ###### 100 | 101 | XATSLIB:: \ 102 | XATSLIB_githwxi 103 | XATSLIB_githwxi:: ; \ 104 | $(CPF) $(XATSHOME)/xatslib/githwxi/SATS/*.sats ./xatslib/githwxi/SATS/. 105 | XATSLIB_githwxi:: ; \ 106 | $(CPF) $(XATSHOME)/xatslib/githwxi/DATS/*.dats ./xatslib/githwxi/DATS/. 107 | XATSLIB_githwxi:: ; \ 108 | $(CPF) $(XATSHOME)/xatslib/githwxi/TEST/*.dats ./xatslib/githwxi/TEST/. 109 | 110 | ###### end of [Makefile] ###### 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [ATS3](http://www.ats-lang.org/) - ATS/Xanadu 2 | 3 | A Programming Language System to Unleash the Potentials 4 | of Types and Templates 5 | 6 | ## Build Status 7 | 8 | * [![Build Status](https://travis-ci.org/xanadu-lang/xanadu.svg?branch=master)](https://travis-ci.org/xanadu-lang/xanadu) Ubuntu 9 | 10 | ## Project Description 11 | 12 | ATS3 is an attempt to greatly improve upon ATS2. The version of ATS3 13 | in this repository is supposed to be used to generate *libxatsopt* for 14 | developing ATS3 tool support of all sorts. 15 | 16 | Probably the biggest problem with ATS2 is the *very* steep learning 17 | curve associated with it. Very few programmers were able to ever 18 | overcome it to reach the point where they could truly start enjoying 19 | the tremendous power of (advanced) type-checking and (embeddable) 20 | templates. 21 | 22 | When DML (the predecessor of ATS) was designed nearly 20 years ago, a 23 | two-layered approach to type-checking was taken: ML-like type-checking 24 | first and dependent type-checking second. This approach was later 25 | abandoned in the design of ATS. Instead, there is only dependent 26 | type-checking in ATS1 and ATS2. In ATS3, DML's two-layered approach is 27 | to be adopted. In particular, a program in ATS3 that passes ML-like 28 | type-checking can be compiled and executed. So one can skip dependent 29 | type-checking in ATS3 if one so chooses. In this way, the learning 30 | curve is expected to be greatly leveled. But there is much more than 31 | just leveling the learning curve. 32 | 33 | ML-like types are algebraic (involving no explicit quantifiers). Such 34 | types are so much friendlier than dependent types (which often involve 35 | explicit quantifiers) for supporting type-based meta-programming. It 36 | seems that a chance has finally arrived to properly address the 37 | problem of template instance resolution that causes so much annoyance 38 | in ATS2 (due to the very use of dependent types for template selection). 39 | 40 | In short, ATS3 adds an extra layer to ATS2 for supporting ML-like 41 | algebraic type-checking. Type-based meta-programming in ATS3 solely 42 | uses algebraic types (while ATS2 uses dependent types). 43 | 44 | ## Installing ATS3 45 | 46 | ATS3 is not ready for release yet. 47 | 48 | Please see 49 | [http://www.ats-lang.org/Downloads.html](http://www.ats-lang.org/Downloads.html) for 50 | instructions after it is officially released. 51 | 52 | ## Developing ATS3 53 | 54 | ## Documenting ATS3 55 | 56 | ## Licenses for ATS/Xanadu 57 | 58 | * The Compiler (ATS/Xanadu): 59 | [GPLv3](https://github.com/githwxi/ATS-Xanadu/blob/master/COPYING-gpl-3.0.txt) 60 | * The ATS source for the Libraries (ATSLIB/{prelude,libats}): 61 | [LGPLv3](https://github.com/githwxi/ATS-Xanadu/blob/master/COPYING-lgpl-3.0.txt). 62 | * As a special exception, any C code generated by the Compiler based on the Libraries 63 | source is not considered by default to be licensed under GPLv3/LGPLv3. If you use such 64 | C code together with other code to create an executable, then the C code by itself does 65 | not cause the executable to be covered by GPLv3/LGPLv3. However, there may be reasons 66 | unrelated to using ATS that can result in the executable being covered by GPLv3/LGPLv3. 67 | * The contributed portion (ATS/Xanadu/contrib) is released under the MIT license. 68 | * There is also a release under the MIT license for the C header files of the Libraries, 69 | which one can, for instance, freely insert into C code generated from ATS source code. 70 | -------------------------------------------------------------------------------- /bin/.keeper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/bin/.keeper -------------------------------------------------------------------------------- /lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/lib/.gitkeep -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/Node/g_print.cats: -------------------------------------------------------------------------------- 1 | /* ****** ****** */ 2 | /* 3 | G_print for Xats2js/Node 4 | */ 5 | /* ****** ****** */ 6 | // 7 | function 8 | XATS2JS_NODE_g_print(obj) 9 | { 10 | let 11 | rep = obj.toString(); 12 | process.stdout.write(rep); 13 | return; // XATS2JS_NODE_g_print 14 | } 15 | // 16 | /* ****** ****** */ 17 | function 18 | XATS2JS_NODE_bool_print 19 | (b0) 20 | { 21 | if(b0) 22 | { 23 | XATS2JS_NODE_g_print("true"); 24 | } 25 | else 26 | { 27 | XATS2JS_NODE_g_print("false"); 28 | } 29 | return; // XATS2JS_NODE_bool_print 30 | } 31 | /* ****** ****** */ 32 | function 33 | XATS2JS_NODE_char_print 34 | (c0) 35 | { 36 | // c0: number 37 | XATS2JS_NODE_g_print 38 | (String.fromCharCode(c0)); 39 | return; // XATS2JS_NODE_char_print 40 | } 41 | /* ****** ****** */ 42 | function 43 | XATS2JS_NODE_gint_print_sint 44 | (x0) 45 | { 46 | XATS2JS_NODE_g_print(x0); 47 | return; // gint_print_sint<> 48 | } 49 | function 50 | XATS2JS_NODE_gint_print_uint 51 | (x0) 52 | { 53 | XATS2JS_NODE_g_print(x0); 54 | return; // gint_print_uint<> 55 | } 56 | /* ****** ****** */ 57 | function 58 | XATS2JS_NODE_gflt_print_sflt 59 | (x0) 60 | { 61 | XATS2JS_NODE_g_print(x0); 62 | return; // gflt_print_sflt<> 63 | } 64 | function 65 | XATS2JS_NODE_gflt_print_dflt 66 | (x0) 67 | { 68 | XATS2JS_NODE_g_print(x0); 69 | return; // gflt_print_dflt<> 70 | } 71 | /* ****** ****** */ 72 | function 73 | XATS2JS_NODE_string_print 74 | (cs) 75 | { 76 | return XATS2JS_NODE_g_print(cs); 77 | } 78 | /* ****** ****** */ 79 | 80 | /* end of [XATS2JS_NODE_g_print.cats] */ 81 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/Node/g_print.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | Print for Xats2js/Node 4 | *) 5 | (* ****** ****** *) 6 | // 7 | impltmp 8 | bool_print<> = 9 | XATS2JS_NODE_bool_print 10 | where 11 | { 12 | #extern 13 | fun 14 | XATS2JS_NODE_bool_print 15 | (b0: bool): void = $exname() 16 | } 17 | // 18 | (* ****** ****** *) 19 | // 20 | impltmp 21 | char_print<> = 22 | XATS2JS_NODE_char_print 23 | where 24 | { 25 | #extern 26 | fun 27 | XATS2JS_NODE_char_print 28 | (b0: char): void = $exname() 29 | } 30 | // 31 | (* ****** ****** *) 32 | impltmp 33 | string_print<> = 34 | XATS2JS_NODE_string_print 35 | where 36 | { 37 | #extern 38 | fun 39 | XATS2JS_NODE_string_print 40 | (cs: string): void = $exname() 41 | } 42 | (* ****** ****** *) 43 | // 44 | local 45 | #extern 46 | fun 47 | XATS2JS_NODE_gint_print_sint 48 | (x0: sint): void = $exname() 49 | #extern 50 | fun 51 | XATS2JS_NODE_gint_print_uint 52 | (x0: uint): void = $exname() 53 | in 54 | impltmp 55 | gint_print_sint<> = XATS2JS_NODE_gint_print_sint 56 | impltmp 57 | gint_print_uint<> = XATS2JS_NODE_gint_print_uint 58 | end // end of [local] 59 | // 60 | (* ****** ****** *) 61 | // 62 | local 63 | #extern 64 | fun 65 | XATS2JS_NODE_gflt_print_sflt 66 | (x0: sflt): void = $exname() 67 | #extern 68 | fun 69 | XATS2JS_NODE_gflt_print_dflt 70 | (x0: dflt): void = $exname() 71 | in 72 | impltmp 73 | gflt_print_sflt<> = XATS2JS_NODE_gflt_print_sflt 74 | impltmp 75 | gflt_print_dflt<> = XATS2JS_NODE_gflt_print_dflt 76 | end // end of [local] 77 | // 78 | (* ****** ****** *) 79 | 80 | (* end of [XATS2JS_NODE_g_print.dats] *) 81 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/g_eqref.cats: -------------------------------------------------------------------------------- 1 | /* ****** ****** */ 2 | /* 3 | G_eqref for Xats2js 4 | */ 5 | /* ****** ****** */ 6 | 7 | function 8 | XATS2JS_g_eqref 9 | (x1, x2) 10 | { 11 | return (x1 === x2); 12 | } 13 | function 14 | XATS2JS_g_neqrf 15 | (x1, x2) 16 | { 17 | return (x1 !== x2); 18 | } 19 | 20 | /* ****** ****** */ 21 | 22 | /* end of [XATS2JS_g_eqref.cats] */ 23 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/g_eqref.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | Eqref for Xats2js 4 | *) 5 | (* ****** ****** *) 6 | // 7 | impltmp 8 | {a:t0} 9 | g_eqref = 10 | XATS2JS_g_eqref{a} 11 | where 12 | { 13 | #extern 14 | fun 15 | XATS2JS_g_eqref 16 | {a:t0} 17 | (x1: a, x2: a): bool = $exname() 18 | } 19 | // 20 | impltmp 21 | {a:t0} 22 | g_neqrf = 23 | XATS2JS_g_neqrf{a} 24 | where 25 | { 26 | #extern 27 | fun 28 | XATS2JS_g_neqrf 29 | {a:t0} 30 | (x1: a, x2: a): bool = $exname() 31 | } 32 | // 33 | (* ****** ****** *) 34 | 35 | (* end of [XATS2JS_g_eqref.dats] *) 36 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/g_print.cats: -------------------------------------------------------------------------------- 1 | /* ****** ****** */ 2 | /* 3 | G_print for Xats2js 4 | */ 5 | /* ****** ****** */ 6 | // 7 | var 8 | XATS2JS_the_print_store = []; 9 | // 10 | /* ****** ****** */ 11 | 12 | function 13 | XATS2JS_g_print(obj) 14 | { 15 | var 16 | rep = obj.toString(); 17 | XATS2JS_the_print_store.push(rep); 18 | return; // XATS2JS_g_print 19 | } 20 | 21 | /* ****** ****** */ 22 | function 23 | XATS2JS_bool_print 24 | (b0) 25 | { 26 | if(b0) 27 | { 28 | XATS2JS_g_print("true"); 29 | } 30 | else 31 | { 32 | XATS2JS_g_print("false"); 33 | } 34 | return; // XATS2JS_bool_print 35 | } 36 | /* ****** ****** */ 37 | function 38 | XATS2JS_char_print 39 | (c0) 40 | { 41 | // c0: number 42 | XATS2JS_g_print 43 | (String.fromCharCode(c0)); 44 | return; // XATS2JS_char_print 45 | } 46 | /* ****** ****** */ 47 | function 48 | XATS2JS_gint_print_sint 49 | (x0) 50 | { 51 | XATS2JS_g_print(x0); 52 | return; // gint_print_sint 53 | } 54 | function 55 | XATS2JS_gint_print_uint 56 | (x0) 57 | { 58 | XATS2JS_g_print(x0); 59 | return; // gint_print_uint 60 | } 61 | /* ****** ****** */ 62 | function 63 | XATS2JS_gflt_print_sflt 64 | (x0) 65 | { 66 | XATS2JS_g_print(x0); 67 | return; // gint_print_sflt 68 | } 69 | function 70 | XATS2JS_gflt_print_dflt 71 | (x0) 72 | { 73 | XATS2JS_g_print(x0); 74 | return; // gint_print_dflt 75 | } 76 | /* ****** ****** */ 77 | function 78 | XATS2JS_string_print 79 | (cs) 80 | { 81 | return XATS2JS_g_print(cs); 82 | } 83 | /* ****** ****** */ 84 | 85 | function 86 | XATS2JS_the_print_store_join() 87 | { 88 | var 89 | rep = 90 | XATS2JS_the_print_store.join(""); 91 | return rep; 92 | } // XATS2JS_the_print_store_join 93 | 94 | /* ****** ****** */ 95 | 96 | function 97 | XATS2JS_the_print_store_clear() 98 | { 99 | XATS2JS_the_print_store = []; return; 100 | } // XATS2JS_the_print_store_clear 101 | 102 | /* ****** ****** */ 103 | 104 | /* end of [XATS2JS_g_print.cats] */ 105 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/g_print.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | Print for Xats2js 4 | *) 5 | (* ****** ****** *) 6 | // 7 | impltmp 8 | bool_print<> = 9 | XATS2JS_bool_print 10 | where 11 | { 12 | #extern 13 | fun 14 | XATS2JS_bool_print 15 | (b0: bool): void = $exname() 16 | } 17 | // 18 | (* ****** ****** *) 19 | // 20 | impltmp 21 | char_print<> = 22 | XATS2JS_char_print 23 | where 24 | { 25 | #extern 26 | fun 27 | XATS2JS_char_print 28 | (b0: char): void = $exname() 29 | } 30 | // 31 | (* ****** ****** *) 32 | // 33 | impltmp 34 | gint_print_sint<> = 35 | XATS2JS_gint_print_sint 36 | where 37 | { 38 | #extern 39 | fun 40 | XATS2JS_gint_print_sint 41 | ( x0: sint ): void = $exname() 42 | } 43 | // 44 | impltmp 45 | gint_print_uint<> = 46 | XATS2JS_gint_print_uint 47 | where 48 | { 49 | #extern 50 | fun 51 | XATS2JS_gint_print_uint 52 | ( x0: uint ): void = $exname() 53 | } 54 | // 55 | (* ****** ****** *) 56 | // 57 | impltmp 58 | gflt_print_sflt<> = 59 | XATS2JS_gflt_print_sflt 60 | where 61 | { 62 | #extern 63 | fun 64 | XATS2JS_gflt_print_sflt 65 | ( x0: sflt ): void = $exname() 66 | } 67 | // 68 | impltmp 69 | gflt_print_dflt<> = 70 | XATS2JS_gflt_print_dflt 71 | where 72 | { 73 | #extern 74 | fun 75 | XATS2JS_gflt_print_dflt 76 | ( x0: dflt ): void = $exname() 77 | } 78 | // 79 | (* ****** ****** *) 80 | impltmp 81 | string_print<> = 82 | XATS2JS_string_print 83 | where 84 | { 85 | #extern 86 | fun 87 | XATS2JS_string_print 88 | (cs: string): void = $exname() 89 | } 90 | (* ****** ****** *) 91 | // 92 | #extern 93 | fun 94 | XATS2JS_the_print_store_join(): string = $exname() 95 | #extern 96 | fun 97 | XATS2JS_the_print_store_clear(): (void) = $exname() 98 | // 99 | (* ****** ****** *) 100 | 101 | (* end of [XATS2JS_g_print.dats] *) 102 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/jsbasics.cats: -------------------------------------------------------------------------------- 1 | /* ****** ****** */ 2 | /* 3 | JSBasics for Xats2js 4 | */ 5 | /* ****** ****** */ 6 | function 7 | XATS2JS_jsobj_get_at 8 | (obj, key) 9 | { 10 | return obj[ key ]; 11 | } 12 | function 13 | XATS2JS_jsobj_set_at 14 | (obj, key, itm) 15 | { 16 | return (obj[key] = itm); 17 | } 18 | /* ****** ****** */ 19 | // HX-2020-11-09: 20 | // Native arrays for Xats2js 21 | /* ****** ****** */ 22 | 23 | function 24 | XATS2JS_jsarray_size 25 | ( xs ) 26 | { 27 | return ( xs.length ); 28 | } 29 | function 30 | XATS2JS_jsarray_length 31 | ( xs ) 32 | { 33 | return ( xs.length ); 34 | } 35 | 36 | /* ****** ****** */ 37 | 38 | function 39 | XATS2JS_jsarray_get_at 40 | (xs, i0) 41 | { 42 | return xs[i0]; 43 | } 44 | function 45 | XATS2JS_jsarray_set_at 46 | (xs, i0, x0) 47 | { 48 | return ( xs[i0] = x0 ); 49 | } 50 | 51 | /* ****** ****** */ 52 | // 53 | // HX-2020-11-28: 54 | // Native objmaps for Xats2js 55 | // 56 | /* ****** ****** */ 57 | 58 | function 59 | XATS2JS_jsobjmap_keys 60 | (obj) 61 | { 62 | return Object.keys(obj); 63 | } // XATS2JS_jsobjmap_keys 64 | 65 | /* ****** ****** */ 66 | 67 | function 68 | XATS2JS_jsobjmap_keyq 69 | (obj, key) 70 | { 71 | return obj.hasOwnProperty(key); 72 | } // XATS2JS_jsobjmap_keyq 73 | 74 | /* ****** ****** */ 75 | 76 | function 77 | XATS2JS_jsobjmap_make_nil 78 | () 79 | { 80 | return {} ; 81 | } // XATS2JS_jsobjmap_make_nil 82 | 83 | /* ****** ****** */ 84 | 85 | function 86 | XATS2JS_jsobjmap_search_opt 87 | (obj, key) 88 | { 89 | // 90 | let itm0 = obj[key]; 91 | // 92 | if(itm0===undefined) 93 | { 94 | return XATS2JS_optn_vt_nil(); 95 | } else { 96 | return XATS2JS_optn_vt_cons(itm0); 97 | } // end of [if] 98 | // 99 | } // [ XATS2JS_jsobjmap_search_opt ] 100 | 101 | /* ****** ****** */ 102 | 103 | function 104 | XATS2JS_jsobjmap_insert_any 105 | (obj, key, itm1) 106 | { 107 | obj[key] = itm1; return; 108 | } // [XATS2JS_jsobjmap_insert_any] 109 | 110 | function 111 | XATS2JS_jsobjmap_remove_any 112 | (obj, key) 113 | { 114 | delete object[key]; return ; 115 | } // [XATS2JS_jsobjmap_remove_any] 116 | 117 | /* ****** ****** */ 118 | 119 | function 120 | XATS2JS_jsobjmap_insert_opt 121 | (obj, key, itm1) 122 | { 123 | // 124 | let itm0 = obj[key]; 125 | // 126 | if(itm0===undefined) 127 | { 128 | obj[key] = itm1; 129 | return XATS2JS_optn_vt_nil(); 130 | } else { 131 | obj[key] = itm1; 132 | return XATS2JS_optn_vt_cons(itm0); 133 | } // end of [if] 134 | // 135 | } // [ XATS2JS_jsobjmap_insert_opt ] 136 | 137 | function 138 | XATS2JS_jsobjmap_remove_opt 139 | (obj, key) 140 | { 141 | // 142 | let itm0 = obj[key]; 143 | // 144 | if(itm0===undefined) 145 | { 146 | return XATS2JS_optn_vt_nil(); 147 | } else { 148 | delete object[key]; 149 | return XATS2JS_optn_vt_cons(itm0); 150 | } // end of [if] 151 | // 152 | } // [ XATS2JS_jsobjmap_remove_opt ] 153 | 154 | /* ****** ****** */ 155 | 156 | /* end of [XATS2JS_jsbasics.cats] */ 157 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/JS/unsafe.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** HX-2020-09: 4 | ** xats2js: 5 | ** for unsafe functions 6 | *) 7 | (* ****** ****** *) 8 | #staload 9 | UN = 10 | "prelude/SATS/unsafe.sats" 11 | (* ****** ****** *) 12 | #extern 13 | fun 14 | XATS2JS_UN_p2tr_get 15 | {a:vt} 16 | ( p0 17 | : p2tr(a)): (a) 18 | = $exname((*self*)) 19 | impltmp 20 | (*tmp*) 21 | $UN.p2tr_get = XATS2JS_UN_p2tr_get 22 | (* ****** ****** *) 23 | #extern 24 | fun 25 | XATS2JS_UN_p2tr_set 26 | {a:vt} 27 | ( p0 28 | : p2tr(a), x0: a): void 29 | = $exname((*self*)) 30 | impltmp 31 | (*tmp*) 32 | $UN.p2tr_set = XATS2JS_UN_p2tr_set 33 | (* ****** ****** *) 34 | 35 | (* end of [XATS2JS_unsafe.dats] *) 36 | -------------------------------------------------------------------------------- /prelude/DATS/CATS/Xint/.keeper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/prelude/DATS/CATS/Xint/.keeper -------------------------------------------------------------------------------- /prelude/DATS/CATS/Xint/prelude.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | HX: for pure C-arrays 4 | *) 5 | (* ****** ****** *) 6 | (* 7 | #staload 8 | "./../SATS/array.sats" 9 | *) 10 | (* ****** ****** *) 11 | #staload 12 | UN = 13 | "prelude/SATS/unsafe.sats" 14 | (* ****** ****** *) 15 | // 16 | (* 17 | // prelude/array.sats 18 | // arrays of 19 | // various dimensionality 20 | *) 21 | // 22 | (* ****** ****** *) 23 | // 24 | (* 25 | HX-2020-10-25: 26 | A C-style implementation 27 | does not work in general 28 | *) 29 | // 30 | impltmp 31 | 32 | a0ptr_make(x0) = 33 | let 34 | val A0 = 35 | a0ptr_alloc() 36 | val p0 = 37 | $UN.cast10{p2tr(a)}(A0) 38 | val () = 39 | $UN.p2tr_set(p0, x0) 40 | in 41 | $UN.castlin10{a0ptr(a)}(A0) 42 | end 43 | // 44 | (* ****** ****** *) 45 | // 46 | (* 47 | HX-2010-10-25: 48 | A C-style implementation 49 | does not work in general 50 | *) 51 | // 52 | impltmp 53 | 54 | a1ref_listize 55 | {n}(A0) = let 56 | // 57 | var 58 | res: 59 | ?list_vt(a) = 60 | list_vt_nil() 61 | val p0 = $addr(res) 62 | // 63 | val n0 = 64 | a1ref_length(A0) 65 | val n1 = pred(n0) 66 | // 67 | impltmp 68 | x1forint$work(i0) = 69 | let 70 | val j0 = n1 - i0 71 | val x0 = get_at(A0, j0) 72 | in 73 | $UN.p2tr_set_list_vt_cons(p0, x0) 74 | end 75 | // 76 | in 77 | let 78 | val () = 79 | g_x1forint(n0) in $UN.castlin10(res) 80 | end 81 | end // end of [a1ref_listize] 82 | // 83 | (* ****** ****** *) 84 | 85 | (* end of [XINTERP_prelude.dats] *) 86 | -------------------------------------------------------------------------------- /prelude/DATS/bool.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: March, 2020 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | impltmp 37 | bool_print<>(b0) = 38 | if b0 39 | then g_print("true") 40 | else g_print("false") 41 | // 42 | (* ****** ****** *) 43 | // 44 | impltmp 45 | bool_parse<>(rep) = 46 | ( 47 | case+ rep of 48 | | "false" => false 49 | (* 50 | | "False" => false 51 | | "FALSE" => false 52 | | "" => false | "0" => false 53 | | "ff" => false | "Ff" => false | "FF" => false 54 | | "nil" => false | "Nil" => false | "NIL" => false 55 | | "none" => false | "None" => false | "NONE" => false 56 | | "null" => false | "Null" => false | "NULL" => false 57 | *) 58 | | _ (* else *) => true 59 | ) 60 | // 61 | (* ****** ****** *) 62 | // 63 | impltmp 64 | (*tmp*) 65 | bool_ifval 66 | (b, x, y) = if b then x else y 67 | // 68 | (* ****** ****** *) 69 | // 70 | // HX: 71 | // For implementing 72 | // some g-operations 73 | // 74 | (* ****** ****** *) 75 | impltmp 76 | g_eqref = g_equal 77 | impltmp 78 | g_neqrf = g_noteq 79 | (* ****** ****** *) 80 | impltmp 81 | g_print = bool_print< > 82 | (* ****** ****** *) 83 | 84 | (* end of [bool.dats] *) 85 | -------------------------------------------------------------------------------- /prelude/DATS/char.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: March, 2020 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | impltmp 37 | <>(*tmp*) 38 | char_noteq 39 | (c1, c2) = 40 | ( 41 | not(char_equal(c1, c2)) 42 | ) 43 | // 44 | (* ****** ****** *) 45 | // 46 | impltmp 47 | <>(*tmp*) 48 | sub_char_char 49 | (c1, c2) = 50 | ( sint(c1) - sint(c2) ) 51 | // 52 | (* ****** ****** *) 53 | 54 | impltmp 55 | <>(*tmp*) 56 | char_lower 57 | (c0) = 58 | ( 59 | if 60 | (c0 < 'A') 61 | then c0 else 62 | ( 63 | if 64 | (c0 > 'Z') 65 | then c0 else 66 | char(sint('a')+(sint(c0)-sint('A'))) 67 | ) 68 | ) (* end of [char_lower] *) 69 | 70 | impltmp 71 | <>(*tmp*) 72 | char_upper 73 | (c0) = 74 | ( 75 | if 76 | (c0 < 'a') 77 | then c0 else 78 | ( 79 | if 80 | (c0 > 'z') 81 | then c0 else 82 | char(sint('A')+(sint(c0)-sint('a'))) 83 | ) 84 | ) (* end of [char_upper] *) 85 | 86 | (* ****** ****** *) 87 | // 88 | // HX: 89 | // For implementing 90 | // some g-operations 91 | // 92 | (* ****** ****** *) 93 | 94 | impltmp 95 | g_cmp = char_cmp<> 96 | 97 | (* ****** ****** *) 98 | 99 | impltmp 100 | g_equal = char_equal<> 101 | impltmp 102 | g_noteq = char_noteq<> 103 | 104 | (* ****** ****** *) 105 | impltmp 106 | g_eqref = g_equal 107 | impltmp 108 | g_neqrf = g_noteq 109 | (* ****** ****** *) 110 | 111 | impltmp 112 | g_print = char_print< > 113 | 114 | (* ****** ****** *) 115 | 116 | (* end of [char.dats] *) 117 | -------------------------------------------------------------------------------- /prelude/DATS/gbas.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** for generics 4 | *) 5 | (* ****** ****** *) 6 | (* 7 | #staload 8 | "./../SATS/gbas.sats" 9 | *) 10 | (* ****** ****** *) 11 | 12 | impltmp 13 | {a:vt} 14 | g_self(x) = x 15 | 16 | (* ****** ****** *) 17 | 18 | impltmp 19 | {a:t0} 20 | g_free(x) = () 21 | 22 | (* ****** ****** *) 23 | 24 | impltmp 25 | {a:t0} 26 | g_copy(x) = (x) 27 | 28 | (* ****** ****** *) 29 | // 30 | (* 31 | HX-2020-06-06: 32 | Please do see 33 | the circular beauty :) 34 | *) 35 | // 36 | (* 37 | impltmp 38 | {a:t0} 39 | g_equal 40 | (x, y) = 41 | ( 42 | not(g_noteq(x, y)) 43 | ) 44 | *) 45 | // 46 | impltmp 47 | {a:t0} 48 | g_noteq 49 | (x, y) = 50 | ( 51 | not(g_equal(x, y)) 52 | ) 53 | // 54 | (* ****** ****** *) 55 | // 56 | impltmp 57 | {a:t0} 58 | g_equal = g_eq 59 | (* 60 | impltmp 61 | {a:t0} 62 | g_noteq = g_neq 63 | *) 64 | // 65 | (* ****** ****** *) 66 | // 67 | (* 68 | impltmp 69 | {a:t0} 70 | g_eqref 71 | (x, y) = 72 | ( 73 | not(g_neqrf(x, y)) 74 | ) 75 | *) 76 | // 77 | impltmp 78 | {a:t0} 79 | g_neqrf 80 | (x, y) = 81 | ( 82 | not(g_eqref(x, y)) 83 | ) 84 | // 85 | (* ****** ****** *) 86 | // 87 | impltmp 88 | {a:vt} 89 | gl_print0(x) = 90 | ( g_free(x) ) where 91 | { 92 | val () = gl_print1(x) 93 | } (* end of [gl_print0] *) 94 | // 95 | impltmp 96 | {a:t0} 97 | gl_print1 = g_print 98 | // 99 | (* ****** ****** *) 100 | // 101 | impltmp 102 | 103 | mapoptn$fopr(x0) = 104 | if 105 | filter$test(x0) 106 | then 107 | ( 108 | optn_vt_cons(y0) 109 | ) where 110 | { 111 | val y0 = 112 | map$fopr(x0) 113 | } 114 | else 115 | ( 116 | optn_vt_nil((*void*)) 117 | ) 118 | // 119 | (* ****** ****** *) 120 | // 121 | impltmp 122 | 123 | mapoptn0$fopr(x0) = 124 | if 125 | filter1$test(x0) 126 | then 127 | ( 128 | optn_vt_cons(y0) 129 | ) where 130 | { 131 | val y0 = 132 | map0$fopr(x0) 133 | } 134 | else 135 | ( 136 | optn_vt_nil((*void*)) 137 | ) where 138 | { 139 | val () = g_free(x0) 140 | } (* end of [mapoptn0$fopr] *) 141 | // 142 | impltmp 143 | 144 | mapoptn1$fopr(x0) = 145 | if 146 | filter1$test(x0) 147 | then 148 | ( 149 | optn_vt_cons(y0) 150 | ) where 151 | { 152 | val y0 = 153 | map1$fopr(x0) 154 | } 155 | else 156 | ( 157 | optn_vt_nil((*void*)) 158 | ) (* end of [mapoptn1$fopr] *) 159 | 160 | (* ****** ****** *) 161 | (* 162 | imptmp 163 | {x0:t0} 164 | group0$test = group$test 165 | *) 166 | (* ****** ****** *) 167 | // 168 | impltmp 169 | <>(*tmp*) 170 | x2foreach_row$beg() = ((*void*)) 171 | impltmp 172 | <>(*tmp*) 173 | x2foreach_row$end() = ((*void*)) 174 | // 175 | impltmp 176 | <>(*tmp*) 177 | x2foreach_col$beg() = ((*void*)) 178 | impltmp 179 | <>(*tmp*) 180 | x2foreach_col$end() = ((*void*)) 181 | // 182 | (* ****** ****** *) 183 | 184 | (* end of [gbas.dats] *) 185 | -------------------------------------------------------------------------------- /prelude/DATS/gfor.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** For forint-loops 4 | *) 5 | (* ****** ****** *) 6 | // 7 | (* 8 | #staload 9 | "./../SATS/xfor.sats" 10 | *) 11 | // 12 | (* ****** ****** *) 13 | 14 | impltmp 15 | (*tmp*) 16 | g_x1forint 17 | ( n1 ) = 18 | loop(0, n1) where 19 | { 20 | fun 21 | loop 22 | {n1:int 23 | ;i1:nat 24 | |i1<=n1}.. 25 | ( i1:int(i1) 26 | , n1:int(n1)): void = 27 | if 28 | (i1 < n1) 29 | then 30 | ( 31 | loop(succ(i1), n1) 32 | ) where 33 | { 34 | val () = x1forint$work(i1) 35 | } 36 | else ( (* else *) ) 37 | } (* end of [g_x1forint] *) 38 | 39 | (* ****** ****** *) 40 | 41 | impltmp 42 | 43 | g_x2forint 44 | ( n1, n2 ) = 45 | let 46 | fun 47 | loop1 48 | ( i1 49 | : nintlt(n1)) = 50 | ( 51 | g_x1forint( n2 ) 52 | ) where 53 | { 54 | impltmp 55 | x1forint$work 56 | (i2) = 57 | ( 58 | x2forint$work(i1, i2) 59 | ) 60 | } 61 | in 62 | ( 63 | g_x1forint( n1 ) 64 | ) where 65 | { 66 | impltmp x1forint$work = loop1 67 | } 68 | end (* end of [x2forint] *) 69 | 70 | (* ****** ****** *) 71 | 72 | impltmp 73 | 74 | g_x3forint(n1,n2,n3) = 75 | let 76 | fun 77 | loop1 78 | ( i1 79 | : nintlt(n1)) = 80 | ( 81 | g_x2forint(n2,n3) 82 | ) where 83 | { 84 | impltmp 85 | x2forint$work 86 | (i2, i3) = 87 | ( 88 | x3forint$work(i1, i2, i3) 89 | ) 90 | } 91 | in 92 | ( 93 | g_x1forint( n1 ) 94 | ) where 95 | { 96 | impltmp x1forint$work = loop1 97 | } 98 | end (* end of [x3forint] *) 99 | 100 | (* ****** ****** *) 101 | 102 | (* end of [gfor.dats] *) 103 | -------------------------------------------------------------------------------- /prelude/DATS/gfun.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** For function ops 4 | *) 5 | (* ****** ****** *) 6 | // 7 | (* 8 | #staload 9 | "./../SATS/gfun.sats" 10 | *) 11 | // 12 | (* ****** ****** *) 13 | // 14 | impltmp 15 | 16 | gfun_not_fnp1 17 | (f0) = 18 | lam(x1) => not(f0(x1)) 19 | impltmp 20 | 21 | gfun_not_cfr1 22 | (f0) = 23 | lam(x1) => not(f0(x1)) 24 | // 25 | (* ****** ****** *) 26 | 27 | impltmp 28 | 29 | gfun_memq_gseq(xs) = 30 | lam(x0) => 31 | gseq_memberq(xs, x0) 32 | 33 | (* ****** ****** *) 34 | 35 | (* end of [gfun.dats] *) 36 | -------------------------------------------------------------------------------- /prelude/DATS/gios.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For generic ordering 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: April, 2020 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | // 40 | (* 41 | #staload 42 | "./../SATS/gios.sats" 43 | *) 44 | // 45 | (* ****** ****** *) 46 | // 47 | #staload 48 | "xatslib\ 49 | /libc/DATS/stdio.dats" 50 | // 51 | (* ****** ****** *) 52 | 53 | impltmp 54 | <>(*tmp*) 55 | g_inp_char() = 56 | fgetc_ref(g_stdin<>()) 57 | 58 | (* ****** ****** *) 59 | 60 | impltmp 61 | <>(*tmp*) 62 | g_inp_cstream() = 63 | ( 64 | auxmain(g_stdin<>()) 65 | ) where 66 | { 67 | // 68 | fun 69 | auxmain 70 | ( 71 | fr: FILEref 72 | ) : stream_vt(int) = 73 | $llazy 74 | ( 75 | let 76 | val c0 = fgetc_ref(fr) 77 | in 78 | if 79 | (c0 < 0) // EOF 80 | then 81 | strmcon_vt_nil((*void*)) 82 | else 83 | strmcon_vt_cons(c0, auxmain(fr)) 84 | end // end of [let] 85 | ) 86 | // 87 | } (* end of [g_inp_chars] *) 88 | 89 | (* ****** ****** *) 90 | // 91 | impltmp 92 | <>(*tmp*) 93 | g_inp_line_list() = 94 | list_vt2t{char}(g_inp_lline_list<>()) 95 | // 96 | (* ****** ****** *) 97 | 98 | impltmp 99 | <>(*tmp*) 100 | g_inp_lline_list() = 101 | let 102 | // 103 | val EOL = '\n' 104 | // 105 | fun 106 | loop 107 | ( cs 108 | : list_vt(char)): list_vt(char) = 109 | let 110 | val c0 = g_inp_char<>() 111 | in 112 | if 113 | (c0 >= 0) 114 | then 115 | let 116 | val c0 = char(c0) 117 | in 118 | if 119 | (c0 = EOL) 120 | then cs else loop(list_vt_cons(c0, cs)) 121 | end 122 | else cs // end of [else] 123 | end 124 | // 125 | in 126 | list_vt_reverse(loop(list_vt_nil())) 127 | end // end of [g_inp_lline_list] 128 | 129 | (* ****** ****** *) 130 | 131 | (* end of [gios.dats] *) 132 | -------------------------------------------------------------------------------- /prelude/DATS/gmap.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | // 4 | // HX-2020-12-04: 5 | // For gmap-operations 6 | // 7 | *) 8 | (* ****** ****** *) 9 | 10 | #staload 11 | UN = 12 | "prelude/SATS/unsafe.sats" 13 | 14 | (* ****** ****** *) 15 | 16 | (* 17 | impltmp 18 | 19 | 20 | 21 | gmap_print(kxs) = 22 | stream_vt_print_all 23 | ( 24 | gmap_streamize(kxs) 25 | ) (* end of [gmap_print] *) 26 | *) 27 | impltmp 28 | 29 | 30 | 31 | gmap_print(kxs) = 32 | let 33 | fun 34 | loop(kxs): void = 35 | ( 36 | case+ !kxs of 37 | | ~ 38 | strmcon_vt_nil() => () 39 | | ~ 40 | strmcon_vt_cons(kx1, kxs) => 41 | ( 42 | print 43 | (kx1.0, " = ", kx1.1); loop(kxs) 44 | ) 45 | ) (* end of [loop] *) 46 | in 47 | loop 48 | (gmap_streamize(kxs)) 49 | end // end of [gmap_print] 50 | 51 | (* ****** ****** *) 52 | // 53 | impltmp 54 | 55 | 56 | 57 | gmap_streamize_key(kxs) = 58 | let 59 | impltmp 60 | map0$fopr 61 | <(key,itm)>(kx) = kx.0 62 | in 63 | stream_vt_map0(gmap_streamize(kxs)) 64 | end // end of [gmap_streamize_key] 65 | // 66 | (* ****** ****** *) 67 | // 68 | impltmp 69 | 70 | 71 | 72 | gmap_streamize_itm(kxs) = 73 | let 74 | impltmp 75 | map0$fopr 76 | <(key,itm)>(kx) = kx.1 77 | in 78 | stream_vt_map0(gmap_streamize(kxs)) 79 | end // end of [gmap_streamize_itm] 80 | // 81 | (* ****** ****** *) 82 | 83 | (* end of [gmap.dats] *) 84 | -------------------------------------------------------------------------------- /prelude/DATS/gnum.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** for generics 4 | *) 5 | (* ****** ****** *) 6 | (* 7 | #staload 8 | "./../SATS/gnum.sats" 9 | *) 10 | (* ****** ****** *) 11 | 12 | impltmp 13 | {a:t0} 14 | g_0() = g_i(0) 15 | impltmp 16 | {a:t0} 17 | g_1() = g_i(1) 18 | impltmp 19 | {a:t0} 20 | g_2() = g_i(2) 21 | 22 | (* ****** ****** *) 23 | 24 | impltmp 25 | {a:t0} 26 | g_succ(x) = g_add(x, g_1()) 27 | impltmp 28 | {a:t0} 29 | g_pred(x) = g_sub(x, g_1()) 30 | 31 | (* ****** ****** *) 32 | // 33 | // HX: 34 | // For linear gnums 35 | // 36 | (* ****** ****** *) 37 | 38 | impltmp 39 | {a:t0} 40 | gl_add00(x, y) = g_add(x, y) 41 | impltmp 42 | {a:t0} 43 | gl_add11(x, y) = g_add(x, y) 44 | 45 | (* ****** ****** *) 46 | 47 | impltmp 48 | {a:t0} 49 | gl_sub00(x, y) = g_sub(x, y) 50 | impltmp 51 | {a:t0} 52 | gl_sub11(x, y) = g_sub(x, y) 53 | 54 | (* ****** ****** *) 55 | 56 | impltmp 57 | {a:t0} 58 | gl_mul00(x, y) = g_mul(x, y) 59 | impltmp 60 | {a:t0} 61 | gl_mul11(x, y) = g_mul(x, y) 62 | 63 | (* ****** ****** *) 64 | 65 | impltmp 66 | {a:t0} 67 | gl_div00(x, y) = g_div(x, y) 68 | impltmp 69 | {a:t0} 70 | gl_div11(x, y) = g_div(x, y) 71 | 72 | (* ****** ****** *) 73 | 74 | impltmp 75 | {a:t0} 76 | gl_mod00(x, y) = g_mod(x, y) 77 | impltmp 78 | {a:t0} 79 | gl_mod11(x, y) = g_mod(x, y) 80 | 81 | (* ****** ****** *) 82 | 83 | (* end of [gnum.dats] *) 84 | -------------------------------------------------------------------------------- /prelude/DATS/gord.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** for generics 4 | *) 5 | (* ****** ****** *) 6 | (* 7 | #staload 8 | "./../SATS/gord.sats" 9 | *) 10 | (* ****** ****** *) 11 | 12 | impltmp 13 | {a:t0} 14 | g_eq(x, y) = 15 | (g_cmp(x, y) = 0) 16 | impltmp 17 | {a:t0} 18 | g_lt(x, y) = 19 | (g_cmp(x, y) < 0) 20 | impltmp 21 | {a:t0} 22 | g_gt(x, y) = 23 | (g_cmp(x, y) > 0) 24 | impltmp 25 | {a:t0} 26 | g_lte(x, y) = 27 | (g_cmp(x, y) <= 0) 28 | impltmp 29 | {a:t0} 30 | g_gte(x, y) = 31 | (g_cmp(x, y) >= 0) 32 | impltmp 33 | {a:t0} 34 | g_neq(x, y) = 35 | (g_cmp(x, y) != 0) 36 | 37 | (* ****** ****** *) 38 | // 39 | impltmp 40 | {a:t0} 41 | g_ltz(x) = (g_cmpz(x) < 0) 42 | impltmp 43 | {a:t0} 44 | g_gtz(x) = (g_cmpz(x) > 0) 45 | impltmp 46 | {a:t0} 47 | g_eqz(x) = (g_cmpz(x) = 0) 48 | // 49 | impltmp 50 | {a:t0} 51 | g_ltez(x) = (g_cmpz(x) <= 0) 52 | impltmp 53 | {a:t0} 54 | g_gtez(x) = (g_cmpz(x) >= 0) 55 | impltmp 56 | {a:t0} 57 | g_neqz(x) = (g_cmpz(x) != 0) 58 | 59 | (* ****** ****** *) 60 | // 61 | impltmp 62 | {a:t0} 63 | g_cmpz(x) = (g_cmp(x, g_0())) 64 | // 65 | (* ****** ****** *) 66 | 67 | impltmp 68 | {a:t0} 69 | g_max(x, y) = 70 | if g_gte(x, y) then (x) else (y) 71 | impltmp 72 | {a:t0} 73 | g_min(x, y) = 74 | if g_lte(x, y) then (x) else (y) 75 | 76 | (* ****** ****** *) 77 | // 78 | // HX: 79 | // For linear gords 80 | // 81 | (* ****** ****** *) 82 | 83 | impltmp 84 | {a:t0} 85 | gl_eq00 = g_eq 86 | impltmp 87 | {a:t0} 88 | gl_eq11 = g_eq 89 | 90 | (* ****** ****** *) 91 | 92 | impltmp 93 | {a:t0} 94 | gl_lt00 = g_lt 95 | impltmp 96 | {a:t0} 97 | gl_lt11 = g_lt 98 | impltmp 99 | {a:t0} 100 | gl_gt00 = g_gt 101 | impltmp 102 | {a:t0} 103 | gl_gt11 = g_gt 104 | 105 | (* ****** ****** *) 106 | 107 | impltmp 108 | {a:t0} 109 | gl_lte00 = g_lte 110 | impltmp 111 | {a:t0} 112 | gl_lte11 = g_lte 113 | impltmp 114 | {a:t0} 115 | gl_gte00 = g_gte 116 | impltmp 117 | {a:t0} 118 | gl_gte11 = g_gte 119 | 120 | (* ****** ****** *) 121 | 122 | impltmp 123 | {a:t0} 124 | gl_cmp00 = g_cmp 125 | impltmp 126 | {a:t0} 127 | gl_cmp11 = g_cmp 128 | 129 | (* ****** ****** *) 130 | 131 | impltmp 132 | {a:t0} 133 | gl_max00 = g_max 134 | impltmp 135 | {a:t0} 136 | gl_max11 = g_max 137 | impltmp 138 | {a:t0} 139 | gl_min00 = g_min 140 | impltmp 141 | {a:t0} 142 | gl_min11 = g_min 143 | 144 | (* ****** ****** *) 145 | 146 | impltmp 147 | {a:vt} 148 | gl_eq00(x, y) = 149 | (gl_cmp00(x, y) = 0) 150 | impltmp 151 | {a:vt} 152 | gl_neq00(x, y) = 153 | (gl_cmp00(x, y) != 0) 154 | 155 | (* ****** ****** *) 156 | 157 | impltmp 158 | {a:vt} 159 | gl_lt00(x, y) = 160 | (gl_cmp00(x, y) < 0) 161 | impltmp 162 | {a:vt} 163 | gl_gt00(x, y) = 164 | (gl_cmp00(x, y) > 0) 165 | 166 | (* ****** ****** *) 167 | 168 | impltmp 169 | {a:vt} 170 | gl_lte00(x, y) = 171 | (gl_cmp00(x, y) <= 0) 172 | impltmp 173 | {a:vt} 174 | gl_gte00(x, y) = 175 | (gl_cmp00(x, y) >= 0) 176 | 177 | (* ****** ****** *) 178 | 179 | impltmp 180 | {a:vt} 181 | gl_max11(x, y) = 182 | if 183 | (gl_gte11(x, y)) 184 | then g_copy(x) else g_copy(y) 185 | impltmp 186 | {a:vt} 187 | gl_min11(x, y) = 188 | if 189 | (gl_lte11(x, y)) 190 | then g_copy(x) else g_copy(y) 191 | 192 | (* ****** ****** *) 193 | 194 | (* end of [gord.dats] *) 195 | -------------------------------------------------------------------------------- /prelude/DATS/gseqn.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | // 3 | (* 4 | #staload 5 | "./../SATS/gseqn.sats" 6 | *) 7 | // 8 | (* ****** ****** *) 9 | 10 | #staload 11 | "prelude/SATS/gseqn.sats" 12 | #staload 13 | UN = 14 | "prelude/SATS/unsafe.sats" 15 | 16 | (* ****** ****** *) 17 | 18 | impltmp 19 | 20 | gseqn_nilq(xs) = 21 | let 22 | val ln = 23 | gseqn_length 24 | (xs) in ln = 0 25 | end // end of [gseqn_nilq] 26 | 27 | (* ****** ****** *) 28 | 29 | impltmp 30 | 31 | gseqn_consq(xs) = 32 | bool_neg<> 33 | (gseqn_nilq(xs)) 34 | 35 | (* ****** ****** *) 36 | 37 | (* end of [gseqn.dats] *) 38 | -------------------------------------------------------------------------------- /prelude/DATS/optn.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** for opts 4 | *) 5 | (* ****** ****** *) 6 | 7 | (* 8 | #staload 9 | "./../SATS/optn.sats" 10 | *) 11 | 12 | (* ****** ****** *) 13 | // 14 | impltmp 15 | <>(*tmp*) 16 | optn_nil_ 17 | () = optn_nil() 18 | impltmp 19 | (*tmp*) 20 | optn_cons_ 21 | (x0) = optn_cons(x0) 22 | // 23 | (* ****** ****** *) 24 | // 25 | impltmp 26 | <>(*tmp*) 27 | optn_nilq(xs) = 28 | ( 29 | case+ xs of 30 | | optn_nil() => true 31 | | optn_cons(x0) => false 32 | ) 33 | impltmp 34 | <>(*tmp*) 35 | optn_consq(xs) = 36 | ( 37 | case+ xs of 38 | | optn_nil() => false 39 | | optn_cons(x0) => (true) 40 | ) 41 | // 42 | (* ****** ****** *) 43 | // 44 | impltmp 45 | (*tmp*) 46 | optn_length(xs) = 47 | ( 48 | case+ xs of 49 | | none() => 0 | some(x0) => 1 50 | ) 51 | // 52 | (* ****** ****** *) 53 | // 54 | impltmp 55 | (*tmp*) 56 | optn_forall(xs) = 57 | ( 58 | case+ xs of 59 | | optn_nil() => true 60 | | optn_cons(x0) => forall$test(x0) 61 | ) 62 | // 63 | impltmp 64 | (*tmp*) 65 | optn_foreach(xs) = 66 | ( 67 | case+ xs of 68 | | optn_nil() => () 69 | | optn_cons(x0) => foreach$work(x0) 70 | ) 71 | // 72 | impltmp 73 | (*tmp*) 74 | optn_rforall(xs) = 75 | ( 76 | case+ xs of 77 | | optn_nil() => true 78 | | optn_cons(x0) => rforall$test(x0) 79 | ) 80 | // 81 | (* ****** ****** *) 82 | 83 | impltmp 84 | (*tmp*) 85 | optn_listize(xs) = 86 | ( 87 | case+ xs of 88 | | optn_nil() => list_vt_nil() 89 | | optn_cons(x0) => list_vt_sing(x0) 90 | ) 91 | impltmp 92 | (*tmp*) 93 | optn_rlistize(xs) = 94 | ( 95 | case+ xs of 96 | | optn_nil() => list_vt_nil() 97 | | optn_cons(x0) => list_vt_sing(x0) 98 | ) 99 | impltmp 100 | (*tmp*) 101 | optn_streamize(xs) = 102 | $llazy 103 | ( 104 | case+ xs of 105 | | optn_nil() => strmcon_vt_nil() 106 | | optn_cons(x0) => strmcon_vt_sing(x0) 107 | ) 108 | 109 | (* ****** ****** *) 110 | 111 | impltmp 112 | 113 | optn_map(xs) = 114 | ( 115 | optn_vt2t(optn_map_vt(xs)) 116 | ) 117 | // 118 | impltmp 119 | 120 | optn_map_vt(xs) = 121 | ( 122 | case+ xs of 123 | | 124 | optn_nil() => 125 | optn_vt_nil() 126 | | 127 | optn_cons(x0) => 128 | optn_vt_cons(map$fopr(x0)) 129 | ) (* end of [optn_map_vt] *) 130 | 131 | (* ****** ****** *) 132 | 133 | impltmp 134 | (*tmp*) 135 | optn_copy_vt(xs) = 136 | ( 137 | case+ xs of 138 | | optn_nil() => optn_vt_nil() 139 | | optn_cons(x0) => optn_vt_cons(x0) 140 | ) (* end of [optn_copy_vt] *) 141 | 142 | (* ****** ****** *) 143 | // 144 | // For gseq-operations 145 | // 146 | (* ****** ****** *) 147 | // 148 | impltmp 149 | {a:t0} 150 | g_print = 151 | gseq_print 152 | // 153 | impltmp 154 | {a:t0} 155 | gseq_print$beg 156 | () = string_print("(") 157 | impltmp 158 | {a:t0} 159 | gseq_print$end 160 | () = string_print(")") 161 | (* 162 | impltmp 163 | {a:t0} 164 | gseq_print$sep 165 | () = string_print(";") 166 | *) 167 | // 168 | (* ****** ****** *) 169 | 170 | impltmp 171 | {a:t0} 172 | gseq_forall = optn_forall 173 | impltmp 174 | {a:t0} 175 | gseq_foreach = optn_foreach 176 | impltmp 177 | {a:t0} 178 | gseq_rforall = optn_rforall 179 | impltmp 180 | {a:t0} 181 | gseq_rforeach = optn_rforeach 182 | 183 | (* ****** ****** *) 184 | 185 | (* end of [optn.dats] *) 186 | -------------------------------------------------------------------------------- /prelude/DATS/optn_vt.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** for opts_vt 4 | *) 5 | (* ****** ****** *) 6 | 7 | (* 8 | #staload 9 | "./../SATS/optn.sats" 10 | *) 11 | 12 | (* ****** ****** *) 13 | // 14 | impltmp 15 | <>(*tmp*) 16 | optn_vt_nilq(xs) = 17 | ( 18 | case+ xs of 19 | | ! 20 | optn_vt_nil() => true 21 | | ! 22 | optn_vt_cons(x0) => false 23 | ) 24 | // 25 | impltmp 26 | <>(*tmp*) 27 | optn_vt_consq(xs) = 28 | ( 29 | case+ xs of 30 | | ! 31 | optn_vt_nil() => false 32 | | ! 33 | optn_vt_cons(x0) => (true) 34 | ) 35 | // 36 | impltmp 37 | {a:vt} 38 | g_free 39 | = optn_vt_free 40 | // 41 | (* ****** ****** *) 42 | // 43 | impltmp 44 | (*tmp*) 45 | optn_vt_free(xs) = 46 | ( 47 | case+ xs of 48 | | ~ 49 | optn_vt_nil() => () 50 | | ~ 51 | optn_vt_cons(x0) => g_free(x0) 52 | ) 53 | // 54 | (* ****** ****** *) 55 | 56 | impltmp 57 | (*tmp*) 58 | optn_vt_copy(xs) = 59 | ( 60 | case+ xs of 61 | | ! 62 | optn_vt_nil() => 63 | optn_vt_nil() 64 | | ! 65 | optn_vt_cons(x0) => 66 | let 67 | val x0 = 68 | g_copy(x0) in optn_vt_cons(x0) 69 | end 70 | ) (* end of [optn_vt_copy] *) 71 | 72 | (* ****** ****** *) 73 | // 74 | impltmp 75 | (*tmp*) 76 | optn_vt_length(xs) = 77 | ( 78 | case+ xs of 79 | | !none_vt() => 0 | !some_vt(x0) => 1 80 | ) 81 | // 82 | (* ****** ****** *) 83 | 84 | impltmp 85 | (*tmp*) 86 | optn_vt_forall0(xs) = 87 | ( 88 | case+ xs of 89 | | ~optn_vt_nil() => true 90 | | ~optn_vt_cons(x0) => forall0$test(x0) 91 | ) (* end of [glseq_forall0] *) 92 | impltmp 93 | (*tmp*) 94 | optn_vt_forall1(xs) = 95 | ( 96 | case+ xs of 97 | | !optn_vt_nil() => true 98 | | !optn_vt_cons(x0) => forall1$test(x0) 99 | ) (* end of [glseq_forall1] *) 100 | 101 | (* ****** ****** *) 102 | 103 | impltmp 104 | (*tmp*) 105 | optn_vt_foreach0(xs) = 106 | ( 107 | case+ xs of 108 | | ~optn_vt_nil() => () 109 | | ~optn_vt_cons(x0) => foreach0$work(x0) 110 | ) (* end of [glseq_foreach0] *) 111 | impltmp 112 | (*tmp*) 113 | optn_vt_foreach1(xs) = 114 | ( 115 | case+ xs of 116 | | !optn_vt_nil() => () 117 | | !optn_vt_cons(x0) => foreach1$work(x0) 118 | ) (* end of [glseq_foreach1] *) 119 | 120 | (* ****** ****** *) 121 | 122 | impltmp 123 | (*tmp*) 124 | optn_vt_listize0(xs) = 125 | ( 126 | case+ xs of 127 | | ~ 128 | optn_vt_nil() => list_vt_nil() 129 | | ~ 130 | optn_vt_cons(x0) => list_vt_sing(x0) 131 | ) 132 | impltmp 133 | (*tmp*) 134 | optn_vt_rlistize0(xs) = 135 | ( 136 | case+ xs of 137 | | ~ 138 | optn_vt_nil() => list_vt_nil() 139 | | ~ 140 | optn_vt_cons(x0) => list_vt_sing(x0) 141 | ) 142 | impltmp 143 | (*tmp*) 144 | optn_vt_streamize(xs) = 145 | $llazy 146 | ( 147 | g_free(xs); 148 | case+ xs of 149 | | ~ 150 | optn_vt_nil() => strmcon_vt_nil() 151 | | ~ 152 | optn_vt_cons(x0) => strmcon_vt_sing(x0) 153 | ) 154 | 155 | (* ****** ****** *) 156 | // 157 | // For gseq-operations 158 | // 159 | (* ****** ****** *) 160 | // 161 | impltmp 162 | {a:vt} 163 | gl_print1 = 164 | glseq_print1 165 | // 166 | impltmp 167 | {a:vt} 168 | glseq_print$beg 169 | () = string_print("(") 170 | impltmp 171 | {a:vt} 172 | glseq_print$end 173 | () = string_print(")") 174 | (* 175 | impltmp 176 | {a:vt} 177 | gseq_print$sep 178 | () = string_print(";") 179 | *) 180 | // 181 | (* ****** ****** *) 182 | 183 | impltmp 184 | {a:vt} 185 | glseq_forall0 = optn_vt_forall0 186 | impltmp 187 | {a:vt} 188 | glseq_forall1 = optn_vt_forall1 189 | 190 | (* ****** ****** *) 191 | impltmp 192 | {a:vt} 193 | glseq_listize0 = optn_vt_listize0 194 | impltmp 195 | {a:vt} 196 | glseq_rlistize0 = optn_vt_rlistize0 197 | impltmp 198 | {a:vt} 199 | glseq_streamize = optn_vt_streamize 200 | (* ****** ****** *) 201 | 202 | (* end of [optn_vt.dats] *) 203 | -------------------------------------------------------------------------------- /prelude/DATS/tuple.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** for tuples 4 | *) 5 | (* ****** ****** *) 6 | vwtpdef 7 | t0up2 8 | (a0:vt,a1:vt) = @(a0, a1) 9 | vwtpdef 10 | t1up2 11 | (a0:vt,a1:vt) = $(a0, a1) 12 | (* ****** ****** *) 13 | vwtpdef 14 | t0up3 15 | (a0:vt 16 | ,a1:vt,a2:vt) = @(a0, a1, a2) 17 | vwtpdef 18 | t1up3 19 | (a0:vt 20 | ,a1:vt,a2:vt) = $(a0, a1, a2) 21 | (* ****** ****** *) 22 | #extern 23 | fun<> 24 | t0up_print$beg(): void 25 | #extern 26 | fun<> 27 | t1up_print$beg(): void 28 | impltmp<> 29 | t0up_print$beg()=string_print("@(") 30 | impltmp<> 31 | t1up_print$beg()=string_print("$(") 32 | (* ****** ****** *) 33 | #extern 34 | fun<> 35 | t0up_print$end(): void 36 | #extern 37 | fun<> 38 | t1up_print$end(): void 39 | impltmp<> 40 | t0up_print$end() = string_print(")") 41 | impltmp<> 42 | t1up_print$end() = string_print(")") 43 | (* ****** ****** *) 44 | #extern 45 | fun<> 46 | t0up_print$sep(): void 47 | #extern 48 | fun<> 49 | t1up_print$sep(): void 50 | impltmp<> 51 | t0up_print$sep() = string_print(",") 52 | impltmp<> 53 | t1up_print$sep() = string_print(",") 54 | (* ****** ****** *) 55 | // 56 | impltmp 57 | {a0:t0 58 | ,a1:t0} 59 | g_print 60 | <(a0,a1)> = 61 | gl_print1 62 | // 63 | impltmp 64 | {a0:vt 65 | ,a1:vt} 66 | gl_print1 67 | < 68 | t0up2 69 | (a0,a1)>(t2) = 70 | let 71 | val () = t0up_print$beg() 72 | val () = gl_print1(t2.0) 73 | val () = t0up_print$sep() 74 | val () = gl_print1(t2.1) 75 | val () = t0up_print$end() 76 | end // end of [gl_print1] 77 | // 78 | (* ****** ****** *) 79 | 80 | impltmp 81 | {a0:vt 82 | ,a1:vt} 83 | gl_print1 84 | < 85 | t1up2 86 | (a0,a1)>(t2) = 87 | let 88 | val () = t1up_print$beg() 89 | val () = gl_print1(t2.0) 90 | val () = t1up_print$sep() 91 | val () = gl_print1(t2.1) 92 | val () = t1up_print$end() 93 | end // end of [gl_print1] 94 | 95 | (* ****** ****** *) 96 | // 97 | impltmp 98 | {a0:t0 99 | ,a1:t0 100 | ,a2:t0} 101 | g_print 102 | <(a0,a1,a2)> = 103 | gl_print1 104 | // 105 | impltmp 106 | {a0:vt 107 | ,a1:vt 108 | ,a2:vt} 109 | gl_print1 110 | < 111 | t0up3 112 | (a0,a1,a2)>(t3) = 113 | let 114 | val () = t0up_print$beg() 115 | val () = gl_print1(t3.0) 116 | val () = t0up_print$sep() 117 | val () = gl_print1(t3.1) 118 | val () = t0up_print$end() 119 | end // end of [gl_print1] 120 | // 121 | (* ****** ****** *) 122 | 123 | impltmp 124 | {a0:vt 125 | ,a1:vt 126 | ,a2:vt} 127 | gl_print1 128 | < 129 | t1up3 130 | (a0,a1,a2)>(t3) = 131 | let 132 | val () = t1up_print$beg() 133 | val () = gl_print1(t3.0) 134 | val () = t1up_print$sep() 135 | val () = gl_print1(t3.1) 136 | val () = t1up_print$end() 137 | end // end of [gl_print1] 138 | 139 | (* ****** ****** *) 140 | 141 | (* end of [tuple.dats] *) 142 | -------------------------------------------------------------------------------- /prelude/DATS/unsafe.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** HX-2020-02: 4 | ** for unsafe functions 5 | *) 6 | (* ****** ****** *) 7 | 8 | #staload 9 | UN = 10 | "prelude/SATS/unsafe.sats" 11 | 12 | (* ****** ****** *) 13 | // 14 | impltmp 15 | (*tmp*) 16 | $UN.p2tr_get 17 | (p0) = $eval(p0) 18 | impltmp 19 | (*tmp*) 20 | $UN.p2tr_set 21 | (p0, x0) = $eval(p0) := x0 22 | // 23 | impltmp 24 | (*tmp*) 25 | $UN.p2tr_ret 26 | (p0, x0) = 27 | let 28 | val x0 = $UN.delinear(x0) in () 29 | end 30 | // 31 | (* ****** ****** *) 32 | // 33 | impltmp 34 | (*tmp*) 35 | $UN.p2tr_set_list_nil 36 | (p0) = 37 | ( 38 | $UN.p2tr_set 39 | (p0, list_nil()) 40 | ) 41 | // 42 | impltmp 43 | (*tmp*) 44 | $UN.p2tr_set_list_cons 45 | (p0, x0) = 46 | let 47 | typedef 48 | xs = list(a) 49 | val xs = 50 | $UN.p2tr_get(p0) 51 | in 52 | $UN.p2tr_set(p0, list_cons(x0, xs)) 53 | end 54 | // 55 | (* ****** ****** *) 56 | // 57 | impltmp 58 | (*tmp*) 59 | $UN.p2tr_set_list_vt_nil 60 | (p0) = 61 | ( 62 | $UN.p2tr_set 63 | (p0, list_vt_nil()) 64 | ) 65 | impltmp 66 | (*tmp*) 67 | $UN.p2tr_set_list_vt_cons 68 | (p0, x0) = 69 | let 70 | typedef 71 | xs = list_vt(a) 72 | val xs = 73 | $UN.p2tr_get(p0) 74 | in 75 | $UN.p2tr_set(p0, list_vt_cons(x0, xs)) 76 | end 77 | // 78 | (* ****** ****** *) 79 | 80 | (* end of [unsafe.dats] *) 81 | -------------------------------------------------------------------------------- /prelude/SATS/CC/array.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For pure arrays in C 31 | // 32 | (* ****** ****** *) 33 | // 34 | praxi 35 | array_view_nil : 36 | {a:vt} 37 | {l:a0} 38 | ((*void*)) - arrvw(a,l,0) 39 | // 40 | praxi 41 | array_view_cons 42 | {a:vt} 43 | {l:a0} 44 | {n:i0} 45 | ( pf1 46 | : a @ l 47 | , pf2 48 | : arrvw(a,l+sz(a),n)): arrvw(a,l,n+1) 49 | // 50 | praxi 51 | array_view_uncons : 52 | {a:vt} 53 | {l:a0} 54 | {n:i0|n > 0} 55 | ( 56 | ! arrvw(a,l,n) >> 57 | arrvw(a,l+sz(a),n-1)) - (a @ l) 58 | // 59 | (* ****** ****** *) 60 | 61 | #symload nil with array_view_cons 62 | #symload cons with array_view_cons 63 | #symload uncons with array_view_uncons 64 | 65 | (* ****** ****** *) 66 | prfun 67 | array_view_split_at 68 | {a:vt} 69 | {l:a0} 70 | {n:i0}{i:nat|i<=n} 71 | ( A0: 72 | arrvw(a,l,n) | i0: int(i) ) 73 | : 74 | ( 75 | arrvw(a,l,i), arrvw(a,l+i*sz(a),n-i) 76 | ) (* end of [array_v_split_at] *) 77 | (* ****** ****** *) 78 | prfun 79 | array_view_unsplit 80 | {a:vt} 81 | {l:a0} 82 | {n1:i0 83 | ;n2:i0} 84 | ( pf1 85 | : arrvw(a,l, n1) 86 | , pf2 87 | : arrvw(a,l+n1*sz(a),n2)): arrvw(a,l,n1+n2) 88 | (* ****** ****** *) 89 | 90 | (* end of [CC/array.sats] 91 | -------------------------------------------------------------------------------- /prelude/SATS/bool.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For booleans 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: March, 2020 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | // 40 | fun<> 41 | bool_neg 42 | {b:bool} 43 | (x: bool(b)): bool(~b) 44 | // 45 | (* ****** ****** *) 46 | // 47 | fun<> 48 | bool_add 49 | {b1,b2:bool} 50 | ( x: bool(b1) 51 | , y: bool(b2)): bool(b1+b2) 52 | fun<> 53 | bool_mul 54 | {b1,b2:bool} 55 | ( x: bool(b1) 56 | , y: bool(b2)): bool(b1*b2) 57 | // 58 | (* ****** ****** *) 59 | 60 | fun<> 61 | bool_print(bool): void 62 | fun<> 63 | bool_parse(string): bool 64 | 65 | (* ****** ****** *) 66 | // 67 | fun 68 | 69 | bool_ifval 70 | {b:b0} 71 | (b: bool(b), x: a, y: a): a 72 | // 73 | (* ****** ****** *) 74 | // 75 | // HX-2020-05-30: 76 | // symbol overloading for bool 77 | // 78 | (* ****** ****** *) 79 | // 80 | #symload 81 | ~ with bool_neg of 1000 82 | #symload 83 | neg with bool_neg of 1000 84 | #symload 85 | not with bool_neg of 1000 86 | // 87 | (* ****** ****** *) 88 | // 89 | #symload + with bool_add of 1000 90 | #symload * with bool_mul of 1000 91 | // 92 | (* ****** ****** *) 93 | // 94 | #symload print with bool_print of 1000 95 | // 96 | (* ****** ****** *) 97 | #symload ifval with bool_ifval of 1000 98 | (* ****** ****** *) 99 | 100 | (* end of [bool.sats] *) 101 | -------------------------------------------------------------------------------- /prelude/SATS/char.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For characters 31 | // that is, sint8 and uint8 32 | // 33 | (* ****** ****** *) 34 | // 35 | // Author: Hongwei Xi 36 | // Start Time: March, 2020 37 | // Authoremail: gmhwxiATgmailDOTcom 38 | // 39 | (* ****** ****** *) 40 | // 41 | fun<> 42 | char_make_sint 43 | (code: sint): char 44 | fun<> 45 | char_make_uint 46 | (code: uint): char 47 | // 48 | (* ****** ****** *) 49 | // 50 | fun<> 51 | sint_make_char 52 | (char: char): sint 53 | // 54 | (* ****** ****** *) 55 | fun<> 56 | char_print(char): void 57 | (* ****** ****** *) 58 | // 59 | fun<> 60 | char_eqzq 61 | {c:char} 62 | (c0: char(c)): bool(c=0) 63 | fun<> 64 | char_neqzq 65 | {c:char} 66 | (c0: char(c)): bool(c>0) 67 | // 68 | fun<> 69 | char_equal 70 | {c1,c2:char} 71 | ( c1: char(c1) 72 | , c2: char(c2)): bool(c1=c2) 73 | fun<> 74 | char_noteq 75 | {c1,c2:char} 76 | ( c1: char(c1) 77 | , c2: char(c2)): bool(c1!=c2) 78 | // 79 | (* ****** ****** *) 80 | 81 | fun<> 82 | sub_char_char 83 | {c1,c2:char} 84 | ( c1: char(c1) 85 | , c2: char(c2)): sint(c1 - c2) 86 | 87 | (* ****** ****** *) 88 | fun<> 89 | char_cmp 90 | {c1,c2:char} 91 | ( c1: char(c1) 92 | , c2: char(c2)): sint(sgn(c1-c2)) 93 | (* ****** ****** *) 94 | // 95 | fun<> 96 | char_lower(c0: char): char 97 | fun<> 98 | char_upper(c0: char): char 99 | // 100 | (* ****** ****** *) 101 | // 102 | // HX-2020-05-30: 103 | // symbol overloading for char 104 | // 105 | (* ****** ****** *) 106 | #symload 107 | - with sub_char_char of 1000 108 | (* ****** ****** *) 109 | // 110 | #symload 111 | char with char_make_sint of 1000 112 | #symload 113 | char with char_make_uint of 1000 114 | // 115 | (* ****** ****** *) 116 | // 117 | #symload 118 | sint with sint_make_char of 1000 119 | // 120 | (* ****** ****** *) 121 | // 122 | #symload print with char_print of 1000 123 | // 124 | (* ****** ****** *) 125 | 126 | (* end of [char.sats] *) 127 | -------------------------------------------------------------------------------- /prelude/SATS/gfor.sats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** For forint-loops 4 | *) 5 | (* ****** ****** *) 6 | // 7 | fun 8 | 9 | g_x1forint 10 | (n1: int(n1)): void 11 | fun 12 | 13 | x1forint$work 14 | (i1: nintlt(n1)): void 15 | // 16 | (* ****** ****** *) 17 | // 18 | fun 19 | 21 | g_x2forint 22 | ( n1: int(n1), n2: int(n2)): void 23 | fun 24 | 26 | x2forint$work 27 | ( i1: nintlt(n1), i2: nintlt(n2)): void 28 | // 29 | (* ****** ****** *) 30 | // 31 | fun 32 | 35 | g_x3forint 36 | ( n1: int(n1) 37 | , n2: int(n2), n3: int(n3)): void 38 | fun 39 | 42 | x3forint$work 43 | ( i1: nintlt(n1) 44 | , i2: nintlt(n2), i3: nintlt(n3)): void 45 | // 46 | (* ****** ****** *) 47 | 48 | (* end of [gfor.sats] *) 49 | -------------------------------------------------------------------------------- /prelude/SATS/gfun.sats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** For function ops 4 | *) 5 | (* ****** ****** *) 6 | 7 | typedef 8 | fnp1(a1:vt,r0:vt) = (a1)-r0 9 | typedef 10 | cfr1(a1:vt,r0:vt) = (a1)-r0 11 | 12 | (* ****** ****** *) 13 | 14 | fun 15 | 16 | gfun_not_fnp1 17 | ( f0 18 | : fnp1(a1,bool)): cfr1(a1,bool) 19 | fun 20 | 21 | gfun_not_cfr1 22 | ( f0 23 | : cfr1(a1,bool)): cfr1(a1,bool) 24 | 25 | (* ****** ****** *) 26 | 27 | #symload fnot with gfun_not_fnp1 of 0100 28 | #symload fnot with gfun_not_cfr1 of 0100 29 | 30 | (* ****** ****** *) 31 | 32 | fun 33 | 34 | 35 | gfun_memq_gseq(xs): cfr1(x0,bool) 36 | 37 | (* ****** ****** *) 38 | 39 | #symload fmemq with gfun_memq_gseq of 0100 40 | 41 | (* ****** ****** *) 42 | 43 | (* end of [gfun.sats] *) 44 | -------------------------------------------------------------------------------- /prelude/SATS/gintb.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2021 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For generic bounded integers 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: Jan/Feb, 2021 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | 40 | abstype 41 | sint8_type(i: int) 42 | abstype 43 | uint8_type(i: int) 44 | sexpdef 45 | sint8 = sint8_type 46 | sexpdef 47 | uint8 = uint8_type 48 | 49 | (* ****** ****** *) 50 | // 51 | sexpdef ui8lb = 0 52 | sexpdef si8lb = -128 53 | sexpdef si8ub = +127 54 | sexpdef ui8ub = +255 55 | // 56 | (* ****** ****** *) 57 | // 58 | sexpdef 59 | si8ck(i: int) = 60 | (si8lb <= i && i <= si8ub) 61 | sexpdef 62 | ui8ck(i: int) = 63 | (ui8lb <= i && i <= ui8ub) 64 | // 65 | (* ****** ****** *) 66 | // 67 | fun<> 68 | gintb_succ_sint8 69 | { i : int 70 | | si8ck(i+1) } 71 | ( x : sint8(i) ) : sint8(i+1) 72 | fun<> 73 | gintb_pred_sint8 74 | { i : int 75 | | si8ck(i-1) } 76 | ( x : sint8(i) ) : sint8(i-1) 77 | // 78 | (* ****** ****** *) 79 | 80 | fun<> 81 | gintb_add_sint8_sint8 82 | { i,j : int 83 | | si8ck(i+j) } 84 | ( x : sint8(i) 85 | , y : sint8(j) ) : sint8(i+j) 86 | fun<> 87 | gintb_sub_sint8_sint8 88 | { i,j : int 89 | | si8ck(i-j) } 90 | ( x : sint8(i) 91 | , y : sint8(j) ) : sint8(i-j) 92 | // 93 | fun<> 94 | gintb_mul_sint8_sint8 95 | { i,j : int 96 | | si8ck(i*j) } 97 | ( x : sint8(i) 98 | , y : sint8(j) ) : sint8(i*j) 99 | // 100 | (* ****** ****** *) 101 | 102 | (* end of [gintb.sats] *) 103 | -------------------------------------------------------------------------------- /prelude/SATS/gmap.sats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | // 4 | // HX-2020-12-04: 5 | // For gmap-operations 6 | // 7 | *) 8 | (* ****** ****** *) 9 | fun 10 | 11 | 12 | 13 | gmap_print 14 | ( kxs: map ) : void 15 | (* ****** ****** *) 16 | // 17 | fun 18 | 19 | 20 | 21 | gmap_keyq 22 | (kxs: map, key: key): bool 23 | // 24 | (* ****** ****** *) 25 | // 26 | fun 27 | 28 | 29 | 30 | gmap_search_opt 31 | (kxs: map, key: key): optn_vt(itm) 32 | // 33 | (* ****** ****** *) 34 | // 35 | fun 36 | 37 | 38 | 39 | gmap_insert_opt 40 | (kxs: &map >> map, key, itm): optn_vt(itm) 41 | fun 42 | 43 | 44 | 45 | gmap_remove_opt 46 | (kxs: &map >> map, key: key): optn_vt(itm) 47 | // 48 | (* ****** ****** *) 49 | // 50 | (* 51 | fun 52 | 53 | 54 | 55 | gmap_forall(kxs: map): bool 56 | fun 57 | 58 | 59 | 60 | gmap_foreach(kxs: map): void 61 | *) 62 | // 63 | (* ****** ****** *) 64 | fun 65 | 66 | 67 | 68 | gmap_streamize 69 | (kxs: map): stream_vt(@(key, itm)) 70 | (* ****** ****** *) 71 | fun 72 | 73 | 74 | 75 | gmap_streamize_key(map): stream_vt(key) 76 | fun 77 | 78 | 79 | 80 | gmap_streamize_itm(map): stream_vt(key) 81 | (* ****** ****** *) 82 | 83 | (* end of [gmap.sats] *) 84 | -------------------------------------------------------------------------------- /prelude/SATS/gseqn.sats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** For gseqn-operations 4 | *) 5 | (* ****** ****** *) 6 | // 7 | (* 8 | // 9 | // HX-2020-07-04: 10 | // Sequences with length 11 | // 12 | *) 13 | // 14 | (* ****** ****** *) 15 | // 16 | fun 17 | 18 | 19 | 20 | gseqn_nilq(xs): bool(ln=0) 21 | // 22 | fun 23 | 24 | 25 | 26 | gseqn_consq(xs): bool(ln>0) 27 | // 28 | (* ****** ****** *) 29 | 30 | fun 31 | 32 | 33 | 34 | gseqn_head{ln>0}(xs): (x0) 35 | 36 | (* ****** ****** *) 37 | 38 | fun 39 | 40 | 41 | 42 | 43 | gseqn_tail{ln>0}(xs): (tl) 44 | 45 | (* ****** ****** *) 46 | 47 | fun 48 | 49 | 50 | 51 | gseqn_last{ln>0}(xs): (x0) 52 | 53 | (* ****** ****** *) 54 | 55 | fun 56 | 57 | 58 | 59 | gseqn_length(xs): sint(ln) 60 | 61 | (* ****** ****** *) 62 | 63 | fun 64 | 65 | 66 | 67 | gseqn_get_at 68 | (xs: xs, i0: nintlt(ln)): (x0) 69 | 70 | (* ****** ****** *) 71 | 72 | fun 73 | 74 | 75 | 76 | gseqn_listize(xs): list_vt(x0, ln) 77 | fun 78 | 79 | 80 | 81 | gseqn_rlistize(xs): list_vt(x0, ln) 82 | 83 | (* ****** ****** *) 84 | 85 | fun 86 | 87 | 88 | 89 | gseqn_unlist(list(x0, ln)): (xs) 90 | fun 91 | 92 | 93 | 94 | gseqn_unrlist(list(x0, ln)): (xs) 95 | 96 | (* ****** ****** *) 97 | // 98 | fun 99 | 100 | 101 | 102 | 103 | gseqn_map_list(xs): list_vt(y0, ln) 104 | fun 105 | 106 | 107 | 108 | 109 | gseqn_map_rlist(xs): list_vt(y0, ln) 110 | // 111 | (* ****** ****** *) 112 | // 113 | fun 114 | 115 | 116 | 117 | 118 | gseqn_map_array(xs): a1ptr( y0, ln ) 119 | fun 120 | 121 | 122 | 123 | 124 | gseqn_map_rarray(xs): a1ptr( y0, ln ) 125 | // 126 | (* ****** ****** *) 127 | 128 | (* 129 | // 130 | (* 131 | HX-2020-07-04: 132 | Is this interesting?! 133 | *) 134 | // 135 | fun 136 | 137 | 138 | 139 | 140 | 141 | gseqn_foldl(xs, r0): rz 142 | fun 143 | 144 | 145 | 146 | 147 | gseqn_foldl_nil{ln=0}(xs, r0): r0 148 | fun 149 | 150 | 151 | 152 | 153 | 154 | 155 | gseqn_foldl_cons{ln>0}(xs, r0): rz 156 | (* 157 | foldl$foprn 158 | {i 170 | 171 | 172 | gseqn_iforalln(xs: xs): bool 173 | // 174 | fun 175 | 176 | 177 | 178 | gseqn_iforeachn(xs: xs): void 179 | // 180 | (* ****** ****** *) 181 | // 182 | // For z2-gseqn-operations 183 | // 184 | (* ****** ****** *) 185 | // 186 | fun 187 | 189 | 191 | 192 | 193 | gseqn_z2map_list 194 | (xs: xs, ys: ys): list_vt(z0, ln) 195 | fun 196 | 198 | 200 | 201 | 202 | gseqn_z2map_rlist 203 | (xs: xs, ys: ys): list_vt(z0, ln) 204 | // 205 | (* ****** ****** *) 206 | 207 | (* end of [gseqn.sats] *) 208 | -------------------------------------------------------------------------------- /prelude/SATS/gseqn_vt.sats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** For glseqn-operations 4 | *) 5 | (* ****** ****** *) 6 | // 7 | (* 8 | // 9 | // HX-2020-07-04: 10 | // Linear 11 | // Sequences with length 12 | // 13 | *) 14 | // 15 | (* ****** ****** *) 16 | // 17 | fun 18 | 19 | 20 | 21 | glseqn_nilq(!xs): bool(ln=0) 22 | // 23 | fun 24 | 25 | 26 | 27 | glseqn_consq(!xs): bool(ln>0) 28 | // 29 | (* ****** ****** *) 30 | 31 | (* end of [gseqn_vt.sats] *) 32 | -------------------------------------------------------------------------------- /prelude/SATS/optn_vt.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2019 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For linear options 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: September, 2019 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | // 40 | fun<> 41 | optn_vt_nilq 42 | {a:vt}{b:b0} 43 | (xs: !optn_vt(a, b)): bool(b=ff) 44 | fun<> 45 | optn_vt_consq 46 | {a:vt}{b:b0} 47 | (xs: !optn_vt(a, b)): bool(b=tt) 48 | // 49 | (* ****** ****** *) 50 | 51 | fun 52 | 53 | optn_vt_free(~optn_vt(a)): void 54 | 55 | (* ****** ****** *) 56 | 57 | fun 58 | 59 | optn_vt_copy 60 | {n:b0} 61 | (xs: !optn_vt(a,n)): optn_vt(a,n) 62 | 63 | (* ****** ****** *) 64 | // 65 | fun 66 | 67 | optn_vt_length 68 | {b:bool} 69 | (xs: !optn_vt(a, b)): int(b2i(b)) 70 | fun 71 | 72 | optn_vt_length0 73 | {b:bool} 74 | (xs: ~optn_vt(a, b)): int(b2i(b)) 75 | // 76 | (* ****** ****** *) 77 | // 78 | fun 79 | 80 | optn_vt_forall0(xs: ~optn_vt(x0)): bool 81 | fun 82 | 83 | optn_vt_forall1(xs: !optn_vt(x0)): bool 84 | // 85 | (* ****** ****** *) 86 | // 87 | fun 88 | 89 | optn_vt_foreach0(xs: ~optn_vt(x0)): void 90 | fun 91 | 92 | optn_vt_foreach1(xs: !optn_vt(x0)): void 93 | // 94 | (* ****** ****** *) 95 | // 96 | fun 97 | 98 | optn_vt_listize0 99 | {b:b0} 100 | (~optn_vt(a, b)): list_vt(a, b2i(b)) 101 | fun 102 | 103 | optn_vt_rlistize0 104 | {b:b0} 105 | (~optn_vt(a, b)): list_vt(a, b2i(b)) 106 | fun 107 | 108 | optn_vt_streamize 109 | {b:b0}(xs: ~optn_vt(a, b)): stream_vt(a) 110 | // 111 | (* ****** ****** *) 112 | // 113 | // HX-2020-05-30: 114 | // symbol overloading for optn_vt 115 | // 116 | (* ****** ****** *) 117 | 118 | #symload 119 | none_vt with optn_vt_nil 120 | #symload 121 | some_vt with optn_vt_cons 122 | 123 | (* ****** ****** *) 124 | // 125 | #symload 126 | nilq with optn_vt_nilq of 1000 127 | #symload 128 | eqzq with optn_vt_nilq of 1000 129 | #symload 130 | consq with optn_vt_consq of 1000 131 | #symload 132 | neqzq with optn_vt_consq of 1000 133 | // 134 | (* ****** ****** *) 135 | 136 | #symload 137 | length with optn_vt_length of 1000 138 | #symload 139 | length0 with optn_vt_length0 of 1000 140 | 141 | (* ****** ****** *) 142 | 143 | #symload 144 | listize with optn_vt_listize0 of 1000 145 | #symload 146 | rlistize with optn_vt_rlistize0 of 1000 147 | 148 | (* ****** ****** *) 149 | 150 | #symload 151 | streamize with optn_vt_streamize of 1000 152 | 153 | (* ****** ****** *) 154 | 155 | (* end of [optn_vt.sats] *) 156 | -------------------------------------------------------------------------------- /prelude/SATS/unsafe.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2019 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For casting of all sorts 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: October, 2019 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | // 40 | fcast 41 | cast01{a0:t0}{a1:t0}(a0): (a1) 42 | fcast 43 | cast10{a1:t0}{a0:t0}(a0): (a1) 44 | // 45 | (* ****** ****** *) 46 | // 47 | fcast 48 | delinear{a0:vt}(a0): (~a0) 49 | fcast 50 | castlin01{a0:vt}{a1:vt}(a0): (a1) 51 | fcast 52 | castlin10{a1:vt}{a0:vt}(a0): (a1) 53 | // 54 | (* ****** ****** *) 55 | // 56 | fcast 57 | optn_vt2t 58 | {a:t0}{b:b0} 59 | (xs: !optn_vt(a, b)): optn(a, b) 60 | fcast 61 | list_vt2t 62 | {a:t0}{n:i0} 63 | (xs: !list_vt(a, n)): list(a, n) 64 | // 65 | (* ****** ****** *) 66 | // 67 | fun 68 | 69 | p1tr_get(p0: p1tr): a 70 | fun 71 | 72 | p1tr_set(p0: p1tr, x0: a): void 73 | fun 74 | 75 | p1tr_ret(p0: p1tr, x0: a): void 76 | // 77 | fun 78 | 79 | p2tr_get(p0: p2tr(a)): a 80 | fun 81 | 82 | p2tr_set(p0: p2tr(a), x0: a): void 83 | fun 84 | 85 | p2tr_ret(p0: p2tr(a), x0: a): void 86 | // 87 | (* ****** ****** *) 88 | // 89 | (* 90 | HX-2020-07-29: 91 | const pointers are read-only 92 | *) 93 | // 94 | fun 95 | 96 | cp1tr_get(cp: cp1tr): a 97 | fun 98 | 99 | cp2tr_get(cp: cp2tr(a)): a 100 | // 101 | (* ****** ****** *) 102 | // 103 | fun 104 | 105 | p2tr_set_list_nil 106 | (p0: p2tr(list(a))): void 107 | fun 108 | 109 | p2tr_set_list_cons 110 | (p0: p2tr(list(a)), x0: a): void 111 | // 112 | fun 113 | 114 | p2tr_set_list_vt_nil 115 | (p0: p2tr(list_vt(a))): void 116 | fun 117 | 118 | p2tr_set_list_vt_cons 119 | (p0: p2tr(list_vt(a)), x0: a): void 120 | // 121 | (* ****** ****** *) 122 | // 123 | // HX-2020-05-30: 124 | // symbol overloading for unsafe 125 | // 126 | (* ****** ****** *) 127 | // 128 | #symload ptr_get with p1tr_get of 1000 129 | #symload ptr_set with p1tr_set of 1000 130 | // 131 | #symload ptr_get with p2tr_get of 1000 132 | #symload ptr_set with p2tr_set of 1000 133 | // 134 | (* ****** ****** *) 135 | // 136 | #symload cptr_get with cp1tr_get of 1000 137 | #symload cptr_get with cp2tr_get of 1000 138 | // 139 | (* ****** ****** *) 140 | 141 | (* end of [unsafe.sats] *) 142 | -------------------------------------------------------------------------------- /prelude/excptn.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Authoremail: gmhwxiATgmailDOTcom 32 | // 33 | // This one should be loaded after xsetup.sats 34 | // 35 | (* ****** ****** *) 36 | // 37 | // HX-2020-03-05: 38 | // For out-of-range subscripting 39 | excptcon 40 | SubscriptExn of ((*void*)) 41 | // 42 | // For indicating the failure of 43 | excptcon AssertExn of () // an assertion 44 | // For indicating something expected 45 | excptcon NotFoundExn of () // to be found but not 46 | // 47 | (* ****** ****** *) 48 | 49 | (* end of [excptn.sats] *) 50 | -------------------------------------------------------------------------------- /prelude/xparam.hats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | #define VERBOSE_FIXITY 0 31 | (* 32 | #define VERBOSE_FIXITY 1 (* used in [prelude/fixity.ats] *) 33 | *) 34 | // 35 | (* ****** ****** *) 36 | // 37 | #define VERBOSE_PRELUDE 0 38 | (* 39 | #define VERBOSE_PRELUDE 1 (* mainly for the purpose of debugging *) 40 | *) 41 | // 42 | (* ****** ****** *) 43 | 44 | (* end of [xparam.hats] *) 45 | -------------------------------------------------------------------------------- /prelude/xsetup.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2019 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // HX-2019-09-09: 31 | // These can be re-defined 32 | // 33 | (* ****** ****** *) 34 | 35 | typedef 36 | the_void_ctype = void 37 | 38 | (* ****** ****** *) 39 | // 40 | typedef 41 | the_p1tr_ctype = p1tr0 42 | typedef 43 | the_p2tr_ctype(a:vt) = p2tr(a) 44 | // 45 | (* ****** ****** *) 46 | // 47 | typedef 48 | the_sint_ctype(i:int) = sint1(i) 49 | typedef 50 | the_uint_ctype(i:int) = uint1(i) 51 | // 52 | (* ****** ****** *) 53 | // 54 | typedef 55 | the_bool_ctype(b:bool) = bool1(b) 56 | typedef 57 | the_char_ctype(c:char) = char1(c) 58 | // 59 | (* ****** ****** *) 60 | // 61 | // single precision 62 | typedef the_sflt_ctype = sflt 63 | // double precision 64 | typedef the_dflt_ctype = dflt 65 | // 66 | // ldouble precision 67 | typedef the_ldflt_ctype = ldflt 68 | // 69 | (* ****** ****** *) 70 | // 71 | typedef the_slint_ctype = slint0 72 | typedef the_ulint_ctype = ulint0 73 | // 74 | typedef the_sllint_ctype = sllint0 75 | typedef the_ullint_ctype = ullint0 76 | // 77 | (* ****** ****** *) 78 | // 79 | typedef 80 | the_string_ctype(n:int) = string1(n) 81 | // 82 | (* ****** ****** *) 83 | 84 | typedef the_sint0_ctype = sint0 85 | typedef the_uint0_ctype = uint0 86 | typedef the_bool0_ctype = bool0 87 | typedef the_char0_ctype = char0 88 | typedef the_string0_ctype = string0 89 | 90 | (* ****** ****** *) 91 | // 92 | typedef 93 | the_lazy_ctype(a:t0) = lazy(a) 94 | vwtpdef 95 | the_llazy_ctype(a:vt) = lazy_vt(a) 96 | // 97 | (* ****** ****** *) 98 | // 99 | vwtpdef 100 | the_excptn_ctype(*void*) = excptn_vt 101 | // 102 | (* ****** ****** *) 103 | // 104 | viewdef 105 | the_a0p1tr_cview(*void*) = a0ptr_view 106 | // 107 | (* ****** ****** *) 108 | 109 | (* end of [xsetup.sats] *) 110 | -------------------------------------------------------------------------------- /srcgen/xats/BUILD/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/srcgen/xats/BUILD/.gitkeep -------------------------------------------------------------------------------- /srcgen/xats/CATS/lexbuf0.cats: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Applied Type System */ 4 | /* */ 5 | /***********************************************************************/ 6 | 7 | /* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | */ 27 | 28 | /* ****** ****** */ 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: May, 2018 32 | // Authoremail: gmhwxi@gmail.com 33 | // 34 | /* ****** ****** */ 35 | 36 | #ifndef XANADU_SRCGEN_CATS_LEXBUF0 37 | #define XANADU_SRCGEN_CATS_LEXBUF0 38 | 39 | /* ****** ****** */ 40 | 41 | /* 42 | typedef 43 | lexbuf_tflt = 44 | $extype_struct 45 | "xats_lexbuf_struct" of 46 | { 47 | base_ntot= int 48 | , base_nrow= int 49 | , base_ncol= int 50 | (* 51 | , char= int 52 | *) 53 | , cbuf= string 54 | // 55 | , begp= ptr 56 | , endp= ptr, curp= ptr 57 | // 58 | , cbhead= cblist, cbtail= cblist 59 | // 60 | } (* end of [xats_lexbuf_tflt] *) 61 | */ 62 | 63 | /* ****** ****** */ 64 | 65 | typedef struct { 66 | // 67 | atstype_int ntot ; // char number 68 | atstype_int nrow ; // line number 69 | atstype_int ncol ; // line offset 70 | // 71 | /* 72 | atstype_int char ; // ungetc 73 | */ 74 | atstype_ptr cbuf ; // prefix 75 | // 76 | atstype_ptr begp ; // start 77 | atstype_ptr endp ; // finish 78 | atstype_ptr curp ; // current 79 | // 80 | atstype_ptr cbhead ; // 1st cblock 81 | atstype_ptr cbtail ; // rest of cblocks 82 | // 83 | } xats_lexbuf_struct ; 84 | 85 | /* ****** ****** */ 86 | 87 | #endif // end of [XANADU_SRCGEN_CATS_LEXBUF0] 88 | 89 | /* ****** ****** */ 90 | 91 | /* end of [xats_lexbuf0.cats] */ 92 | -------------------------------------------------------------------------------- /srcgen/xats/CATS/locinfo.cats: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Applied Type System */ 4 | /* */ 5 | /***********************************************************************/ 6 | 7 | /* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | */ 27 | 28 | /* ****** ****** */ 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: May, 2018 32 | // Authoremail: gmhwxi@gmail.com 33 | // 34 | /* ****** ****** */ 35 | 36 | #ifndef \ 37 | ATS3_SRCGEN_CATS_XATS_LOCINFO 38 | #define \ 39 | ATS3_SRCGEN_CATS_XATS_LOCINFO 40 | 41 | /* ****** ****** */ 42 | 43 | typedef struct { 44 | atstype_int ntot ; // char number 45 | atstype_int nrow ; // line number 46 | atstype_int ncol ; // line offset 47 | } xats_position_struct ; 48 | 49 | /* ****** ****** */ 50 | // 51 | #endif // end if [ifndef] 52 | // [ATS3_SRCGEN_CATS_XATS_LOCINFO] 53 | // 54 | /* ****** ****** */ 55 | 56 | /* end of [xats_locinfo.cats] */ 57 | -------------------------------------------------------------------------------- /srcgen/xats/CATS/parsing.cats: -------------------------------------------------------------------------------- 1 | /***********************************************************************/ 2 | /* */ 3 | /* Applied Type System */ 4 | /* */ 5 | /***********************************************************************/ 6 | 7 | /* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | */ 27 | 28 | /* ****** ****** */ 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: June, 2018 32 | // Authoremail: gmhwxi@gmail.com 33 | // 34 | /* ****** ****** */ 35 | // 36 | #ifndef \ 37 | ATS3_SRCGEN_CATS_XATS_PARSING 38 | #define \ 39 | ATS3_SRCGEN_CATS_XATS_PARSING 40 | // 41 | /* ****** ****** */ 42 | 43 | /* 44 | typedef 45 | tokbuf_tflat = 46 | $extype_struct 47 | "xats_tokbuf_struct" of 48 | { 49 | token *begp; 50 | token *endp; 51 | token *curp; 52 | } (* end of [tokbuf] *) 53 | */ 54 | 55 | typedef struct { 56 | // 57 | atstype_ptr begp ; // start 58 | atstype_ptr endp ; // finish 59 | atstype_ptr curp ; // current 60 | // 61 | } xats_tokbuf_struct ; 62 | 63 | /* ****** ****** */ 64 | // 65 | #endif // end if [ifndef] 66 | // [ATS3_SRCGEN_CATS_XATS_PARSING] 67 | // 68 | /* ****** ****** */ 69 | 70 | /* end of [xats_parsing.cats] */ 71 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/CONTRIB/githwxi/.keeper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/srcgen/xats/DATS/CONTRIB/githwxi/.keeper -------------------------------------------------------------------------------- /srcgen/xats/DATS/CONTRIB/githwxi/my_tread23_dynexp.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | // 3 | // Author: Hongwei Xi 4 | // Start Time: July 02, 2020 5 | // Authoremail: gmhwxiATgmailDOTcom 6 | // 7 | (* ****** ****** *) 8 | // 9 | #include 10 | "share/atspre_staload.hats" 11 | #staload 12 | UN = "prelude/SATS/unsafe.sats" 13 | // 14 | (* ****** ****** *) 15 | #staload 16 | "./../../../SATS/dynexp3.sats" 17 | (* ****** ****** *) 18 | #staload 19 | "./../../../SATS/tread23.sats" 20 | (* ****** ****** *) 21 | 22 | extern 23 | fun{} 24 | my_tread23_d3ecl_D3Clocal: treader23(d3ecl) 25 | 26 | (* ****** ****** *) 27 | 28 | implement 29 | {}(*tmp*) 30 | my_tread23_d3ecl_D3Clocal 31 | (d3c0) = 32 | { 33 | // 34 | val- 35 | D3Clocal 36 | (head, body) = d3c0.node() 37 | // 38 | val () = tread23_d3eclist(head) 39 | val () = tread23_d3eclist(body) 40 | // 41 | } // end of [my_tread23_d3ecl_D3Clocal] 42 | 43 | (* ****** ****** *) 44 | 45 | (* end of [tread23_dynexp.dats] *) 46 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/CONTRIB/tread23_dynexp.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | // 3 | // Author: Hongwei Xi 4 | // Start Time: July 02, 2020 5 | // Authoremail: gmhwxiATgmailDOTcom 6 | // 7 | (* ****** ****** *) 8 | // 9 | #staload 10 | GITHWXI = 11 | "./githwxi/my_tread23_dynexp.dats" 12 | // 13 | (* ****** ****** *) 14 | 15 | implement 16 | tread23_d3ecl_D3Clocal 17 | (d3c0) = 18 | { 19 | val () = 20 | $GITHWXI.my_tread23_d3ecl_D3Clocal<>(d3c0) 21 | } (* end of [tread23_d3ecl_D3Clocal] *) 22 | 23 | (* ****** ****** *) 24 | 25 | (* end of [tread23_dynexp.dats] *) 26 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/CONTRIB/tread33_dynexp.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | // 3 | // Author: Hongwei Xi 4 | // Start Time: July 02, 2020 5 | // Authoremail: gmhwxiATgmailDOTcom 6 | // 7 | (* ****** ****** *) 8 | // 9 | #staload 10 | GITHWXI = 11 | "./githwxi/my_tread33_dynexp.dats" 12 | // 13 | (* ****** ****** *) 14 | 15 | implement 16 | tread33_d3exp_D3Elcast 17 | (d3e0) = 18 | { 19 | val () = 20 | $GITHWXI.my_tread33_d3exp_D3Elcast<>(d3e0) 21 | } (* end of [tread33_d3exp_D3Elcast] *) 22 | 23 | (* ****** ****** *) 24 | 25 | implement 26 | tread33_d3exp_D3Etcast 27 | (d3e0) = 28 | { 29 | val () = 30 | $GITHWXI.my_tread33_d3exp_D3Etcast<>(d3e0) 31 | } (* end of [tread33_d3exp_D3Etcast] *) 32 | 33 | (* ****** ****** *) 34 | 35 | (* end of [tread33_dynexp.dats] *) 36 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/cstrnt0.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2021 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: March, 2021 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | #staload "./../SATS/locinfo.sats" 43 | (* ****** ****** *) 44 | // 45 | #staload "./../SATS/cstrnt0.sats" 46 | // 47 | (* ****** ****** *) 48 | // 49 | implement 50 | c0str_make_tasmp 51 | ( s2e1(*src*) 52 | , s2e2(*dst*)) = C0Htpeq(s2e1, s2e2) 53 | // 54 | implement 55 | c0str_make_tcast 56 | ( s2e1(*src*) 57 | , s2e2(*dst*)) = C0Itple(s2e1, s2e2) 58 | // 59 | (* ****** ****** *) 60 | 61 | (* end of [xats_cstrnt0.dats] *) 62 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/cstrnt0_print.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2021 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: March, 2021 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | // 43 | #staload "./../SATS/staexp2.sats" 44 | #staload "./../SATS/statyp2.sats" 45 | #staload "./../SATS/dynexp2.sats" 46 | // 47 | (* ****** ****** *) 48 | // 49 | #staload "./../SATS/cstrnt0.sats" 50 | // 51 | (* ****** ****** *) 52 | implement 53 | print_c0str(x0) = 54 | fprint_c0str(stdout_ref, x0) 55 | implement 56 | prerr_c0str(x0) = 57 | fprint_c0str(stderr_ref, x0) 58 | (* ****** ****** *) 59 | implement 60 | fprint_val = fprint_c0str 61 | (* ****** ****** *) 62 | // 63 | implement 64 | fprint_c0str 65 | (out, x0) = 66 | ( 67 | case+ x0 of 68 | // 69 | (* 70 | | 71 | C0Heqeq(s2e1, s2e2) => 72 | fprint! 73 | ( out 74 | , "C0Heqeq(", s2e1, "; ", s2e2, ")") 75 | *) 76 | | 77 | C0Htpeq(s2e1, s2e2) => 78 | fprint! 79 | ( out 80 | , "C0Htpeq(", s2e1, "; ", s2e2, ")") 81 | // 82 | (* 83 | | 84 | C0Ieqeq(s2e1, s2e2) => 85 | fprint! 86 | ( out 87 | , "C0Ieqeq(", s2e1, "; ", s2e2, ")") 88 | *) 89 | | 90 | C0Itple(s2e1, s2e2) => 91 | fprint! 92 | ( out 93 | , "C0Itple(", s2e1, "; ", s2e2, ")") 94 | | 95 | C0Itpeq(s2e1, s2e2) => 96 | fprint! 97 | ( out 98 | , "C0Itpeq(", s2e1, "; ", s2e2, ")") 99 | // 100 | ) (* end of [fprint_c0str] *) 101 | // 102 | (* ****** ****** *) 103 | 104 | (* end of [xats_cstrnt0_print.dats] *) 105 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/cstrnt1.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2021 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: May 22nd, 2021 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | #staload "./../SATS/locinfo.sats" 43 | (* ****** ****** *) 44 | // 45 | #staload "./../SATS/cstrnt1.sats" 46 | // 47 | (* ****** ****** *) 48 | 49 | local 50 | 51 | absimpl 52 | c1hyp_tbox = $rec 53 | { c1hyp_loc= loc_t 54 | , c1hyp_node= c1hyp_node 55 | } (* $rec *) 56 | 57 | in (* in-of-local *) 58 | 59 | (* ****** ****** *) 60 | // 61 | implement 62 | c1hyp_get_loc 63 | (c1s) = c1s.c1hyp_loc 64 | implement 65 | c1hyp_get_node 66 | (c1s) = c1s.c1hyp_node 67 | // 68 | (* ****** ****** *) 69 | 70 | implement 71 | c1hyp_make_node 72 | (loc0, node) = 73 | $rec{ 74 | c1hyp_loc=loc0 75 | , c1hyp_node= node 76 | } (* $rec *) // c1hyp_make_node 77 | 78 | (* ****** ****** *) 79 | 80 | end // end of [local] 81 | 82 | (* ****** ****** *) 83 | 84 | local 85 | 86 | absimpl 87 | c1str_tbox = $rec 88 | { c1str_loc= loc_t 89 | , c1str_kind= c1knd 90 | , c1str_node= c1str_node 91 | } (* $rec *) 92 | 93 | in (* in-of-local *) 94 | 95 | (* ****** ****** *) 96 | // 97 | implement 98 | c1str_get_loc 99 | (c1s) = c1s.c1str_loc 100 | implement 101 | c1str_get_node 102 | (c1s) = c1s.c1str_node 103 | // 104 | (* ****** ****** *) 105 | // 106 | implement 107 | c1str_make_node1 108 | (loc0, node) = 109 | c1str_make_node2 110 | ( loc0 111 | , C1Knone(), node) 112 | implement 113 | c1str_make_node2 114 | (loc0, c1k0, node) = 115 | $rec{ 116 | c1str_loc=loc0 117 | , c1str_kind= c1k0 118 | , c1str_node= node 119 | } (* $rec *) // c1str_make_node2 120 | // 121 | (* ****** ****** *) 122 | 123 | end // end of [local] 124 | 125 | (* ****** ****** *) 126 | 127 | (* end of [xats_cstrnt1.dats] *) 128 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/dmacro2_macdef.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: October, 2020 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | // HX-2020-10-04: 37 | // For "hygenic" macros that avoid 38 | // capturing of free variables. 39 | // 40 | (* ****** ****** *) 41 | // 42 | #include 43 | "share/atspre_staload.hats" 44 | #staload 45 | UN = "prelude/SATS/unsafe.sats" 46 | // 47 | (* ****** ****** *) 48 | // 49 | #staload "./../SATS/staexp1.sats" 50 | // 51 | (* ****** ****** *) 52 | 53 | (* end of [xats_dmacro2_macdef.dats] *) 54 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/effect0.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: October, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #staload "./../SATS/effect0.sats" 37 | // 38 | (* ****** ****** *) 39 | // 40 | // HX-2019-02-20: 41 | // It is no longer planned to support 42 | // effect-tracking given its "obtrusiveness"!!! 43 | // 44 | (* ****** ****** *) 45 | 46 | (* end of [xats_effect0.dats] *) 47 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/intrep0.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: June, 2020 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | // 43 | #staload 44 | STM = "./../SATS/xstamp0.sats" 45 | #staload 46 | SYM = "./../SATS/xsymbol.sats" 47 | #staload 48 | LOC = "./../SATS/locinfo.sats" 49 | // 50 | (* ****** ****** *) 51 | // 52 | #staload "./../SATS/intrep0.sats" 53 | // 54 | (* ****** ****** *) 55 | 56 | local 57 | 58 | val 59 | stamper = 60 | $STM.stamper_new() 61 | 62 | in (* in-of-local *) 63 | 64 | implement 65 | htcst_stamp_new() = 66 | $STM.stamper_getinc(stamper) 67 | 68 | end // end of [local] 69 | 70 | (* ****** ****** *) 71 | 72 | local 73 | 74 | val 75 | stamper = 76 | $STM.stamper_new() 77 | 78 | in (* in-of-local *) 79 | 80 | implement 81 | htvar_stamp_new() = 82 | $STM.stamper_getinc(stamper) 83 | 84 | end // end of [local] 85 | 86 | (* ****** ****** *) 87 | 88 | local 89 | 90 | val 91 | stamper = $STM.stamper_new() 92 | 93 | in (* in-of-local *) 94 | 95 | implement 96 | hdcon_stamp_new() = $STM.stamper_getinc(stamper) 97 | 98 | end // end of [local] 99 | 100 | (* ****** ****** *) 101 | 102 | local 103 | 104 | val 105 | stamper = $STM.stamper_new() 106 | 107 | in (* in-of-local *) 108 | 109 | implement 110 | hdcst_stamp_new() = $STM.stamper_getinc(stamper) 111 | 112 | end // end of [local] 113 | 114 | (* ****** ****** *) 115 | 116 | local 117 | 118 | val 119 | stamper = $STM.stamper_new() 120 | 121 | in (* in-of-local *) 122 | 123 | implement 124 | hdvar_stamp_new() = $STM.stamper_getinc(stamper) 125 | 126 | end // end of [local] 127 | 128 | (* ****** ****** *) 129 | 130 | (* end of [xats_intrep0.dats] *) 131 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/intrep0_jsoniz.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: June, 2020 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | // 43 | #staload "./../SATS/xstamp0.sats" 44 | // 45 | #staload "./../SATS/xsymbol.sats" 46 | // 47 | (* ****** ****** *) 48 | 49 | #staload "./../SATS/intrep0.sats" 50 | 51 | (* ****** ****** *) 52 | 53 | (* end of [xats_intrep0_jsoniz.dats] *) 54 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/intrep0_statyp.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: June, 2020 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | // 43 | #staload "./../SATS/xstamp0.sats" 44 | #staload "./../SATS/xsymbol.sats" 45 | #staload "./../SATS/locinfo.sats" 46 | // 47 | (* ****** ****** *) 48 | 49 | #staload "./../SATS/intrep0.sats" 50 | 51 | (* ****** ****** *) 52 | 53 | local 54 | 55 | typedef 56 | htcst_struct = @{ 57 | // 58 | htcst_loc= loc_t 59 | , htcst_sym= sym_t // name 60 | , htcst_sort= h0srt // type 61 | , htcst_stamp= stamp // unicity 62 | // 63 | } (* end of [htcst_tbox] *) 64 | 65 | absimpl 66 | htcst_tbox = ref(htcst_struct) 67 | 68 | in(* in-of-local *) 69 | 70 | implement 71 | htcst_get_sym 72 | (htc) = htc->htcst_sym 73 | implement 74 | htcst_get_stamp 75 | (htc) = htc->htcst_stamp 76 | 77 | implement 78 | htcst_make_idst 79 | (loc, sym, hst) = 80 | ( 81 | ref 82 | @{ 83 | htcst_loc=loc 84 | , htcst_sym=sym 85 | , htcst_sort=hst 86 | , htcst_stamp=stamp 87 | } 88 | ) where 89 | { 90 | val stamp = htcst_stamp_new() 91 | } 92 | 93 | end // end of [local] 94 | 95 | (* ****** ****** *) 96 | 97 | local 98 | 99 | typedef 100 | htvar_struct = @{ 101 | // 102 | htvar_sym= sym_t // name 103 | , htvar_sort= h0srt // type 104 | , htvar_stamp= stamp // unicity 105 | // 106 | } (* end of [htvar_tbox] *) 107 | 108 | absimpl 109 | htvar_tbox = ref(htvar_struct) 110 | 111 | in(* in-of-local *) 112 | 113 | implement 114 | htvar_get_sym 115 | (htv) = htv->htvar_sym 116 | implement 117 | htvar_get_stamp 118 | (htv) = htv->htvar_stamp 119 | 120 | implement 121 | htvar_make_idst 122 | (sym, hst) = 123 | ( 124 | ref 125 | @{ 126 | htvar_sym=sym 127 | , htvar_sort=hst 128 | , htvar_stamp=stamp 129 | } 130 | ) where 131 | { 132 | val stamp = htvar_stamp_new() 133 | } 134 | 135 | end // end of [local] 136 | 137 | (* ****** ****** *) 138 | 139 | local 140 | 141 | absimpl 142 | h0typ_tbox = $rec 143 | { 144 | h0typ_sort= h0srt 145 | , h0typ_node= h0typ_node 146 | } (* absimpl *) 147 | 148 | in (* in-of-local *) 149 | // 150 | implement 151 | h0typ_get_sort 152 | (h2t) = h2t.h0typ_sort 153 | implement 154 | h0typ_get_node 155 | (h2t) = h2t.h0typ_node 156 | // 157 | implement 158 | h0typ_make_node 159 | (s2t0, node) = $rec 160 | { 161 | h0typ_sort= s2t0, h0typ_node= node 162 | } 163 | // 164 | end // end of [local] 165 | 166 | (* ****** ****** *) 167 | 168 | (* end of [xats_intrep0_statyp.dats] *) 169 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/parsing_tokbuf.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: June, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | 43 | #staload "./../SATS/lexing0.sats" 44 | #staload "./../SATS/parsing.sats" 45 | 46 | (* ****** ****** *) 47 | // 48 | absimpl 49 | tokbuf_tflt = 50 | $extype_struct 51 | "xats_tokbuf_struct" of 52 | { 53 | begp= ptr, endp= ptr, curp= ptr 54 | } (* end of [tokbuf] *) 55 | // 56 | (* ****** ****** *) 57 | 58 | implement 59 | tokbuf_initize_list 60 | (buf, xs) = let 61 | // 62 | val n0 = 63 | length(xs) 64 | // 65 | val A0 = 66 | arrayptr_make_list 67 | (n0, xs) 68 | // 69 | val p0 = 70 | $UN.castvwtp0{ptr}( A0 ) 71 | // 72 | in 73 | // 74 | buf.begp := p0; 75 | buf.curp := p0; 76 | buf.endp := 77 | ptr0_add_gint(p0, n0); 78 | // 79 | end // end of [tokbuf_make_list] 80 | 81 | (* ****** ****** *) 82 | // 83 | implement 84 | tokbuf_getok0 85 | (buf) = 86 | ( 87 | $UN.ptr0_get(buf.curp) 88 | ) 89 | // 90 | (* 91 | HX-2018-06-24: 92 | This function is only safe 93 | if the current token is not EOF 94 | *) 95 | implement 96 | tokbuf_incby1 97 | (buf) = let 98 | // 99 | val p0 = buf.curp 100 | // 101 | in 102 | buf.curp := ptr0_succ(p0) 103 | end // end of [tokbuf_incby1] 104 | // 105 | (* ****** ****** *) 106 | 107 | implement 108 | tokbuf_getok1 109 | (buf) = let 110 | // 111 | val p0 = buf.curp 112 | // 113 | val tok = 114 | $UN.ptr0_get(p0) 115 | // 116 | in 117 | // 118 | case+ 119 | tok.node() of 120 | | T_EOF() => tok 121 | | _ (* non-EOF *) => tok where 122 | { 123 | val () = 124 | buf.curp := ptr0_succ(p0) 125 | } 126 | // 127 | end // end of [tokbuf_getok1] 128 | 129 | (* ****** ****** *) 130 | 131 | local 132 | 133 | absimpl 134 | tokbuf_mark_vtbox = ptr 135 | 136 | in (* in-of-local *) 137 | 138 | implement 139 | tokbuf_get_mark(buf) = buf.curp 140 | implement 141 | tokbuf_set_mark(buf, mk0) = buf.curp := mk0 142 | implement 143 | tokbuf_clear_mark(buf, mk0) = () // discard 144 | 145 | end // end of [local] 146 | 147 | (* ****** ****** *) 148 | 149 | (* end of [xats_parsing_tokbuf.dats] *) 150 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/trans34_util2.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2021 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: January, 2021 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | 43 | #staload "./../SATS/staexp2.sats" 44 | #staload "./../SATS/statyp2.sats" 45 | #staload "./../SATS/dynexp3.sats" 46 | 47 | (* ****** ****** *) 48 | 49 | #staload "./../SATS/dynexp4.sats" 50 | #staload "./../SATS/trans34.sats" 51 | 52 | (* ****** ****** *) 53 | 54 | (* end of [xats_trans34_util2.dats] *) 55 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/xatsopt.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: October, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | #dynload 36 | "./xatsopt_main0.dats" 37 | (* ****** ****** *) 38 | #staload 39 | "./../SATS/xatsopt.sats" 40 | (* ****** ****** *) 41 | // 42 | #include 43 | "share/atspre_staload.hats" 44 | #staload 45 | UN = "prelude/SATS/unsafe.sats" 46 | // 47 | (* ****** ****** *) 48 | // 49 | // HX-2019-11-14: 50 | // 51 | #ifdef 52 | __LIBXATSOPT__ 53 | #then 54 | (* ****** ****** *) 55 | #define 56 | ATS_MAINATSFLAG 1 57 | #define 58 | ATS_DYNLOADNAME "libxatsopt_dynloadall" 59 | (* ****** ****** *) 60 | #else 61 | (* ****** ****** *) 62 | implement 63 | main0(argc, argv) = 64 | ( 65 | // 66 | if 67 | (argc >= 2) 68 | then 69 | { 70 | val () = 71 | xatsopt_main0(argc, argv) 72 | } 73 | else 74 | { 75 | // 76 | val () = 77 | prerrln! 78 | ("Hello from ATS3(xatsopt)!") 79 | // 80 | val 81 | XATSHOME = the_XATSHOME_get() 82 | val 83 | ((*void*)) = 84 | prerrln! 85 | ("xatsopt: XATSHOME=",XATSHOME) 86 | // 87 | } 88 | // end of [if] 89 | ) where 90 | { 91 | // (* 92 | val out = stderr_ref 93 | val ( ) = 94 | echo_argc_argv(out, argc, argv) 95 | // *) 96 | } (* end of [main] *) 97 | (* ****** ****** *) 98 | #endif // #ifdef(__LIBXATSOPT__) 99 | (* ****** ****** *) 100 | (* end of [xats_xatsopt.dats] *) 101 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/xerrory.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: August, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | #staload 39 | UN = "prelude/SATS/unsafe.sats" 40 | // 41 | (* ****** ****** *) 42 | // 43 | #staload "./../SATS/xerrory.sats" 44 | // 45 | (* ****** ****** *) 46 | 47 | local 48 | // 49 | extern 50 | fun 51 | segfault 52 | ( 53 | // argless 54 | ) : int 55 | = "ext#xats_xerrory_segfault" 56 | // 57 | in (* in-of-local *) 58 | 59 | implement 60 | abort() = let 61 | (* 62 | val _ = segfault() 63 | *) 64 | in 65 | $raise FatalErrorExn((*void*)) 66 | end // end of [abort] 67 | 68 | implement 69 | abort_interr() = let 70 | (* 71 | val _ = segfault() 72 | *) 73 | in 74 | $raise FatalErrorExn_interr((*void*)) 75 | end // end of [abort] 76 | 77 | end // end of [local] 78 | 79 | (* ****** ****** *) 80 | 81 | (* end of [xats_xerrory.dats] *) 82 | -------------------------------------------------------------------------------- /srcgen/xats/DATS/xstamp0.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: October, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #include 37 | "share/atspre_staload.hats" 38 | // 39 | #staload 40 | UN = "prelude/SATS/unsafe.sats" 41 | // 42 | (* ****** ****** *) 43 | // 44 | #staload "./../SATS/xstamp0.sats" 45 | // 46 | (* ****** ****** *) 47 | 48 | absimpl stamp_type = ptr 49 | 50 | (* ****** ****** *) 51 | // 52 | implement 53 | the_stamp0 = ( the_null_ptr ) 54 | // 55 | (* ****** ****** *) 56 | // 57 | implement 58 | stamp2uint(x0) = 59 | let 60 | val x0 = 61 | $UN.cast 62 | {uintptr}(x0) in $UN.cast{uint}(x0) 63 | end // end of [stamp2uint] 64 | // 65 | (* ****** ****** *) 66 | // 67 | implement 68 | eq_stamp_stamp 69 | (x1, x2) = 70 | ( 71 | eq_ptr0_ptr0(x1, x2) 72 | ) 73 | // 74 | (* ****** ****** *) 75 | // 76 | implement 77 | cmp_stamp_stamp 78 | (x1, x2) = 79 | ( 80 | compare_ptr0_ptr0(x1, x2) 81 | ) 82 | // 83 | (* ****** ****** *) 84 | // 85 | implement 86 | print_stamp(x0) = 87 | fprint_stamp(stdout_ref, x0) 88 | implement 89 | prerr_stamp(x0) = 90 | fprint_stamp(stderr_ref, x0) 91 | // 92 | implement 93 | fprint_stamp(out, x0) = 94 | ( 95 | fprint_uint(out, stamp2uint(x0)) 96 | ) 97 | // 98 | (* ****** ****** *) 99 | 100 | local 101 | // 102 | absimpl 103 | stamper_tbox = ref(stamp) 104 | // 105 | in (* in-of-local *) 106 | // 107 | implement 108 | stamper_new() = 109 | ref(the_null_ptr) 110 | // 111 | implement 112 | stamper_set 113 | (obj, n0) = let 114 | val n0 = 115 | $UN.cast{uintptr}(n0) 116 | in 117 | obj[] := $UN.cast{ptr}(n0) 118 | end // end of [stamper_set] 119 | // 120 | implement 121 | stamper_getinc 122 | (obj) = n0 where 123 | { 124 | val n0 = obj[] 125 | val () = obj[] := ptr_succ(n0) 126 | } 127 | // 128 | end // end of [local] 129 | 130 | (* ****** ****** *) 131 | 132 | (* end of [xats_xstamp0.dats] *) 133 | -------------------------------------------------------------------------------- /srcgen/xats/HATS/xatsopt.hats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: May, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | // For defining 37 | // various system-wise parameters 38 | // 39 | (* ****** ****** *) 40 | (* 41 | ** HX-2020-07-08: 42 | ** proposed by Richard Kent: 43 | *) 44 | #ifndef 45 | XATSOPT_DEBUG_INFO 46 | #define 47 | XATSOPT_DEBUG_INFO 48 | 49 | #define 50 | __XATSOPT_DEBUG__ 1 51 | 52 | #endif(*XATSOPT_DEBUG_INFO*) 53 | (* ****** ****** *) 54 | // 55 | #define SYSTEM_IS_POSIX_LIKE 1 56 | #define SYSTEM_IS_WINDOWS_LIKE 0 57 | // 58 | (* ****** ****** *) 59 | 60 | (* end of [xatsopt.hats] *) 61 | -------------------------------------------------------------------------------- /srcgen/xats/Makefile: -------------------------------------------------------------------------------- 1 | Makefile_xatsopt -------------------------------------------------------------------------------- /srcgen/xats/SATS/cstrnt0.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2021 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: March 27, 2021 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | #staload "./xbasics.sats" 36 | (* ****** ****** *) 37 | #staload "./locinfo.sats" 38 | (* ****** ****** *) 39 | 40 | #staload S2E = "./staexp2.sats" 41 | #staload S2T = "./statyp2.sats" 42 | #staload D2E = "./dynexp2.sats" 43 | 44 | (* ****** ****** *) 45 | // 46 | typedef s2exp = $S2E.s2exp 47 | typedef t2ype = $S2T.t2ype 48 | typedef d2var = $D2E.d2var 49 | // 50 | (* ****** ****** *) 51 | // 52 | datatype c0str = 53 | // 54 | (* 55 | | C0Heqeq of 56 | (s2exp, s2exp) // equality 57 | *) 58 | | C0Htpeq of 59 | (s2exp, s2exp) // type-equality 60 | // 61 | (* 62 | | C0Ieqeq of 63 | (s2exp, s2exp) // equality 64 | *) 65 | | C0Itple of 66 | (s2exp, s2exp) // subtyping 67 | | C0Itpeq of 68 | (s2exp, s2exp) // type-equality 69 | // 70 | where c0strlst = List0(c0str) 71 | // 72 | typedef 73 | c0stropt = Option(c0str) 74 | typedef 75 | c0strlstopt = Option(c0strlst) 76 | // 77 | (* ****** ****** *) 78 | // 79 | fun 80 | print_c0str : print_type(c0str) 81 | fun 82 | prerr_c0str : prerr_type(c0str) 83 | fun 84 | fprint_c0str : fprint_type(c0str) 85 | // 86 | overload print with print_c0str 87 | overload prerr with prerr_c0str 88 | overload fprint with fprint_c0str 89 | // 90 | (* ****** ****** *) 91 | // 92 | fun 93 | c0str_make_tasmp 94 | (s2e1: s2exp, s2e2: s2exp): c0str 95 | fun 96 | c0str_make_tcast 97 | (s2e1: s2exp, s2e2: s2exp): c0str 98 | // 99 | (* ****** ****** *) 100 | 101 | (* end of [xats_cstrnt0.sats] *) 102 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/effect0.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: November, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | (* 36 | // 37 | abstype effect_type = ptr 38 | abstype effset_type = ptr 39 | // 40 | typedef effect = effect_type 41 | typedef effset = effset_type 42 | typedef effectlst = List0(effect) 43 | // 44 | *) 45 | (* ****** ****** *) 46 | // 47 | // HX-2019-02-20: 48 | // It is no longer planned to support 49 | // effect-tracking given its "obtrusiveness"!!! 50 | // 51 | (* ****** ****** *) 52 | 53 | (* end of [xats_effect0.sats] *) 54 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/filsrch.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: May, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #staload 37 | SYM = "./xsymbol.sats" 38 | // 39 | (* ****** ****** *) 40 | 41 | #staload "./filpath.sats" 42 | 43 | (* ****** ****** *) 44 | // 45 | datatype fname = 46 | | FNM0 of (string) 47 | // 48 | typedef 49 | fnameopt = Option(fname) 50 | vtypedef 51 | fnameopt_vt = Option_vt(fname) 52 | // 53 | (* ****** ****** *) 54 | 55 | fun 56 | print_fname : print_type(fname) 57 | fun 58 | prerr_fname : prerr_type(fname) 59 | fun 60 | fprint_fname : fprint_type(fname) 61 | 62 | (* ****** ****** *) 63 | 64 | fun 65 | filsrch_absolut 66 | (base: string): Option_vt(filpath) 67 | fun 68 | filsrch_current 69 | (base: string): Option_vt(filpath) 70 | fun 71 | filsrch_includes 72 | (base: string): Option_vt(filpath) 73 | 74 | (* ****** ****** *) 75 | 76 | fun 77 | filsrch_combined 78 | (fnm0: fname): Option_vt(filpath) 79 | 80 | (* ****** ****** *) 81 | // 82 | fun 83 | filsrch_dirbase 84 | ( dir: dirpath 85 | , base: string): Option_vt(filpath) 86 | fun 87 | filsrch_dirsbase 88 | ( dirs 89 | : List(dirpath) 90 | , base: string): Option_vt(filpath) 91 | // 92 | (* ****** ****** *) 93 | 94 | (* end of [xats_filsrch.sats] *) 95 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/lexbuf0.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: May, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | %{# 37 | #include "CATS/lexbuf0.cats" 38 | %} // end of [%{#] 39 | 40 | (* ****** ****** *) 41 | // 42 | #staload CBS = 43 | "./../../xutl/SATS/cblist.sats" 44 | // 45 | typedef cblist = $CBS.cblist 46 | // 47 | (* ****** ****** *) 48 | // 49 | #staload LOC = "./locinfo.sats" 50 | // 51 | typedef pos_t = $LOC.pos_t 52 | typedef loc_t = $LOC.loc_t 53 | typedef position = $LOC.position 54 | typedef location = $LOC.location 55 | // 56 | (* ****** ****** *) 57 | // 58 | abstflt 59 | lexbuf_tflt = 60 | $extype"xats_lexbuf_struct" 61 | // 62 | typedef lexbuf = lexbuf_tflt 63 | // 64 | (* ****** ****** *) 65 | 66 | fun 67 | lexbuf_initize_cblist 68 | ( 69 | buf: &lexbuf? >> _, cbs: cblist 70 | ) : void // end of [lexbuf_initize_cblist] 71 | 72 | (* ****** ****** *) 73 | // 74 | (* 75 | fun 76 | lexbuf_get_ntot(buf: &lexbuf): int 77 | fun 78 | lexbuf_get_nspc(buf: &lexbuf): int 79 | *) 80 | // 81 | (* ****** ****** *) 82 | // 83 | fun 84 | lexbuf_get_none 85 | (buf: &lexbuf >> _): void 86 | fun 87 | lexbuf_get_fullseg 88 | (buf: &lexbuf >> _): string 89 | // 90 | (* ****** ****** *) 91 | // 92 | // HX-2018-05-27: 93 | // [lexbuf_getc] is like getc 94 | // [lexbuf_unget] can be safely 95 | // applied only once at a given 96 | // position! 97 | // 98 | fun 99 | lexbuf_getc(buf: &lexbuf >> _): int 100 | fun 101 | lexbuf_unget 102 | (buf: &lexbuf >> _, i0: int): void 103 | // 104 | (* ****** ****** *) 105 | // 106 | (* 107 | fun 108 | lexbuf_get_pos 109 | ( 110 | buf: &lexbuf, pos: &pos_t? >> _ 111 | ) : void // end-of-fun 112 | *) 113 | // 114 | (* 115 | fun 116 | lexbuf_set_pos 117 | (buf: &lexbuf >> _, pos: &pos_t): void 118 | *) 119 | // 120 | (* ****** ****** *) 121 | (* 122 | // 123 | fun 124 | lexbufpos_get_loc 125 | (buf: &lexbuf, pos: &pos_t): loc_t 126 | // 127 | *) 128 | (* ****** ****** *) 129 | 130 | (* end of [xats_lexbuf0.sats] *) 131 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/nmspace.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: November, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | abstbox nmitm_tbox = ptr 37 | typedef nmitm = nmitm_tbox 38 | 39 | (* ****** ****** *) 40 | // 41 | fun the_nmspace_top(): nmitm 42 | // 43 | fun the_nmspace_ins(nmitm): void 44 | // 45 | (* ****** ****** *) 46 | 47 | fun the_nmspace_pop(): void 48 | fun the_nmspace_push(): void 49 | 50 | (* ****** ****** *) 51 | 52 | fun the_nmspace_savecur(): void 53 | fun the_nmspace_restore(): void 54 | 55 | (* ****** ****** *) 56 | 57 | fun the_nmspace_locjoin(): void 58 | 59 | (* ****** ****** *) 60 | 61 | fun 62 | the_nmspace_find{a:type} 63 | (fopr: nmitm - Option_vt(a)): Option_vt(a) 64 | // end of [the_nmspace_find] 65 | 66 | (* ****** ****** *) 67 | 68 | (* end of [xats_nmspace.sats] *) 69 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/tread23.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2019 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: September, 2019 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | #staload "./staexp1.sats" 37 | #staload "./dynexp1.sats" 38 | 39 | (* ****** ****** *) 40 | 41 | #staload "./staexp2.sats" 42 | #staload "./statyp2.sats" 43 | #staload "./dynexp2.sats" 44 | #staload "./dynexp3.sats" 45 | 46 | (* ****** ****** *) 47 | // 48 | typedef 49 | treader23 50 | (a:t@ype) = (a) -> void 51 | // 52 | (* ****** ****** *) 53 | // 54 | datatype trerr23 = 55 | // 56 | | TRERR23s2exp of (s2exp) 57 | // 58 | | TRERR23d3pat of (d3pat) 59 | | TRERR23d3exp of (d3exp) 60 | // 61 | | TRERR23f3arg of (f3arg) 62 | | TRERR23d3ecl of (d3ecl) 63 | // 64 | typedef 65 | trerr23lst = List0(trerr23) 66 | // 67 | (* ****** ****** *) 68 | // 69 | fun//{} 70 | trerr23_add(trerr23): void 71 | // 72 | (* ****** ****** *) 73 | // 74 | fun 75 | tread23_package 76 | ( p3kg: d3transd ): void 77 | // 78 | (* ****** ****** *) 79 | // 80 | fun//{} 81 | tread23_d3exp: treader23(d3exp) 82 | fun//{} 83 | tread23_d3explst: treader23(d3explst) 84 | // 85 | (* ****** ****** *) 86 | // 87 | fun//{} 88 | tread23_d3ecl: treader23(d3ecl) 89 | fun//{} 90 | tread23_d3eclist: treader23(d3eclist) 91 | // 92 | (* ****** ****** *) 93 | // 94 | // HX-2020-07-02: 95 | // The following functions is expected 96 | // to be CONTRIBUTED. 97 | // 98 | (* ****** ****** *) 99 | // 100 | fun//{} 101 | tread23_d3ecl_D3Clocal: treader23(d3ecl) 102 | // 103 | (* ****** ****** *) 104 | 105 | (* end of [xats_tread23.sats] *) 106 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/tread34.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2021 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: January, 2021 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | #staload "./staexp1.sats" 37 | #staload "./dynexp1.sats" 38 | 39 | (* ****** ****** *) 40 | 41 | #staload "./staexp2.sats" 42 | #staload "./statyp2.sats" 43 | #staload "./dynexp2.sats" 44 | #staload "./dynexp3.sats" 45 | #staload "./dynexp4.sats" 46 | 47 | (* ****** ****** *) 48 | // 49 | typedef 50 | treader34 51 | (a:t@ype) = (a) -> void 52 | // 53 | (* ****** ****** *) 54 | // 55 | datatype trerr34 = 56 | // 57 | | TRERR34d4pat of (d4pat) 58 | | TRERR34d4exp of (d4exp) 59 | // 60 | typedef 61 | trerr34lst = List0(trerr34) 62 | // 63 | (* ****** ****** *) 64 | // 65 | fun//{} 66 | trerr34_add(trerr34): void 67 | // 68 | (* ****** ****** *) 69 | // 70 | fun 71 | tread34_package 72 | ( p4kg: d4transd ): void 73 | // 74 | (* ****** ****** *) 75 | // 76 | fun//{} 77 | tread34_d4pat: treader34(d4pat) 78 | fun//{} 79 | tread34_d4patlst: treader34(d4patlst) 80 | // 81 | (* ****** ****** *) 82 | // 83 | fun//{} 84 | tread34_d4exp: treader34(d4exp) 85 | fun//{} 86 | tread34_d4explst: treader34(d4explst) 87 | fun//{} 88 | tread34_d4expopt: treader34(d4expopt) 89 | // 90 | (* ****** ****** *) 91 | // 92 | fun//{} 93 | tread34_d4ecl: treader34(d4ecl) 94 | fun//{} 95 | tread34_d4eclist: treader34(d4eclist) 96 | // 97 | (* ****** ****** *) 98 | 99 | fun//{} 100 | tread34_v4aldecl: treader34(v4aldecl) 101 | fun//{} 102 | tread34_v4aldeclist: treader34(v4aldeclist) 103 | 104 | (* ****** ****** *) 105 | 106 | fun//{} 107 | tread34_v4ardecl: treader34(v4ardecl) 108 | fun//{} 109 | tread34_v4ardeclist: treader34(v4ardeclist) 110 | 111 | (* ****** ****** *) 112 | 113 | fun//{} 114 | tread34_f4undecl: treader34(f4undecl) 115 | fun//{} 116 | tread34_f4undeclist: treader34(f4undeclist) 117 | 118 | (* ****** ****** *) 119 | 120 | (* end of [xats_tread34.sats] *) 121 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/tread3t.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: September, 2019 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | #staload "./staexp1.sats" 37 | #staload "./dynexp1.sats" 38 | 39 | (* ****** ****** *) 40 | 41 | #staload "./staexp2.sats" 42 | #staload "./statyp2.sats" 43 | #staload "./dynexp2.sats" 44 | #staload "./dynexp3.sats" 45 | 46 | (* ****** ****** *) 47 | // 48 | typedef 49 | treader3t 50 | (a:t@ype) = (a) -> void 51 | // 52 | (* ****** ****** *) 53 | // 54 | datatype trerr3t = 55 | // 56 | | TRERR3Td3pat of (d3pat) 57 | | TRERR3Td3exp of (d3exp) 58 | // 59 | | TRERR3Tf3arg of (f3arg) 60 | | TRERR3Td3ecl of (d3ecl) 61 | // 62 | typedef 63 | trerr3tlst = List0(trerr3t) 64 | // 65 | (* ****** ****** *) 66 | // 67 | fun//{} 68 | trerr3t_add(trerr3t): void 69 | // 70 | (* ****** ****** *) 71 | // 72 | fun 73 | tread3t_main(d3eclist): void 74 | // 75 | (* ****** ****** *) 76 | 77 | (* end of [xats_tread3t.sats] *) 78 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/tread3x.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2019 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: September, 2019 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | #staload "./staexp1.sats" 37 | #staload "./dynexp1.sats" 38 | 39 | (* ****** ****** *) 40 | 41 | #staload "./staexp2.sats" 42 | #staload "./statyp2.sats" 43 | #staload "./dynexp2.sats" 44 | #staload "./dynexp3.sats" 45 | 46 | (* ****** ****** *) 47 | // 48 | typedef 49 | treader3x 50 | (a:t@ype) = (a) -> void 51 | // 52 | (* ****** ****** *) 53 | // 54 | datatype trerr3x = 55 | // 56 | | TRERR3Xd3pat of (d3pat) 57 | | TRERR3Xd3exp of (d3exp) 58 | // 59 | | TRERR3Xf3arg of (f3arg) 60 | | TRERR3Xd3ecl of (d3ecl) 61 | // 62 | | TRERR3Xd3exp_tcst of (d3exp) 63 | // 64 | | TRERR3Xd3exp_terr of (d3exp) 65 | // 66 | | TRERR3Xd3exp_tapp of (d3exp) 67 | | TRERR3Xd3exp_timp2f of (d3exp, f3undecl) 68 | // 69 | typedef 70 | trerr3xlst = List0(trerr3x) 71 | // 72 | (* ****** ****** *) 73 | // 74 | fun//{} 75 | trerr3x_add(trerr3x): void 76 | // 77 | (* ****** ****** *) 78 | // 79 | fun 80 | tread3x_package 81 | ( p3kg: d3transd ): void 82 | // 83 | (* ****** ****** *) 84 | // 85 | fun//{} 86 | tread3x_d3pat: treader3x(d3pat) 87 | fun//{} 88 | tread3x_d3patlst: treader3x(d3patlst) 89 | // 90 | (* ****** ****** *) 91 | // 92 | fun//{} 93 | tread3x_d3exp: treader3x(d3exp) 94 | fun//{} 95 | tread3x_d3explst: treader3x(d3explst) 96 | fun//{} 97 | tread3x_d3expopt: treader3x(d3expopt) 98 | // 99 | (* ****** ****** *) 100 | // 101 | fun//{} 102 | tread3x_d3gua: treader3x(d3gua) 103 | fun//{} 104 | tread3x_d3gpat: treader3x(d3gpat) 105 | fun//{} 106 | tread3x_d3clau: treader3x(d3clau) 107 | fun//{} 108 | tread3x_d3gualst: treader3x(d3gualst) 109 | fun//{} 110 | tread3x_d3claulst: treader3x(d3claulst) 111 | // 112 | (* ****** ****** *) 113 | // 114 | fun//{} 115 | tread3x_d3ecl: treader3x(d3ecl) 116 | fun//{} 117 | tread3x_d3eclist: treader3x(d3eclist) 118 | // 119 | (* ****** ****** *) 120 | 121 | fun//{} 122 | tread3x_v3aldecl: treader3x(v3aldecl) 123 | fun//{} 124 | tread3x_v3aldeclist: treader3x(v3aldeclist) 125 | 126 | (* ****** ****** *) 127 | 128 | fun//{} 129 | tread3x_v3ardecl: treader3x(v3ardecl) 130 | fun//{} 131 | tread3x_v3ardeclist: treader3x(v3ardeclist) 132 | 133 | (* ****** ****** *) 134 | 135 | fun//{} 136 | tread3x_f3undecl: treader3x(f3undecl) 137 | fun//{} 138 | tread3x_f3undeclist: treader3x(f3undeclist) 139 | 140 | (* ****** ****** *) 141 | 142 | (* end of [xats_tread3x.sats] *) 143 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/xerrory.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: August, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | exception 37 | FatalErrorExn of () 38 | exception 39 | FatalErrorExn_interr of () 40 | // 41 | (* ****** ****** *) 42 | // 43 | exception 44 | XATSOPT_FIXITY_EXN of ((*void*)) 45 | // 46 | (* ****** ****** *) 47 | // 48 | exception 49 | XATSOPT_SYNERR_EXN of ((*void*)) 50 | // 51 | (* ****** ****** *) 52 | // 53 | exception 54 | XATSOPT_TRERR01_EXN of ((*void*)) 55 | exception 56 | XATSOPT_TRERR12_EXN of ((*void*)) 57 | exception 58 | XATSOPT_TRERR23_EXN of ((*void*)) 59 | exception 60 | XATSOPT_TRERR33_EXN of ((*void*)) 61 | exception 62 | XATSOPT_TRERR3X_EXN of ((*void*)) 63 | // 64 | exception 65 | XATSOPT_TRERR34_EXN of ((*void*)) 66 | // 67 | (* ****** ****** *) 68 | // 69 | // HX: 70 | // raising FatalErrorException 71 | // raising FatalErrorException_interr 72 | // 73 | fun abort((*void*)): void 74 | fun abort_interr((*void*)): void 75 | // 76 | (* ****** ****** *) 77 | 78 | (* end of [xats_xerrory.sats] *) 79 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/xglobal.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: July, 2019 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | #staload 36 | FP0 = "./filpath.sats" 37 | (* ****** ****** *) 38 | typedef 39 | filpath = $FP0.filpath 40 | (* ****** ****** *) 41 | abstbox 42 | fpathenv_tbox = ptr 43 | typedef 44 | fpathenv = fpathenv_tbox 45 | (* ****** ****** *) 46 | // 47 | fun 48 | fpathenv_get_level 49 | ( fpenv: fpathenv ) : int 50 | // 51 | fun 52 | fpathenv_inc_level 53 | ( fpenv: fpathenv ) : void 54 | fun 55 | fpathenv_dec_level 56 | ( fpenv: fpathenv ) : void 57 | // 58 | (* ****** ****** *) 59 | // 60 | fun 61 | the_XATSHOME_get(): string 62 | // 63 | (* ****** ****** *) 64 | // 65 | fun 66 | the_global_level 67 | ((*void*)): int//top:0/err:-1 68 | // 69 | (* ****** ****** *) 70 | fun 71 | the_global_fpiadd1 72 | (fpath: filpath): void 73 | (* ****** ****** *) 74 | // 75 | fun 76 | the_global_fpsrch0 77 | ((*current*)): Option_vt(fpathenv) 78 | fun 79 | the_global_fpsrch1 80 | (fpath: filpath): Option_vt(fpathenv) 81 | // 82 | (* ****** ****** *) 83 | 84 | (* end of [xats_xglobal.sats] *) 85 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/xlabel0.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: July, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | #staload 37 | SYM = "./xsymbol.sats" 38 | 39 | (* ****** ****** *) 40 | // 41 | abstbox label_tbox = ptr 42 | // 43 | typedef label = label_tbox 44 | // 45 | typedef symbol = $SYM.symbol 46 | // 47 | (* ****** ****** *) 48 | // 49 | fun 50 | eq_label_label 51 | (l1: label, l2: label): bool 52 | // 53 | overload = with eq_label_label 54 | // 55 | (* ****** ****** *) 56 | // 57 | fun 58 | print_label : print_type(label) 59 | fun 60 | prerr_label : prerr_type(label) 61 | fun 62 | fprint_label : fprint_type(label) 63 | // 64 | overload print with print_label 65 | overload prerr with prerr_label 66 | overload fprint with fprint_label 67 | // 68 | (* ****** ****** *) 69 | // 70 | val label_nil : label 71 | // 72 | fun 73 | label_make_int(i0: int): label 74 | fun 75 | label_make_sym(i0: symbol): label 76 | fun 77 | label_make_name(s0: string): label 78 | // 79 | (* ****** ****** *) 80 | // 81 | fun 82 | label_is_int(l0: label): bool 83 | fun 84 | label_is_sym(l0: label): bool 85 | // 86 | (* ****** ****** *) 87 | // 88 | fun 89 | label_get_int 90 | (l0: label): Option_vt(int) 91 | fun 92 | label_get_sym 93 | (l0: label): Option_vt(symbol) 94 | // 95 | overload .int with label_get_int 96 | overload .sym with label_get_sym 97 | // 98 | (* ****** ****** *) 99 | 100 | fun label_dotize(l0: label): symbol 101 | 102 | (* ****** ****** *) 103 | 104 | (* end of [xats_xlabel0.sats] *) 105 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/xstamp0.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: October, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | abstype 37 | stamp_type = ptr 38 | // 39 | typedef stamp = stamp_type 40 | typedef stampopt = Option(stamp) 41 | // 42 | (* ****** ****** *) 43 | 44 | val the_stamp0 : stamp 45 | 46 | (* ****** ****** *) 47 | // 48 | fun 49 | stamp2uint(stamp):<> uint 50 | // 51 | overload .uint with stamp2uint 52 | // 53 | (* ****** ****** *) 54 | // 55 | fun 56 | lt_stamp_stamp 57 | (x1: stamp, x2: stamp):<> bool 58 | fun 59 | lte_stamp_stamp 60 | (x1: stamp, x2: stamp):<> bool 61 | // 62 | fun 63 | eq_stamp_stamp 64 | (x1: stamp, x2: stamp):<> bool 65 | fun 66 | neq_stamp_stamp 67 | (x1: stamp, x2: stamp):<> bool 68 | // 69 | fun 70 | cmp_stamp_stamp 71 | (x1: stamp, x2: stamp):<> (int) 72 | // 73 | overload < with lt_stamp_stamp 74 | overload <= with lte_stamp_stamp 75 | // 76 | overload = with eq_stamp_stamp 77 | overload != with neq_stamp_stamp 78 | // 79 | overload compare with cmp_stamp_stamp 80 | // 81 | (* ****** ****** *) 82 | // 83 | fun print_stamp: print_type(stamp) 84 | fun prerr_stamp: prerr_type(stamp) 85 | fun fprint_stamp: fprint_type(stamp) 86 | // 87 | (* ****** ****** *) 88 | 89 | abstype stamper_tbox = ptr 90 | typedef stamper = stamper_tbox 91 | 92 | (* ****** ****** *) 93 | 94 | fun 95 | stamper_new((*void*)): stamper 96 | 97 | (* ****** ****** *) 98 | // 99 | fun 100 | stamper_set 101 | (obj: stamper, n0: uint): void 102 | // 103 | (* ****** ****** *) 104 | 105 | fun 106 | stamper_getinc(obj: stamper): stamp 107 | 108 | (* ****** ****** *) 109 | 110 | (* end of [xats_xstamp0.sats] *) 111 | -------------------------------------------------------------------------------- /srcgen/xats/SATS/xsymmap.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: August, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #staload 37 | SYM = "./xsymbol.sats" 38 | // 39 | typedef sym_t = $SYM.sym_t 40 | // 41 | (* ****** ****** *) 42 | // 43 | absvtype 44 | symmap_vtype(itm:type) = ptr 45 | vtypedef 46 | symmap(itm:type) = symmap_vtype(itm) 47 | // 48 | (* ****** ****** *) 49 | // 50 | fun 51 | symmap_make_nil 52 | {itm:type}(): symmap(itm) 53 | // 54 | (* ****** ****** *) 55 | // 56 | fun 57 | symmap_free 58 | {itm:type} 59 | (map: symmap(itm)): void 60 | // 61 | (* ****** ****** *) 62 | 63 | fun 64 | symmap_search 65 | {itm:type} 66 | ( 67 | kxs: !symmap(itm), k0: sym_t 68 | ) :<> Option_vt(itm) // end-of-fun 69 | 70 | (* ****** ****** *) 71 | 72 | fun 73 | symmap_insert 74 | {itm:type} 75 | ( 76 | kxs: &symmap(itm), k0: sym_t, x0: itm 77 | ) :<> void // end of [symmap_insert] 78 | 79 | (* ****** ****** *) 80 | 81 | fun 82 | symmap_insert2 83 | {itm:type} 84 | ( kxs: &symmap(itm) 85 | , key: sym_t, itm: itm, mix: (itm, itm) -<0> itm 86 | ) :<> void // end of [symmap_insert2] 87 | 88 | (* ****** ****** *) 89 | // 90 | fun 91 | symmap_joinwth 92 | {itm:type} 93 | (m1: &symmap(itm), m2: !symmap(itm)): void 94 | // end of [symmap_joinwth] 95 | // 96 | (* ****** ****** *) 97 | 98 | fun 99 | fprint_symmap 100 | {itm:type} 101 | ( out: FILEref 102 | , map: !symmap(itm), fpr: (FILEref, itm) -> void 103 | ) : void // end of [fprint_symmap] 104 | 105 | (* ****** ****** *) 106 | 107 | (* end of [xats_xsymmap.sats] *) 108 | -------------------------------------------------------------------------------- /srcgen/xats/TEST/Makefile_test: -------------------------------------------------------------------------------- 1 | ###### 2 | # 3 | # For testing xatsopt 4 | # 5 | ###### 6 | all:: 7 | ###### 8 | MAKE=make 9 | ###### 10 | XATSOPT=./../xatsopt 11 | ###### 12 | all:: \ 13 | prelude 14 | prelude:: ; \ 15 | $(MAKE) XATSOPT=$(XATSOPT) -f Makefile_prelude > /dev/null 16 | ###### 17 | all:: \ 18 | xatslib 19 | xatslib:: ; \ 20 | $(MAKE) XATSOPT=$(XATSOPT) -f Makefile_xatslib > /dev/null 21 | ###### 22 | ###### end of [Makefile_test] ###### 23 | -------------------------------------------------------------------------------- /srcgen/xats/TEST/Makefile_xatslib: -------------------------------------------------------------------------------- 1 | ###### 2 | # 3 | # For testing 4 | # the files in xatslib 5 | # 6 | ###### 7 | 8 | XATSOPT=./../xatsopt 9 | PRELUDE=./../../../prelude 10 | XATSLIB=./../../../xatslib 11 | 12 | ###### 13 | 14 | all:: all_libc 15 | all:: all_githwxi 16 | 17 | ###### 18 | all_libc:: ; \ 19 | $(XATSOPT) -s $(XATSLIB)/libc/SATS/libc.sats 20 | ###### 21 | all_libc:: ; \ 22 | $(XATSOPT) -d $(XATSLIB)/libc/DATS/gios.dats 23 | all_libc:: ; \ 24 | $(XATSOPT) -d $(XATSLIB)/libc/DATS/rand.dats 25 | all_libc:: ; \ 26 | $(XATSOPT) -d $(XATSLIB)/libc/DATS/fpath.dats 27 | all_libc:: ; \ 28 | $(XATSOPT) -d $(XATSLIB)/libc/DATS/stdio.dats 29 | ###### 30 | all_githwxi:: ; \ 31 | $(XATSOPT) -s $(XATSLIB)/githwxi/SATS/githwxi.sats 32 | ###### 33 | all_githwxi:: ; \ 34 | $(XATSOPT) -d $(XATSLIB)/githwxi/DATS/mygist.dats 35 | all_githwxi:: ; \ 36 | $(XATSOPT) -d $(XATSLIB)/githwxi/DATS/mytest.dats 37 | ###### 38 | all_githwxi:: ; \ 39 | $(XATSOPT) -d $(XATSLIB)/githwxi/DATS/gtree1.dats 40 | all_githwxi:: ; \ 41 | $(XATSOPT) -d $(XATSLIB)/githwxi/DATS/dvdcnq.dats 42 | all_githwxi:: ; \ 43 | $(XATSOPT) -d $(XATSLIB)/githwxi/DATS/parcmbr1.dats 44 | ###### 45 | 46 | ###### end of [Makefile_xatslib] ###### 47 | -------------------------------------------------------------------------------- /srcgen/xutl/DATS/Windows/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xanadu-lang/xanadu/ae89a3b3b63e0a8d24ac234f8f715c4fec265992/srcgen/xutl/DATS/Windows/.gitkeep -------------------------------------------------------------------------------- /srcgen/xutl/DATS/cblist.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: April, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | #staload 37 | UN = "prelude/SATS/unsafe.sats" 38 | // 39 | (* ****** ****** *) 40 | 41 | #staload "./../SATS/cblist.sats" 42 | 43 | (* ****** ****** *) 44 | // 45 | implement 46 | string2cblist(cs) = 47 | ( 48 | cblist_cons(n0, cs, nil) 49 | ) where 50 | { 51 | val n0 = length(cs) 52 | val cs = $UN.cast(cs) 53 | val nil = cblist_nil() 54 | } (* end of [string2cblist] *) 55 | // 56 | (* ****** ****** *) 57 | 58 | implement 59 | cblist_length 60 | (cbs) = loop(cbs, 0) where 61 | { 62 | // 63 | fun 64 | loop 65 | (cbs: cblist, res: Nat): Nat = 66 | ( 67 | case+ cbs of 68 | | cblist_nil() => res 69 | | cblist_cons(_, _, cbs) => loop(cbs, res+1) 70 | ) 71 | // 72 | } (* end of [cblist_length] *) 73 | 74 | (* ****** ****** *) 75 | // 76 | implement 77 | cblist_vt_length 78 | (cbs) = 79 | cblist_length($UN.castvwtp1{cblist}(cbs)) 80 | // 81 | (* ****** ****** *) 82 | 83 | implement 84 | {}(*tmp*) 85 | cblist_foreach 86 | (cbs) = loop(cbs) where 87 | { 88 | // 89 | fun 90 | loop 91 | (cbs: cblist): void = 92 | ( 93 | case+ cbs of 94 | | cblist_nil() => () 95 | | cblist_cons(n, cs, cbs) => 96 | ( 97 | cblist_foreach$fwork<>(n, cs); loop(cbs) 98 | ) 99 | ) 100 | // 101 | } (* end of [cblist_foreach] *) 102 | 103 | (* ****** ****** *) 104 | 105 | (* end of [cblist.dats] *) 106 | -------------------------------------------------------------------------------- /srcgen/xutl/SATS/Posix/cblist.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: April, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | #staload "./../cblist.sats" 37 | 38 | (* ****** ****** *) 39 | // 40 | fun{} 41 | fpath_get_cblist 42 | (inp: string, bsz: Size): Option_vt(cblist) 43 | fun{} 44 | fpath_get_cblist_vt 45 | (inp: string, bsz: Size): Option_vt(cblist_vt) 46 | // 47 | (* ****** ****** *) 48 | // 49 | fun//{} 50 | fileref_get_cblist 51 | (inp: FILEref, bsz: Size): Option_vt(cblist) 52 | fun//{} 53 | fileref_get_cblist_vt 54 | (inp: FILEref, bsz: Size): Option_vt(cblist_vt) 55 | // 56 | (* ****** ****** *) 57 | 58 | (* end of [Posix_cblist.sats] *) 59 | -------------------------------------------------------------------------------- /srcgen/xutl/SATS/Windows/cblist.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: April, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | 36 | #staload "./../cblist.sats" 37 | 38 | (* ****** ****** *) 39 | // 40 | fun 41 | fpath_get_cblist(inp: string): Option_vt(cblist) 42 | (* 43 | fun 44 | fileref_get_cblist(inp: FILEref): Option_vt(cblist) 45 | *) 46 | // 47 | (* ****** ****** *) 48 | 49 | (* end of [Windows_cblist.sats] *) 50 | -------------------------------------------------------------------------------- /srcgen/xutl/SATS/cblist.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: April, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | datatype 37 | cblist = 38 | | cblist_nil of () 39 | | {n:pos} 40 | cblist_cons of 41 | (size_t(n), arrayref(uchar, n), cblist) 42 | // 43 | datavtype 44 | cblist_vt = 45 | | cblist_vt_nil of () 46 | | {n:pos} 47 | cblist_vt_cons of 48 | (size_t(n), arrayptr(uchar, n), cblist_vt) 49 | // 50 | (* ****** ****** *) 51 | // 52 | castfn 53 | clist_vt2t(cbs: cblist_vt): cblist 54 | // 55 | (* ****** ****** *) 56 | // 57 | fun 58 | string2cblist 59 | {n:pos}(text: string(n)): cblist 60 | // 61 | (* ****** ****** *) 62 | // 63 | fun 64 | cblist_length(cbs: cblist): intGte(0) 65 | fun 66 | cblist_vt_length(cbs: !cblist_vt): intGte(0) 67 | // 68 | overload length with cblist_length 69 | overload length with cblist_vt_length 70 | // 71 | (* ****** ****** *) 72 | 73 | fun cblist_vt_free(cbs: cblist_vt): void 74 | 75 | (* ****** ****** *) 76 | 77 | fun{} 78 | cblist_foreach(cbs: cblist): void 79 | fun{} 80 | cblist_foreach$fwork{n:int}(size_t(n), arrayref(uchar, n)): void 81 | // 82 | overload foreach with cblist_foreach 83 | // 84 | (* ****** ****** *) 85 | 86 | (* end of [cblist.sats] *) 87 | -------------------------------------------------------------------------------- /srcgen/xutl/SATS/mylibc.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2018 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: April, 2018 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | fun 37 | xatsopt_memcpy 38 | ( dst: ptr 39 | , src: ptr 40 | , nbyte: Size_t): ptr = "ext#xatsopt_memcpy" 41 | // 42 | (* ****** ****** *) 43 | // 44 | (* 45 | char *strchr(const char *s, int c); 46 | char *strrchr(const char *s, int c); 47 | *) 48 | // 49 | fun 50 | xatsopt_strchr 51 | (cs: ptr, c0: int): ptr = "ext#xatsopt_strchr" 52 | fun 53 | xatsopt_strrchr 54 | (cs: ptr, c0: int): ptr = "ext#xatsopt_strrchr" 55 | // 56 | (* ****** ****** *) 57 | // 58 | fun 59 | xatsopt_chrunq // '' -> 60 | (source: string): char = "ext#xatsopt_chrunq" 61 | fun 62 | xatsopt_strunq // "" -> 63 | (source: string): string = "ext#xatsopt_strunq" 64 | // 65 | (* ****** ****** *) 66 | // 67 | fun 68 | xatsopt_strbtwe 69 | (p0: ptr, p1: ptr): string = "ext#xatsopt_strbtwe" 70 | // 71 | (* ****** ****** *) 72 | // 73 | (* 74 | int 75 | strcmp(const char *s1, const char *s2); 76 | int 77 | strncmp(const char *s1, const char *s2, size_t n); 78 | *) 79 | // 80 | fun 81 | xatsopt_strcmp 82 | (cs1: ptr, cs2: ptr): int = "ext#xatsopt_strcmp" 83 | fun 84 | xatsopt_strncmp 85 | ( cs1: ptr 86 | , cs2: ptr, nlen: size_t): int = "ext#xatsopt_strncmp" 87 | // 88 | (* ****** ****** *) 89 | // 90 | fun 91 | xatsopt_getcwd 92 | ( buf: ptr 93 | , bsz: size_t): ptr = "ext#xatsopt_getcwd" 94 | fun 95 | xatsopt_getcwd_gc 96 | ((*void*)): Strptr0 = "ext#xatsopt_getcwd_gc" 97 | // 98 | (* ****** ****** *) 99 | // 100 | fun 101 | xatsopt_getenv 102 | (key: string): ptr = "ext#xatsopt_getenv" 103 | fun 104 | xatsopt_getenv_gc 105 | (key: string): Strptr0 = "ext#xatsopt_getenv_gc" 106 | // 107 | (* ****** ****** *) 108 | // 109 | fun 110 | xatsopt_is_exist 111 | (fpath: string): bool = "ext#xatsopt_is_exist" 112 | // 113 | (* ****** ****** *) 114 | 115 | (* end of [mylibc.sats] *) 116 | -------------------------------------------------------------------------------- /srcgen/xutl/TEST/Makefile: -------------------------------------------------------------------------------- 1 | ###### 2 | # 3 | # A simple Makefile 4 | # 5 | ###### 6 | 7 | PATSCC=$(PATSHOME)/bin/patscc 8 | PATSOPT=$(PATSHOME)/bin/patsopt 9 | MYATSCC=$(PATSHOME)/bin/myatscc 10 | 11 | ###### 12 | 13 | all:: 14 | 15 | ###### 16 | 17 | all:: \ 18 | cblist 19 | 20 | cblist: \ 21 | cblist_dats 22 | cblist_dats: \ 23 | cblist.dats; $(MYATSCC) $< 24 | regress:: \ 25 | cblist_dats; ./cblist_dats 26 | cleanall:: ; $(RMF) cblist_dats 27 | 28 | ###### 29 | 30 | testall:: all 31 | testall:: regress 32 | testall:: cleanall 33 | 34 | ###### 35 | 36 | RMF=rm -f 37 | 38 | ###### 39 | 40 | ###### end of [Makefile] ###### 41 | -------------------------------------------------------------------------------- /srcgen/xutl/TEST/Posix/DATA/test_cblist.txt: -------------------------------------------------------------------------------- 1 | hello world 2 | 3 | for cblist?! 4 | -------------------------------------------------------------------------------- /srcgen/xutl/TEST/Posix/Makefile: -------------------------------------------------------------------------------- 1 | ###### 2 | # 3 | # A simple Makefile 4 | # 5 | ###### 6 | 7 | PATSCC=$(PATSHOME)/bin/patscc 8 | PATSOPT=$(PATSHOME)/bin/patsopt 9 | MYATSCC=$(PATSHOME)/bin/myatscc 10 | 11 | ###### 12 | 13 | all:: 14 | 15 | ###### 16 | 17 | all:: \ 18 | test_cblist 19 | 20 | ###### 21 | 22 | test_cblist: \ 23 | test_cblist_dats 24 | test_cblist_dats: \ 25 | test_cblist.dats; $(MYATSCC) $< 26 | regress:: \ 27 | test_cblist_dats; ./test_cblist_dats 28 | cleanall:: ; $(RMF) test_cblist_dats 29 | 30 | ###### 31 | 32 | test_mylibc: \ 33 | test_mylibc_dats 34 | test_mylibc_dats: \ 35 | test_mylibc.dats; $(MYATSCC) $< 36 | regress:: \ 37 | test_mylibc_dats; ./test_mylibc_dats 38 | cleanall:: ; $(RMF) test_mylibc_dats 39 | 40 | ###### 41 | 42 | testall:: all 43 | testall:: regress 44 | testall:: cleanall 45 | 46 | ###### 47 | 48 | RMF=rm -f 49 | 50 | ###### 51 | 52 | ###### end of [Makefile] ###### 53 | -------------------------------------------------------------------------------- /srcgen/xutl/TEST/Posix/test_cblist.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** HX-2018-05-16 4 | ** Unit testing. Kind of. 5 | *) 6 | (* ****** ****** *) 7 | // 8 | #include 9 | "share/atspre_staload.hats" 10 | // 11 | (* ****** ****** *) 12 | // 13 | #staload 14 | "./../../SATS/cblist.sats" 15 | #staload 16 | "./../../SATS/Posix/cblist.sats" 17 | // 18 | #staload 19 | "./../../DATS/cblist.dats" 20 | #staload 21 | "./../../DATS/Posix/cblist.dats" 22 | // 23 | (* ****** ****** *) 24 | 25 | local 26 | // 27 | #include "./../../DATS/cblist.dats" 28 | #include "./../../DATS/Posix/cblist.dats" 29 | // 30 | in 31 | // nothing 32 | end // end of [local] 33 | 34 | (* ****** ****** *) 35 | 36 | implement main0() = 37 | { 38 | #define BUFSIZE 16 39 | val opt = 40 | fpath_get_cblist 41 | ("./DATA/test_cblist.txt", i2sz(BUFSIZE)) 42 | val-~Some_vt(cbs) = opt 43 | 44 | val () = assert (2 = length(cbs)) 45 | 46 | val () = foreach(cbs) where 47 | { 48 | val r = ref(0) 49 | val out = stdout_ref 50 | implement 51 | fprint_array$sep<> 52 | (out) = ((*void*)) 53 | implement 54 | cblist_foreach$fwork<> 55 | (n, cs) = 56 | let 57 | val () = 58 | assertloc 59 | (n <= i2sz(BUFSIZE)) 60 | implement 61 | tostrptr_val(x) = tostrptr_char(uchar2char0 x) 62 | val x = 63 | tostrptr_arrayref(cs, n) 64 | val x = strptr2string(x) 65 | in 66 | if 67 | (r[] = 0) 68 | then 69 | assertloc 70 | ("hello world\n\nfor"=x) 71 | else 72 | assertloc( " cblist?!\n" = x ); 73 | // end of [if] 74 | r[] := succ(r[]) 75 | end // end of [cblist_foreach$fwork] 76 | } 77 | } (* end of [main0] *) 78 | 79 | (* ****** ****** *) 80 | 81 | (* end of [test_cblist.dats] *) 82 | -------------------------------------------------------------------------------- /srcgen/xutl/TEST/Posix/test_mylibc.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** HX-2018-05-16 4 | ** Unit testing. Kind of. 5 | *) 6 | (* ****** ****** *) 7 | // 8 | #include 9 | "share/atspre_staload.hats" 10 | // 11 | (* ****** ****** *) 12 | // 13 | #staload 14 | "./../../SATS/mylibc.sats" 15 | // 16 | (* ****** ****** *) 17 | 18 | local 19 | // 20 | #include "./../../DATS/Posix/mylibc.dats" 21 | // 22 | in 23 | // nothing 24 | end // end of [local] 25 | 26 | (* ****** ****** *) 27 | 28 | implement 29 | main0() = 30 | { 31 | // 32 | val () = 33 | assertloc(iseqz(xatsopt_chrunq("''"))) 34 | val () = 35 | assertloc('a' = xatsopt_chrunq("'a'")) 36 | val () = 37 | assertloc('X' = xatsopt_chrunq("'X'")) 38 | // 39 | val () = 40 | assertloc(iseqz(xatsopt_chrunq("'\\0'"))) 41 | // 42 | val () = 43 | assertloc('\a' = xatsopt_chrunq("'\\a'")) 44 | val () = 45 | assertloc('\b' = xatsopt_chrunq("'\\b'")) 46 | val () = 47 | assertloc('\n' = xatsopt_chrunq("'\\n'")) 48 | val () = 49 | assertloc('\r' = xatsopt_chrunq("'\\r'")) 50 | val () = 51 | assertloc('\t' = xatsopt_chrunq("'\\t'")) 52 | val () = 53 | assertloc('\v' = xatsopt_chrunq("'\\v'")) 54 | // 55 | val () = 56 | assertloc('\'' = xatsopt_chrunq("'\\''")) 57 | val () = 58 | assertloc('\"' = xatsopt_chrunq("'\\\"'")) 59 | // 60 | val () = 61 | assertloc('A' = xatsopt_chrunq("'\\101'")) 62 | val () = 63 | assertloc('B' = xatsopt_chrunq("'\\102'")) 64 | val () = 65 | assertloc('Z' = xatsopt_chrunq("'\\132'")) 66 | val () = 67 | assertloc('a' = xatsopt_chrunq("'\\141'")) 68 | val () = 69 | assertloc('b' = xatsopt_chrunq("'\\142'")) 70 | val () = 71 | assertloc('z' = xatsopt_chrunq("'\\172'")) 72 | // 73 | val () = 74 | assertloc("xy" = xatsopt_strunq("\"xy\"")) 75 | val () = 76 | assertloc("\t" = xatsopt_strunq("\"\\t\"")) 77 | val () = 78 | assertloc("\n" = xatsopt_strunq("\"\\012\"")) 79 | // 80 | val () = 81 | assertloc("\"" = xatsopt_strunq("\"\\\"\"")) 82 | val () = 83 | assertloc("xy" = xatsopt_strunq("\"\\170\\171\"")) 84 | // 85 | } (* end of [main0] *) 86 | 87 | (* ****** ****** *) 88 | 89 | (* end of [test_mylibc.dats] *) 90 | -------------------------------------------------------------------------------- /srcgen/xutl/TEST/cblist.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | ** AS-2018-10-27 4 | ** Unit-tests for cblist 5 | *) 6 | (* ****** ****** *) 7 | // 8 | #include 9 | "share/atspre_staload.hats" 10 | // 11 | (* ****** ****** *) 12 | // 13 | #staload 14 | "./../SATS/cblist.sats" 15 | #staload 16 | "./../SATS/Posix/cblist.sats" 17 | // 18 | #staload 19 | "./../DATS/cblist.dats" 20 | // 21 | (* ****** ****** *) 22 | 23 | local 24 | // 25 | #include "./../DATS/cblist.dats" 26 | // 27 | in 28 | // nothing 29 | end // end of [local] 30 | // 31 | (* ****** ****** *) 32 | 33 | implement main0() = 34 | { 35 | // 36 | #define STR "HELLO" 37 | // 38 | val cb = 39 | string2cblist(STR) 40 | val () = 41 | assert(1 = length(cb)) 42 | // 43 | val () = 44 | ( 45 | cblist_foreach(cb) ) where 46 | { 47 | implement 48 | cblist_foreach$fwork<> (n, cs) = 49 | { 50 | // 51 | val () = 52 | assertloc(length(STR) = n) 53 | val () = 54 | assertloc(char2uchar0(g0ofg1('H')) = cs[0]) 55 | val () = 56 | assertloc(char2uchar0(g0ofg1('E')) = cs[1]) 57 | val () = 58 | assertloc(char2uchar0(g0ofg1('L')) = cs[2]) 59 | val () = 60 | assertloc(char2uchar0(g0ofg1('L')) = cs[3]) 61 | val () = 62 | assertloc(char2uchar0(g0ofg1('O')) = cs[4]) 63 | } (* end of [cblist_foreach$fwork] *) 64 | } 65 | // 66 | } (* end of [main0] *) 67 | 68 | (* ****** ****** *) 69 | 70 | (* end of [test_cblist.dats] *) 71 | -------------------------------------------------------------------------------- /travis-ci/install-ats2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ###################################### 4 | 5 | ATS2VER=$1 6 | ATS2PACK=\ 7 | ATS2-Postiats-$ATS2VER 8 | ATS2PACKTGZ=$ATS2PACK.tgz 9 | 10 | ###################################### 11 | 12 | MV=mv 13 | TARZX="tar zx" 14 | WGETQ="wget -q" 15 | 16 | ATS2LANGURL_srcfg=\ 17 | https://sourceforge.net/projects/ats2-lang 18 | 19 | ###################################### 20 | # 21 | ATS2PACKTGZURL_download=\ 22 | "\ 23 | ${ATS2LANGURL_srcfg}/files\ 24 | /ats2-lang/ats2-postiats-$ATS2VER/$ATS2PACKTGZ" 25 | # 26 | ATS2PACKTGZURL_download=\ 27 | "\ 28 | http://ats-lang.sourceforge.net\ 29 | /IMPLEMENT/Postiats/ATS2-Postiats-gmp-$ATS2VER.tgz" 30 | # 31 | ###################################### 32 | # 33 | # HX-2019-06: 34 | # ATS2PACKgmp is the default 35 | # 36 | # ATS2PACKint=\ 37 | # ATS2-Postiats-int-$ATS2VER 38 | # ATS2PACKgmp=\ 39 | # ATS2-Postiats-gmp-$ATS2VER 40 | # 41 | ###################################### 42 | 43 | ( \ 44 | cd $HOME && mkdir -p ATS2 && \ 45 | $WGETQ -O- $ATS2PACKTGZURL_download | $TARZX -C ATS2 --strip 1) 46 | 47 | ###################################### 48 | 49 | ###### end of [install-ats2.sh] ###### 50 | -------------------------------------------------------------------------------- /travis-ci/travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | os: 3 | - linux 4 | 5 | language: c 6 | 7 | node_js: 8 | - "5.10.1" 9 | 10 | env: 11 | - export NODE_VERSION="5.10.1" 12 | 13 | addons: 14 | apt: 15 | packages: 16 | - libgc-dev 17 | - libgmp-dev 18 | 19 | before_install: 20 | - date 21 | - export PATSHOME=${HOME}/ATS2 22 | - export PATH=${PATH}:${PATSHOME}/bin 23 | - export XATSHOME=${TRAVIS_BUILD_DIR} 24 | - export GCC=gcc 25 | - export CLANG=clang 26 | 27 | install: 28 | # $XATSHOME/travis-ci/install-ats2.sh 0.4.0 29 | # $XATSHOME/travis-ci/install-ats2.sh 0.4.1 30 | - $XATSHOME/travis-ci/install-ats2.sh 0.4.2 31 | 32 | after_install: 33 | - date 34 | 35 | before_script: 36 | - date 37 | 38 | script: 39 | # Building ATS2 40 | - cd ${PATSHOME} 41 | - ./configure&&make CC=${GCC} all 42 | # Building Xanadu 43 | - cd ${XATSHOME}/srcgen 44 | - echo 'running unit-tests...' 45 | - (cd xutl/TEST && make testall) 46 | - (cd xutl/TEST/Posix && make testall) 47 | - echo 'building ATS-Xanadu...' 48 | - (cd xats && make all) 49 | - echo 'running integration tests...' 50 | - (cd xats/TEST && make XATSOPT=./../xatsopt testall) 51 | 52 | after_script: 53 | - date 54 | -------------------------------------------------------------------------------- /xatslib/githwxi/DATS/dvdcnq.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | #extern 31 | fun 32 | 33 | 34 | dvdcnq_solve(x0: inp): out 35 | // 36 | #extern 37 | fun 38 | 39 | 40 | dvdcnq_divide 41 | (x0: inp): list_vt(inp) 42 | #extern 43 | fun 44 | 45 | 46 | dvdcnq_conquer 47 | (xs: list_vt(inp)): list_vt(out) 48 | // 49 | (* ****** ****** *) 50 | 51 | datavwtp 52 | either 53 | (i: vt, o: vt) = 54 | | either_l of (i) | either_r of (o) 55 | 56 | (* ****** ****** *) 57 | // 58 | #extern 59 | fun 60 | 61 | 62 | dvdcnq_solve_rec 63 | (x0: inp): out 64 | #extern 65 | fun 66 | 67 | 68 | dvdcnq_solve_try 69 | (x0: inp): either(inp, out) 70 | // 71 | #extern 72 | fun 73 | 74 | 75 | dvdcnq_solved_cmb(rs: list_vt(out)): out 76 | // 77 | (* ****** ****** *) 78 | 79 | impltmp 80 | 81 | 82 | dvdcnq_solve(x0) = 83 | let 84 | val xr = 85 | dvdcnq_solve_try(x0) 86 | in 87 | // 88 | case+ xr of 89 | | ~ 90 | either_r(r0) => r0 91 | | ~ 92 | either_l(x0) => let 93 | // 94 | val xs = 95 | dvdcnq_divide(x0) 96 | val rs = 97 | dvdcnq_conquer(xs) 98 | // 99 | in 100 | dvdcnq_solved_cmb(rs) 101 | end 102 | // 103 | end // end of [dvdcnq_solve] 104 | 105 | (* ****** ****** *) 106 | 107 | impltmp 108 | 109 | 110 | dvdcnq_conquer(xs) = 111 | ( 112 | list_vt_map0(xs) 113 | ) where 114 | { 115 | impltmp 116 | map0$fopr(x1) = 117 | dvdcnq_solve_rec(x1) 118 | } 119 | 120 | (* ****** ****** *) 121 | 122 | (* end of [xatslib_githwxi_dvdcnq.dats] *) 123 | -------------------------------------------------------------------------------- /xatslib/githwxi/DATS/xdebug.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | #extern 30 | fun<> 31 | FI$name(): string 32 | (* ****** ****** *) 33 | #extern 34 | fun 35 | 36 | FI$arity(f0: f0): int 37 | (* ****** ****** *) 38 | #extern 39 | fun 40 | 41 | FI$pinfo(f0: f0): void 42 | (* ****** ****** *) 43 | #extern 44 | fun 45 | 46 | 47 | FI$debug(f1: f1): (f2) 48 | (* ****** ****** *) 49 | // //////////////////////////////////////////////// // 50 | // 51 | // HX-2020-11-16: 52 | // Implementations below 53 | // 54 | // //////////////////////////////////////////////// // 55 | (* ****** ****** *) 56 | impltmp 57 | <>(*tmp*) 58 | FI$name 59 | () = 60 | "**UNKNOWN**" 61 | (* ****** ****** *) 62 | impltmp 63 | {f0:t0} 64 | FI$arity 65 | (f0) = (-1) 66 | (* ****** ****** *) 67 | impltmp 68 | {r0:vt} 69 | FI$arity 70 | <()->r0>(f0) = 0 71 | impltmp 72 | {a1:vt} 73 | {r0:vt} 74 | FI$arity 75 | <(a1)->r0>(f0) = 1 76 | impltmp 77 | {a1:vt 78 | ,a2:vt} 79 | {r0:vt} 80 | FI$arity 81 | <(a1,a2)->r0>(f0) = 2 82 | impltmp 83 | {a1:vt 84 | ,a2:vt 85 | ,a3:vt} 86 | {r0:vt} 87 | FI$arity 88 | <(a1,a2,a3)->r0>(f0) = 3 89 | (* ****** ****** *) 90 | impltmp 91 | {f0:t0} 92 | FI$pinfo(f0) = 93 | let 94 | val nm = FI$name() 95 | val na = FI$arity(f0) 96 | val () = 97 | println("fun(", nm, "): arity = ", na) 98 | end // end of [FI$info] 99 | (* ****** ****** *) 100 | impltmp 101 | {f0:t0} 102 | FI$debug 103 | (f0) = f0 104 | (* ****** ****** *) 105 | impltmp 106 | {r0:vt} 107 | FI$debug 108 | <()->r0> 109 | <()-r0> 110 | (f0) = 111 | lam() => r0 where 112 | { 113 | val nm = FI$name() 114 | val () = println(nm, ": call") 115 | val r0 = f0() 116 | val () = println(nm, ": res0 = ", r0) 117 | } 118 | (* ****** ****** *) 119 | impltmp 120 | {a1:vt} 121 | {r0:vt} 122 | FI$debug 123 | <(a1)->r0> 124 | <(a1)-r0> 125 | (f0) = 126 | lam(x1) => r0 where 127 | { 128 | val nm = FI$name() 129 | val () = println(nm, ": call") 130 | val () = println(nm, ": arg1 = ", x1) 131 | val r0 = f0(x1) 132 | val () = println(nm, ": res0 = ", r0) 133 | } 134 | (* ****** ****** *) 135 | impltmp 136 | {a1:vt 137 | ,a2:vt} 138 | {r0:vt} 139 | FI$debug 140 | <(a1,a2)->r0> 141 | <(a1,a2)-r0> 142 | (f0) = 143 | lam(x1, x2) => r0 where 144 | { 145 | val nm = FI$name() 146 | val () = println(nm, ": call") 147 | val () = println(nm, ": arg1 = ", x1) 148 | val () = println(nm, ": arg2 = ", x2) 149 | val r0 = f0(x1, x2) 150 | val () = println(nm, ": res0 = ", r0) 151 | } 152 | (* ****** ****** *) 153 | 154 | (* end of [xatslib_githwxi_xdebug.dats] *) 155 | -------------------------------------------------------------------------------- /xatslib/githwxi/SATS/githwxi.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For generic ordering 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: April, 2020 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | // 40 | (* 41 | datatype 42 | gval_tbox = 43 | // 44 | | GVint of int 45 | | GVbtf of bool 46 | | GVchr of char 47 | | GVflt of double 48 | | GVstr of string 49 | // 50 | | {a:tbox} 51 | GVbx0 of ( a ) 52 | | {a:tbox} 53 | GVbx1 of (int, a) 54 | // 55 | | GVlst of gvalist 56 | // 57 | | GVfun of 58 | (gvalist) - gval 59 | // 60 | where 61 | { 62 | typedef gval = gval_tbox 63 | typedef gvalist = list(gval) 64 | } 65 | *) 66 | // 67 | (* ****** ****** *) 68 | 69 | (* end of [xatslib_githwxi.sats] *) 70 | -------------------------------------------------------------------------------- /xatslib/githwxi/TEST/test-2020-03-21.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | HX-2020-03-21: 4 | For testing gint_digitize 5 | For testing gint_rdigitize 6 | *) 7 | (* ****** ****** *) 8 | 9 | #staload 10 | "xatslib\ 11 | /githwxi/DATS/mygist.dats" 12 | 13 | (* ****** ****** *) 14 | 15 | val bs = 16 | digitize(16) 17 | where 18 | impltmp digitize$base<>() = 2 19 | endwhr // end of [val] 20 | 21 | (* ****** ****** *) 22 | // 23 | val ds1 = digitize(31415926) 24 | val ds2 = 25 | stream_vt_listize(rdigitize(31415926)) 26 | // 27 | (* ****** ****** *) 28 | 29 | (* end of [test-2020-03-21.dats] *) 30 | -------------------------------------------------------------------------------- /xatslib/libc/DATS/CATS/JS/Node/basics.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | Basics 4 | for Xats2js/Node 5 | *) 6 | (* ****** ****** *) 7 | 8 | #staload 9 | "xatslib\ 10 | /libc/DATS/fpath.dats" 11 | 12 | (* ****** ****** *) 13 | 14 | impltmp 15 | <>(*tmp*) 16 | fpath_streamize_char 17 | (path) = 18 | let 19 | val 20 | opt = 21 | XATS2JS_NODE_fs_readFileSync 22 | (path) 23 | in 24 | if 25 | stropt_nilq(opt) 26 | then 27 | stream_vt_nil((*void*)) 28 | else 29 | string_streamize(stropt_unsome(opt)) 30 | end where 31 | { 32 | #extern 33 | fun 34 | XATS2JS_NODE_fs_readFileSync 35 | (path: string): stropt = $exname() 36 | } (* end of [fpath_streamize_char] *) 37 | 38 | (* ****** ****** *) 39 | // 40 | impltmp 41 | <>(*tmp*) 42 | fpath_streamize_cgtz 43 | (path) = 44 | ( 45 | fpath_streamize_char<>(path) 46 | ) (* end of [fpath_streamize_cgtz] *) 47 | // 48 | (* ****** ****** *) 49 | 50 | (* end of [xatslib_libc_XATS2JS_NODE_basics.dats] *) 51 | -------------------------------------------------------------------------------- /xatslib/libc/DATS/CATS/JS/Node/prelude.cats: -------------------------------------------------------------------------------- 1 | /* ****** ****** */ 2 | /* 3 | Basics for Xats2js/Node 4 | */ 5 | /* ****** ****** */ 6 | 7 | const 8 | XATS2JS_NODE_fs = 9 | require( 'fs' ) ; 10 | 11 | /* ****** ****** */ 12 | 13 | function 14 | XATS2JS_NODE_fs_readFileSync 15 | (path) 16 | { 17 | return String( 18 | XATS2JS_NODE_fs.readFileSync(path) 19 | ); // end of [return] 20 | } 21 | 22 | /* ****** ****** */ 23 | 24 | /* end of [xatslib_libc_XATS2JS_NODE_prelude.cats] */ 25 | -------------------------------------------------------------------------------- /xatslib/libc/DATS/CATS/Xint/basics.dats: -------------------------------------------------------------------------------- 1 | (* ****** ****** *) 2 | (* 3 | Basics for Xinterp 4 | *) 5 | (* ****** ****** *) 6 | #staload 7 | "xatslib\ 8 | /libc/SATS/libc.sats" 9 | (* ****** ****** *) 10 | // 11 | #staload "./../../gios.dats" 12 | #staload "./../../rand.dats" 13 | #staload "./../../stdio.dats" 14 | // 15 | (* ****** ****** *) 16 | // 17 | #extern 18 | fun 19 | XINTERP_g_stdin 20 | ((*void*)): FILEref 21 | #extern 22 | fun 23 | XINTERP_g_stdout 24 | ((*void*)): FILEref 25 | #extern 26 | fun 27 | XINTERP_g_stderr 28 | ((*void*)): FILEref 29 | // 30 | impltmp 31 | g_stdin<> = XINTERP_g_stdin 32 | impltmp 33 | g_stdout<> = XINTERP_g_stdout 34 | impltmp 35 | g_stderr<> = XINTERP_g_stderr 36 | // 37 | (* ****** ****** *) 38 | // 39 | #extern 40 | fun 41 | XINTERP_fgetc_ref 42 | (fr: FILEref): int 43 | impltmp 44 | fgetc_ref<> = XINTERP_fgetc_ref 45 | // 46 | (* ****** ****** *) 47 | // 48 | #extern 49 | fun 50 | XINTERP_fputc_ref 51 | ( c0: int 52 | , fr: FILEref): int 53 | impltmp 54 | fputc_ref<> = XINTERP_fputc_ref 55 | // 56 | (* ****** ****** *) 57 | // 58 | #extern 59 | fun 60 | XINTERP_nint_rand_limit 61 | {n:pos}(limit: int(n)): nintlt(n) 62 | // 63 | impltmp 64 | nint_rand_limit<> = XINTERP_nint_rand_limit 65 | // 66 | (* ****** ****** *) 67 | 68 | (* end of [xatslib_libc_XINTERP_basics.dats] *) 69 | -------------------------------------------------------------------------------- /xatslib/libc/DATS/fpath.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For processing files abstractly 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: November, 2020 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | #staload 40 | "xatslib\ 41 | /libc/SATS/libc.sats" 42 | (* ****** ****** *) 43 | // 44 | #extern 45 | fun<> 46 | fpath_streamize_char 47 | (path: string): stream_vt(char) 48 | // 49 | #extern 50 | fun<> 51 | fpath_streamize_cgtz 52 | (path: string): stream_vt(cgtz) 53 | #extern 54 | fun<> 55 | fpath_streamize_line 56 | (path: string): stream_vt(string) 57 | #extern 58 | fun<> 59 | fpath_streamize_line_vt 60 | (path: string): stream_vt(string_vt) 61 | // 62 | (* ****** ****** *) 63 | 64 | impltmp 65 | <>(*tmp*) 66 | fpath_streamize_line 67 | (path) = 68 | stream_vt_map0 69 | ( 70 | fpath_streamize_line_vt<>(path) 71 | ) where 72 | { 73 | typedef y0 = string 74 | vwtpdef x0 = string_vt 75 | impltmp 76 | map0$fopr(x0) = string_vt2t(x0) 77 | } 78 | 79 | (* ****** ****** *) 80 | 81 | impltmp 82 | <>(*tmp*) 83 | fpath_streamize_line_vt 84 | (path) = 85 | ( 86 | auxmain0 87 | ( 88 | fpath_streamize_cgtz<>(path) 89 | ) 90 | ) where 91 | { 92 | // 93 | vwtpdef 94 | cstream = 95 | stream_vt(cgtz) 96 | // 97 | fun 98 | iseol 99 | ( c0 100 | : cgtz ) 101 | : bool = (c0 = '\n') 102 | fnx 103 | auxmain0 104 | ( cs 105 | : cstream) 106 | : stream_vt(string_vt) = 107 | $llazy 108 | ( 109 | free(cs); 110 | case+ !cs of 111 | | ~ 112 | strmcon_vt_nil() => 113 | strmcon_vt_nil() 114 | | ~ 115 | strmcon_vt_cons(c0, cs) => 116 | if 117 | iseol(c0) 118 | then 119 | strmcon_vt_cons 120 | (l1, auxmain0(cs)) where 121 | { 122 | val l1 = string_vt_nil() 123 | } 124 | else 125 | let 126 | val rs = 127 | list_vt_sing(c0) in auxmain1(cs, rs) 128 | end 129 | ) 130 | and 131 | auxmain1 132 | ( cs 133 | : cstream 134 | , rs 135 | : list_vt(cgtz)) 136 | : strmcon_vt(string_vt) = 137 | ( 138 | case+ !cs of 139 | | ~ 140 | strmcon_vt_nil() => 141 | ( 142 | strmcon_vt_sing(l1) 143 | ) where 144 | { 145 | val rs = 146 | list_vt_reverse(rs) 147 | val l1 = 148 | string_vt_make_list_vt(rs) 149 | } 150 | | ~ 151 | strmcon_vt_cons(c0, cs) => 152 | if 153 | iseol(c0) 154 | then 155 | let 156 | val rs = 157 | list_vt_reverse(rs) 158 | val l1 = 159 | string_vt_make_list_vt(rs) 160 | in 161 | strmcon_vt_cons(l1, auxmain0(cs)) 162 | end 163 | else 164 | ( 165 | auxmain1(cs, list_vt_cons(c0, rs)) 166 | ) 167 | ) (* end of [auxmain1] *) 168 | // 169 | } (* end of [fpath_streamize_line] *) 170 | 171 | (* ****** ****** *) 172 | 173 | (* end of [xatslib_libc_fpath.dats] *) 174 | -------------------------------------------------------------------------------- /xatslib/libc/DATS/gios.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For generic ordering 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: April, 2020 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | #staload 40 | "xatslib\ 41 | /libc/SATS/libc.sats" 42 | (* ****** ****** *) 43 | #staload 44 | "xatslib\ 45 | /libc/DATS/stdio.dats" 46 | (* ****** ****** *) 47 | 48 | #extern 49 | fun<> 50 | g_stdin(): FILEref // STDIN=0 51 | #extern 52 | fun<> 53 | g_stdout(): FILEref // STDOUT=1 54 | #extern 55 | fun<> 56 | g_stderr(): FILEref // STDERR=2 57 | 58 | (* ****** ****** *) 59 | 60 | #extern 61 | fun<> 62 | g_inp_char(): sint 63 | #extern 64 | fun<> 65 | g_inp_cstream(): stream_vt(sint) 66 | 67 | (* ****** ****** *) 68 | #extern 69 | fun<> 70 | g_inp_line(): string 71 | #extern 72 | fun<> 73 | g_inp_lline(): string_vt 74 | (* ****** ****** *) 75 | #extern 76 | fun<> 77 | g_inp_line_list(): list(char) 78 | #extern 79 | fun<> 80 | g_inp_lline_list(): list_vt(char) 81 | (* ****** ****** *) 82 | 83 | impltmp 84 | <>(*tmp*) 85 | g_inp_char() = 86 | fgetc_ref(g_stdin<>()) 87 | 88 | (* ****** ****** *) 89 | 90 | impltmp 91 | <>(*tmp*) 92 | g_inp_cstream() = 93 | ( 94 | auxmain(g_stdin<>()) 95 | ) where 96 | { 97 | // 98 | fun 99 | auxmain 100 | ( 101 | fr: FILEref 102 | ) : stream_vt(int) = 103 | $llazy 104 | ( 105 | let 106 | val c0 = fgetc_ref(fr) 107 | in 108 | if 109 | (c0 < 0) // EOF 110 | then 111 | strmcon_vt_nil((*void*)) 112 | else 113 | strmcon_vt_cons(c0, auxmain(fr)) 114 | end // end of [let] 115 | ) 116 | // 117 | } (* end of [g_inp_chars] *) 118 | 119 | (* ****** ****** *) 120 | // 121 | impltmp 122 | <>(*tmp*) 123 | g_inp_line_list() = 124 | list_vt2t{char}(g_inp_lline_list<>()) 125 | // 126 | (* ****** ****** *) 127 | 128 | impltmp 129 | <>(*tmp*) 130 | g_inp_lline_list() = 131 | let 132 | // 133 | val EOL = '\n' 134 | // 135 | fun 136 | loop 137 | ( cs 138 | : list_vt(char)): list_vt(char) = 139 | let 140 | val c0 = g_inp_char<>() 141 | in 142 | if 143 | (c0 >= 0) 144 | then 145 | let 146 | val c0 = char(c0) 147 | in 148 | if 149 | (c0 = EOL) 150 | then cs else loop(list_vt_cons(c0, cs)) 151 | end 152 | else cs // end of [else] 153 | end 154 | // 155 | in 156 | list_vt_reverse(loop(list_vt_nil())) 157 | end // end of [g_inp_lline_list] 158 | 159 | (* ****** ****** *) 160 | 161 | (* end of [xatslib_libc_gios.dats] *) 162 | -------------------------------------------------------------------------------- /xatslib/libc/DATS/stdio.dats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // For generic ordering 31 | // 32 | (* ****** ****** *) 33 | // 34 | // Author: Hongwei Xi 35 | // Start Time: April, 2020 36 | // Authoremail: gmhwxiATgmailDOTcom 37 | // 38 | (* ****** ****** *) 39 | #staload 40 | "xatslib\ 41 | /libc/SATS/libc.sats" 42 | (* ****** ****** *) 43 | 44 | #extern 45 | fun<> 46 | fgetc_ref 47 | (filr: FILEref): int 48 | #extern 49 | fun<> 50 | fgetc_ptr 51 | (filp: !FILEptr1): int 52 | 53 | (* ****** ****** *) 54 | 55 | #extern 56 | fun<> 57 | fputc_ref 58 | (char: int, filr: FILEref): int 59 | #extern 60 | fun<> 61 | fputc_ptr 62 | (char: int, filp: !FILEptr1): int 63 | 64 | (* ****** ****** *) 65 | 66 | (* end of [xatslib_libc_stdio.dats] *) 67 | -------------------------------------------------------------------------------- /xatslib/libc/SATS/libc.sats: -------------------------------------------------------------------------------- 1 | (***********************************************************************) 2 | (* *) 3 | (* Applied Type System *) 4 | (* *) 5 | (***********************************************************************) 6 | 7 | (* 8 | ** ATS/Xanadu - Unleashing the Potential of Types! 9 | ** Copyright (C) 2020 Hongwei Xi, ATS Trustful Software, Inc. 10 | ** All rights reserved 11 | ** 12 | ** ATS is free software; you can redistribute it and/or modify it under 13 | ** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the 14 | ** Free Software Foundation; either version 3, or (at your option) any 15 | ** later version. 16 | ** 17 | ** ATS is distributed in the hope that it will be useful, but WITHOUT ANY 18 | ** WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20 | ** for more details. 21 | ** 22 | ** You should have received a copy of the GNU General Public License 23 | ** along with ATS; see the file COPYING. If not, please write to the 24 | ** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 25 | ** 02110-1301, USA. 26 | *) 27 | 28 | (* ****** ****** *) 29 | // 30 | // Author: Hongwei Xi 31 | // Start Time: April, 2020 32 | // Authoremail: gmhwxiATgmailDOTcom 33 | // 34 | (* ****** ****** *) 35 | // 36 | abstype 37 | FILEref_tbox <= ptr 38 | absvwtp 39 | FILEptr_vtbx(l:addr) <= ptr 40 | // 41 | typedef FILEref = FILEref_tbox 42 | sexpdef FILEptr = FILEptr_vtbx 43 | vwtpdef FILEptr0 = [l:addr] FILEptr(l) 44 | vwtpdef FILEptr1 = [l:agtz] FILEptr(l) 45 | // 46 | (* ****** ****** *) 47 | 48 | (* end of [xatslib_libc.sats] *) 49 | --------------------------------------------------------------------------------