├── bin
├── conf
├── pubpriv
├── install.sh
├── mbfixbin
├── pfrepl
├── pfront
├── repl
├── pfhighlight
├── pftexprint
├── uninstall_all.sh
└── test.sh
├── misc
├── footer.tex
├── flowtop.hl
├── flowdll.hl
├── header.html
├── scripts1.js
├── footer.html
├── stylesheets.css
├── header.tex
└── demos
│ ├── calc.hl
│ ├── 03calc.al
│ ├── 04calc.al
│ ├── 01calc.al
│ └── 00calc.al
├── doc
├── doc.tex
├── pfdoc.tex
├── scripts1.js
├── stylesheets.css
└── template.tex
├── src
├── l
│ ├── tests
│ │ ├── level2
│ │ │ ├── readme
│ │ │ └── test_w.al
│ │ ├── level1
│ │ │ └── readme
│ │ ├── level3
│ │ │ └── readme
│ │ ├── level4
│ │ │ └── test.al
│ │ └── common.al
│ ├── lib
│ │ ├── ssa
│ │ │ ├── bootstrap.sh
│ │ │ ├── bootstrap.hl
│ │ │ ├── bootstrap.al
│ │ │ ├── genlive-ast.hl
│ │ │ ├── ssa-lib.hl
│ │ │ ├── ssa-ast.hl
│ │ │ ├── doc.tex
│ │ │ ├── ssa-fold-typing.hl
│ │ │ ├── domtree.hl
│ │ │ └── ssa-fold-algebra.hl
│ │ ├── wam
│ │ │ ├── mbaselogic.hl
│ │ │ ├── lib.hl
│ │ │ ├── prologdoc.tex
│ │ │ ├── prolog_backend_lib.hl
│ │ │ └── prolog_repl.hl
│ │ ├── parsing
│ │ │ ├── packrat.al
│ │ │ ├── pegtemp.al
│ │ │ ├── lib.al
│ │ │ ├── pegbasics.peg
│ │ │ ├── basics.peg
│ │ │ ├── backend-ast.al
│ │ │ └── ast.al
│ │ ├── ml
│ │ │ ├── mllib.al
│ │ │ ├── mldll.al
│ │ │ ├── mlcomp.al
│ │ │ ├── mlcore-parser2.al
│ │ │ ├── mlprelude.al
│ │ │ ├── mlrepl.al
│ │ │ ├── mllexer.peg
│ │ │ ├── mlcore-ast.al
│ │ │ └── mlfront.al
│ │ └── pfront
│ │ │ ├── front.al
│ │ │ ├── pfrepl.al
│ │ │ ├── pfrepl2.al
│ │ │ ├── pftexprint.al
│ │ │ ├── backport.al
│ │ │ ├── parser.al
│ │ │ ├── pliter.peg
│ │ │ ├── pfront.al
│ │ │ ├── pftexincludeinv.al
│ │ │ └── sexp.hl
│ ├── boot
│ │ ├── initlib2.al
│ │ ├── stagec.al
│ │ ├── extra.al
│ │ ├── stage2.al
│ │ ├── stage3.al
│ │ ├── stage4.al
│ │ ├── stage5.al
│ │ └── common.al
│ ├── version.al
│ ├── core
│ │ ├── asmlib_hooks.al
│ │ ├── ccerrors.al
│ │ ├── asmlib_load.al
│ │ ├── environment.al
│ │ ├── graphsort.al
│ │ ├── pmatchcomp.al
│ │ ├── cc-anntexpand.al
│ │ ├── cc-plugins.al
│ │ ├── cc-sanitise.al
│ │ ├── fccase.al
│ │ ├── cc-cons.al
│ │ ├── unit.al
│ │ ├── asmlib_common.al
│ │ ├── list.al
│ │ ├── parsing_chars.al
│ │ ├── utils.al
│ │ ├── final.al
│ │ ├── envhandling.al
│ │ ├── netlib_fields.al
│ │ ├── cc-tail.al
│ │ ├── cc-expand.al
│ │ ├── cc-ast-flat.al
│ │ ├── native.al
│ │ ├── parsing_0.al
│ │ ├── cc-netdefs.al
│ │ ├── records.al
│ │ ├── cc-optimise.al
│ │ └── compiler.al
│ ├── ext
│ │ ├── ast2-initvector.al
│ │ ├── raise.al
│ │ ├── unittests.al
│ │ ├── tarjan.al
│ │ ├── extra.al
│ │ ├── ast2.al
│ │ ├── float.al
│ │ ├── tcprepl.al
│ │ ├── nrecord.al
│ │ └── texprint.al
│ ├── util
│ │ ├── makeasmlib.al
│ │ └── update_pure.al
│ └── options.al
└── cs
│ └── dll
│ ├── AssemblyInfo.cs
│ └── version.cs
└── COPYING
/bin/conf:
--------------------------------------------------------------------------------
1 | MONO=mono
2 |
--------------------------------------------------------------------------------
/misc/footer.tex:
--------------------------------------------------------------------------------
1 |
2 | \end{document}
3 |
--------------------------------------------------------------------------------
/bin/pubpriv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/combinatorylogic/mbase/HEAD/bin/pubpriv
--------------------------------------------------------------------------------
/doc/doc.tex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/combinatorylogic/mbase/HEAD/doc/doc.tex
--------------------------------------------------------------------------------
/src/l/tests/level2/readme:
--------------------------------------------------------------------------------
1 | Tests covering an interpreted .NET compiler functionality
--------------------------------------------------------------------------------
/bin/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | ls MBase*.dll | xargs -I {} gacutil /i {}
4 |
5 |
--------------------------------------------------------------------------------
/src/l/lib/ssa/bootstrap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | pfront /dumpal ssa.al ./bootstrap.hl
4 |
5 |
--------------------------------------------------------------------------------
/src/l/tests/level1/readme:
--------------------------------------------------------------------------------
1 | Tests covering L1 functionality without .NET compiler.
2 |
3 |
--------------------------------------------------------------------------------
/src/l/tests/level3/readme:
--------------------------------------------------------------------------------
1 | Tests covering fully compiled L1' + extra libraries, including NOT.NET
2 | backend.
3 |
4 |
--------------------------------------------------------------------------------
/misc/flowtop.hl:
--------------------------------------------------------------------------------
1 | #(sysdll MBaseExtra)
2 | #(sysdll FlowCharts)
3 |
4 | function main() {
5 | fc_main()
6 | }
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/l/lib/ssa/bootstrap.hl:
--------------------------------------------------------------------------------
1 |
2 |
3 | include "ssa-ast.hl"
4 | include "domtree.hl"
5 | include "ssa-trans.hl"
6 | include "ssa-analysis.hl"
7 |
8 |
--------------------------------------------------------------------------------
/src/l/lib/wam/mbaselogic.hl:
--------------------------------------------------------------------------------
1 | #(include "../../version.al")
2 | #(n.module MBaseLogic)
3 |
4 | include "./lib.hl";
5 |
6 | #(force-class-flush)
7 |
8 | #(n.save)
--------------------------------------------------------------------------------
/bin/mbfixbin:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set +e
4 | editbin /stack:9000000 $1
5 |
6 | CorFlags.exe /Force /32BIT+ $1
7 | sn -Ra $1 pubpriv
8 |
9 | set -e
10 |
11 |
--------------------------------------------------------------------------------
/bin/pfrepl:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | REPL_PATH="`dirname \"$0\"`"
4 | REPL_PATH="`( cd \"$REPL_PATH\" && pwd )`"
5 |
6 | . $REPL_PATH/conf
7 |
8 | $MONO $0.exe $*
9 |
10 |
--------------------------------------------------------------------------------
/bin/pfront:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | REPL_PATH="`dirname \"$0\"`"
4 | REPL_PATH="`( cd \"$REPL_PATH\" && pwd )`"
5 |
6 | . $REPL_PATH/conf
7 |
8 | $MONO $0.exe $*
9 |
10 |
--------------------------------------------------------------------------------
/bin/repl:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | REPL_PATH="`dirname \"$0\"`"
4 | REPL_PATH="`( cd \"$REPL_PATH\" && pwd )`"
5 |
6 | . $REPL_PATH/conf
7 |
8 | $MONO $0.exe $*
9 |
10 |
--------------------------------------------------------------------------------
/bin/pfhighlight:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | REPL_PATH="`dirname \"$0\"`"
4 | REPL_PATH="`( cd \"$REPL_PATH\" && pwd )`"
5 |
6 | . $REPL_PATH/conf
7 |
8 | $MONO $0.exe $*
9 |
10 |
--------------------------------------------------------------------------------
/bin/pftexprint:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | REPL_PATH="`dirname \"$0\"`"
4 | REPL_PATH="`( cd \"$REPL_PATH\" && pwd )`"
5 |
6 | . $REPL_PATH/conf
7 |
8 | $MONO $0.exe $*
9 |
10 |
--------------------------------------------------------------------------------
/src/l/lib/wam/lib.hl:
--------------------------------------------------------------------------------
1 | litinclude ("./prolog") "./prolog.hl";
2 | litinclude ("./prolog_backend") "./prolog_backend.hl";
3 | litinclude ("./prolog_backend_lib") "./prolog_backend_lib.hl";
4 |
5 |
--------------------------------------------------------------------------------
/misc/flowdll.hl:
--------------------------------------------------------------------------------
1 | #(include "../src/l/version.al")
2 | #(sysdll MBaseExtra)
3 | #(n.module FlowCharts)
4 |
5 | include "./extra.hl"
6 | htmlinclude "./flowchart.hl"
7 |
8 | #(force-class-flush)
9 | #(n.save)
10 |
11 |
--------------------------------------------------------------------------------
/bin/uninstall_all.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | if [ -z "$SED" ];
4 | then
5 | SED=sed
6 | fi
7 |
8 | gacutil /l | grep d53ce51f54584d25 | $SED -s "s/ //g" | $SED -s "s/,Custom=null//g" | xargs -I {} gacutil /uf "{}"
9 |
10 |
--------------------------------------------------------------------------------
/src/l/lib/ssa/bootstrap.al:
--------------------------------------------------------------------------------
1 |
2 | (with-macros ((hlevl-file (fun (x) `(begin )))
3 | (top-begin (fun (x) `(begin ,@(cdr x))))
4 | (pfront.debugpoint (fun (x) `(inner.debugpoint ,@(cdr x))))
5 | )
6 | (include "./ssa.al"))
7 |
8 |
--------------------------------------------------------------------------------
/src/l/lib/wam/prologdoc.tex:
--------------------------------------------------------------------------------
1 | \input ../../../../misc/header
2 | \begin{document}
3 | \setlength{\parindent}{0pt}
4 |
5 | \tableofcontents
6 |
7 | \newpage
8 |
9 | \input prolog
10 | \input prolog_backend
11 | \input prolog_backend_lib
12 |
13 | \end{document}
14 |
--------------------------------------------------------------------------------
/doc/pfdoc.tex:
--------------------------------------------------------------------------------
1 | \input ../misc/header
2 |
3 | \title{PFront manual}
4 | \author{Meta Alternative Ltd.}
5 | \date{Apr 2017}
6 |
7 | \begin{document}
8 |
9 | \maketitle
10 |
11 | \tableofcontents
12 |
13 | \newpage
14 |
15 | \input pfrontdoc
16 |
17 | \end{document}
18 |
--------------------------------------------------------------------------------
/src/l/lib/ssa/genlive-ast.hl:
--------------------------------------------------------------------------------
1 | %literate:
2 |
3 | \pfcode{
4 | ast genlivebb {
5 | bbs is (.*bb:bbs);
6 | bb = genbb(lblident:lbl, *useident:uses, *defident:defs, *instr:is);
7 | instr = use(ident:id)
8 | | kill(ident:id)
9 | | usekill(ident:id)
10 | | next(lblident:dst)
11 | ;
12 | }}
13 |
14 | %%%%%%%%%%%%%
15 |
16 |
--------------------------------------------------------------------------------
/src/l/lib/ssa/ssa-lib.hl:
--------------------------------------------------------------------------------
1 | #(include "../../version.al")
2 | #(n.module MBaseExtra)
3 |
4 | include "ssa-ast.hl"
5 | include "domtree.hl"
6 | include "ssa-trans.hl"
7 | include "ssa-analysis.hl"
8 |
9 | litinclude ("./ssa-fold") "ssa-fold.hl"
10 |
11 | include "ssa-backend.hl"
12 | include "genlive.hl"
13 |
14 | include "genpprint.hl"
15 |
16 | #(force-class-flush)
17 | #(n.save)
18 |
--------------------------------------------------------------------------------
/src/l/boot/initlib2.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 |
11 | (include "../core/netlib.al")
12 | (include "../core/macrolib.al")
13 | (include "../core/morelib.al")
14 |
15 |
--------------------------------------------------------------------------------
/src/l/lib/parsing/packrat.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (ctimex (define compiler-debug-enabled #t))
11 | (include "../../version.al")
12 | (n.module MBasePackrat)
13 |
14 | (include "./lib.al")
--------------------------------------------------------------------------------
/src/l/tests/level2/test_w.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (define ENV (cc:newenv))
11 | (cc:env:defmodule ENV "testl2" 'dll)
12 |
13 | (cc:toplevel-devour ENV '(include "./test.al"))
14 |
15 |
--------------------------------------------------------------------------------
/src/l/tests/level4/test.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (n.module test4 exe)
11 | (sysdll MBaseFront)
12 |
13 | (include "../common.al")
14 |
15 | (hlevl-file "./test.hl")
16 |
17 | (include "./auto.al")
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/l/lib/ml/mllib.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (include "./mlcore.al")
11 |
12 | (define ml:env (mkhash))
13 | (define ml:prev (mkhash))
14 |
15 | (force-class-flush)
16 |
17 | (ctime `(ml-file ,(cpath "./mlprelude.ml")))
18 |
--------------------------------------------------------------------------------
/src/l/version.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (ctime (define *VERSION* "1.0.2.20"))
11 | (ctime `(#define version ,*VERSION*))
12 | (ctimex (define assembly-version *VERSION*))
13 | (ctimex (define assembly-keyfile "pubpriv"))
14 |
15 |
--------------------------------------------------------------------------------
/src/l/core/asmlib_hooks.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (define m_Call_Generic (cons m_Call_Generic_00 nil))
11 |
12 | (define ms_Call_Generics (cons ms_Call_Generics_00 nil))
13 |
14 | (define ms_Call_RevGenerics (cons ms_Call_RevGenerics_00 nil))
15 |
16 |
17 |
--------------------------------------------------------------------------------
/misc/header.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
15 |
16 |
--------------------------------------------------------------------------------
/src/l/boot/stagec.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;-
11 | ;- \section{Stage $1^c$ --- building the interpreted compiler}
12 | ;-
13 |
14 | (ctimex (println "Bootstrap stage: C"))
15 | (include "../core/compiler.al")
16 | (force-class-flush)
17 | (gensym-counter-set (ctime (cdr *gensym-counter-storage*)))
--------------------------------------------------------------------------------
/src/l/lib/pfront/front.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (include "../../version.al")
11 | (n.module MBaseFront)
12 | (sysdll MBasePackrat)
13 |
14 | (force-class-flush)
15 |
16 | (unit-tests-use)
17 |
18 | (include "./lib.al")
19 |
20 |
21 | (force-class-flush)
22 |
23 | (unit-tests-dump (4 "../src/l/tests/level4/auto.al"))
--------------------------------------------------------------------------------
/src/l/lib/ssa/ssa-ast.hl:
--------------------------------------------------------------------------------
1 | % literate:
2 |
3 | \subsection{AST for the generic SSA DSL}
4 |
5 | \pfcode{
6 | ast genssa {
7 | top is (*varident:allocas, code:c);
8 | code is (.*bblock:bs);
9 | bblock =
10 | b(labident:name, *oppair:ops, *labident:nexts);
11 | oppair is (varident:name, iop:op);
12 | iop = phi(varident:orig,*labident:prevs,*varident:vals)
13 | | load(varident:v)
14 | | store(varident:dst, varident:src)
15 | | remap(varident:v)
16 | | use(.*varident:ids)
17 | ;
18 | varident is id:v;
19 | labident is id:v;
20 | }
21 | }
22 |
23 |
24 | %%%
25 | %%%
--------------------------------------------------------------------------------
/src/l/lib/ml/mldll.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (include "../../version.al")
11 | (n.module MBaseML)
12 | (sysdll MBasePackrat)
13 | (macro save-gensym ()
14 | (let ((gctr (cdr *gensym-counter-storage*)))
15 | `(set-cdr! *gensym-counter-storage* ,(+ gctr 10001))))
16 |
17 | (include "./mllib.al")
18 |
19 | (ml-saveenv)
20 |
21 | (save-gensym)
22 |
23 |
--------------------------------------------------------------------------------
/doc/scripts1.js:
--------------------------------------------------------------------------------
1 | function srcref_over(dstid, id) {
2 | SvgConnectors.manage();
3 | let x = document.getElementById(dstid);
4 | document.getElementById('dummy_to').childNodes[0].removeAttribute('id');
5 | document.getElementById('dummy_from').childNodes[0].removeAttribute('id');
6 | x.childNodes[0].id = 'too';
7 | id.childNodes[0].id = 'frm';
8 | SvgConnectors.manage();
9 | }
10 |
11 | function srcref_leave(dstid, id) {
12 | SvgConnectors.manage();
13 | let x = document.getElementById(dstid);
14 | document.getElementById('dummy_to').childNodes[0].id = 'too';
15 | document.getElementById('dummy_from').childNodes[0].id = 'frm';
16 | x.childNodes[0].removeAttribute('id');
17 | id.childNodes[0].removeAttribute('id');
18 | SvgConnectors.manage();
19 | }
20 |
--------------------------------------------------------------------------------
/misc/scripts1.js:
--------------------------------------------------------------------------------
1 | function srcref_over(dstid, id) {
2 | SvgConnectors.manage();
3 | let x = document.getElementById(dstid);
4 | document.getElementById('dummy_to').childNodes[0].removeAttribute('id');
5 | document.getElementById('dummy_from').childNodes[0].removeAttribute('id');
6 | x.childNodes[0].id = 'too';
7 | id.childNodes[0].id = 'frm';
8 | SvgConnectors.manage();
9 | }
10 |
11 | function srcref_leave(dstid, id) {
12 | SvgConnectors.manage();
13 | let x = document.getElementById(dstid);
14 | document.getElementById('dummy_to').childNodes[0].id = 'too';
15 | document.getElementById('dummy_from').childNodes[0].id = 'frm';
16 | x.childNodes[0].removeAttribute('id');
17 | id.childNodes[0].removeAttribute('id');
18 | SvgConnectors.manage();
19 | }
20 |
--------------------------------------------------------------------------------
/src/l/ext/ast2-initvector.al:
--------------------------------------------------------------------------------
1 | (macro ast2-init-n-vector vlst
2 | (with-syms (fldnm arnm)
3 | `(straise
4 | (not.neth ()
5 | (lift-initfield ,fldnm
6 | ((public) (static))
7 | ,@(foreach-mappend (v vlst)
8 | (int->ibytes v)))
9 | (lift-field (field (array int) ,arnm (public) (static)))
10 | (if (isnull (this # ,arnm))
11 | (begin
12 | (this # ,arnm <- (mkarr int ,(length vlst)))
13 | (System.Runtime.CompilerServices.RuntimeHelpers
14 | @ InitializeArray
15 | ((System.Array)(this # ,arnm))
16 | ((System.RuntimeFieldHandle)(fieldtoken (this # ,fldnm)))
17 | )))
18 | (leave ((object) (this # ,arnm)))))))
19 |
20 |
--------------------------------------------------------------------------------
/src/l/lib/ml/mlcomp.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (n.module mlcomp exe)
11 | (sysdll MBaseML)
12 |
13 | (function compile-ml (src tgt)
14 | (read-compile-eval `(n.module ,(Sm<< tgt) exe))
15 | (read-compile-eval `(ml-file ,src))
16 | (read-compile-eval '(n.save)))
17 |
18 | (function main ( )
19 | (shashput (getfuncenv) 'main nil)
20 | (p:match (a->l *CMDLINE*)
21 | (($src)
22 | (compile-ml src "mlout"))
23 | (($src $tgt)
24 | (compile-ml src tgt))
25 | (else
26 | (println "Usage:\n mlcomp
[]\n"))))
27 |
28 |
--------------------------------------------------------------------------------
/src/l/util/makeasmlib.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (include "../core/ccerrors.al")
11 | (include "../core/emit.al")
12 | (include "../version.al")
13 | (include "../options.al")
14 |
15 | (include "../core/asmlib_common.al")
16 | (include "../core/asmlib_build.al")
17 | (define _asmlib_asm (make-strong-assembly "bootasm" assembly-version assembly-keyfile))
18 | (define _asmlib_module (make-module-s _asmlib_asm "DYNAMIC" "bootasm.dll" #f))
19 |
20 | (asmlib:build _asmlib_asm _asmlib_module "bootasm.")
21 |
22 | ;; yes, save it now:
23 | (asm-save _asmlib_asm "bootasm.dll")
24 |
--------------------------------------------------------------------------------
/src/l/options.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (ctimex (begin
11 | (#define prefix-tail #t) ; use .tail call isntructions
12 | (#define debug-compiler #t) ; allow inspecting intermediate code
13 | (#define optimise-case nil) ; legacy case optimisation
14 |
15 | (#define option-asserts #t) ; compile asserts
16 |
17 | (#define optimise-cache #t) ; use code and const cache
18 | (#define optimise-cache-threshold 200)
19 | (#define optimise-cache-length-threshold 3000)
20 |
21 | (#define copyright "(c) by Meta Alternative Ltd., 2005-2017")
22 |
23 | ))
24 |
--------------------------------------------------------------------------------
/src/l/lib/parsing/pegtemp.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (include "./peg.al")
11 |
12 | (function peg-translate (out sources)
13 | (call-with-output-file out
14 | (fun (fo)
15 | (foreach (s sources)
16 | (alet x (lex-and-parse peg-lexer parse-peg-decls
17 | (read-file-list
18 | (S<< (corelib:get-lookup-path) "/" s)))
19 | (foreach (xi x) (fprintln fo (to-string xi)))
20 | )))))
21 |
22 |
23 | (peg-translate "./temporary-source.al" '("./basics.peg" "./pegbasics.peg" "./peg.peg"))
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/l/boot/extra.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 |
11 | (include "../ext/ibinder.al")
12 | (include "../ext/float.al")
13 | (include "../ext/extra.al")
14 | (include "../ext/rules.al")
15 | (include "../ext/collections.al")
16 | (include "../ext/threading.al")
17 | (include "../ext/tarjan.al")
18 | (include "../ext/sexp.al")
19 | (include "../ext/xml.al")
20 | (include "../ext/nettypes.al")
21 |
22 |
23 |
24 | (include "../ext/notnet-ast.al")
25 | (include "../ext/notnet-core.al")
26 | (include "../ext/notnet-backend.al")
27 | (include "../ext/notnet-frontend.al")
28 |
29 | (include "../ext/nrecord.al")
30 | (include "../ext/raise.al")
31 | (include "../ext/extutils.al")
32 |
33 | (include "../ext/ast2.al")
34 |
35 |
--------------------------------------------------------------------------------
/misc/footer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/bin/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ./conf
4 |
5 | MBASE="$MONO ./mb0.exe"
6 | REPL="$MONO ./repl.exe"
7 | TDIR=../src/l/tests/
8 |
9 | echo "L1"
10 | $MBASE /I boot2.alc $TDIR/level1/test.al | grep -v OK
11 | echo "L2: boot2.alc, libnet.alc, int"
12 | $MBASE /I boot2.alc /I libnet.alc $TDIR/level2/test.al | grep -v OK
13 | echo "L2: boot2.alc, libnet.alc, comp"
14 | $MBASE /I boot2.alc /I libnet.alc $TDIR/level2/test_w.al | grep -v OK
15 | echo "L2: boot2c.dll, libnet.alc, comp"
16 | $MBASE /D boot2c.dll /I libnet.alc $TDIR/level2/test_w.al | grep -v OK
17 | echo "L2: boot3.dll, comp"
18 | $MBASE /D boot3.dll $TDIR/level2/test_w.al | grep -v OK
19 | echo "L2: boot4.dll, comp"
20 | $MBASE /D boot4.dll $TDIR/level2/test_w.al | grep -v OK
21 | echo "L3: repl"
22 | $REPL $TDIR/level3/test.al | grep -v OK
23 | echo "L3: repl, exe comp"
24 | $REPL /emit $TDIR/level3/test.al | grep -v OK
25 | echo "L3: repl, exe run"
26 | $MONO ./test.exe | grep -v OK
27 |
28 | echo "L4: pfront"
29 | $REPL $TDIR/level4/test.al | grep -v OK
30 |
31 |
--------------------------------------------------------------------------------
/src/l/core/ccerrors.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 |
11 | (function mkexcp (arg)
12 | (r_raise (new t_MBaseException (object arg)))
13 | )
14 |
15 | (function ccerror (arg)
16 | "Raises [MBaseException] with a given argument."
17 | (if (shashget (getfuncenv) 'debug-compiler-failure)
18 | (begin
19 | (writeline `(EXCEPTION: ,arg))
20 | (exit -1)
21 | )
22 | (mkexcp arg)))
23 |
24 | (define *WARNINGS* (mkref))
25 |
26 | (function ccwarning (arg)
27 | "Adds a warning to the global list of warnings."
28 | (set-cdr! *WARNINGS* (cons arg *WARNINGS*))
29 | (print "WARNING: ")
30 | (println (to-string arg)))
31 |
32 | (function getwarnings ()
33 | "Returns the current list of warnings."
34 | (cdr *WARNINGS*))
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/l/util/update_pure.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;; Rebuilds Pure.cs
11 |
12 | (define MAXARGS 20)
13 |
14 | (iter println '(
15 | "using System;"
16 | "using System.Collections;"
17 | "using System.IO;"
18 | "using System.Reflection;"
19 | ""
20 | ""
21 | "namespace Meta.Scripting"
22 | "{"))
23 |
24 | (for (i 0 MAXARGS)
25 | (println
26 | (S<< "public delegate Object AltFun" i "("
27 | (if (> i 0) (strinterleave (formap (j 0 i) (S<< "Object a" j)) ",") "")
28 | ");"))
29 | (println
30 | (S<< "public interface AltClosure" i " {"))
31 | (println
32 | (S<< " Object run("
33 | (if (> i 0) (strinterleave (formap (j 0 i) (S<< "Object a" j)) ",") "")
34 | ");}"))
35 | )
36 |
37 |
38 | (println "}")
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/cs/dll/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////////////////////////////////////////////
2 | //
3 | // OpenMBase
4 | //
5 | // Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | //
7 | //
8 | //////////////////////////////////////////////////////////////////////////////
9 |
10 | using System.Reflection;
11 | using System.Runtime.CompilerServices;
12 | using System.Security;
13 |
14 |
15 | [assembly: AssemblyTitle(AssemblyVersion.kDescription)]
16 | [assembly: AssemblyDescription(AssemblyVersion.kDescription)]
17 | [assembly: AssemblyConfiguration("")]
18 | [assembly: AssemblyCompany(AssemblyVersion.kCompanyName)]
19 | [assembly: AssemblyProduct(AssemblyVersion.kProductName)]
20 | [assembly: AssemblyCopyright(AssemblyVersion.kCopyright)]
21 | [assembly: AssemblyTrademark("")]
22 | [assembly: AssemblyCulture("")]
23 | [assembly: AssemblyVersion(AssemblyVersion.kFileVersion)]
24 |
25 |
26 | [assembly: AssemblyDelaySign(true)]
27 | //[assembly: AssemblyKeyFile("")]
28 | //[assembly: AssemblyKeyName("")]
29 | [assembly:AssemblyKeyFile("pubpriv")]
30 |
--------------------------------------------------------------------------------
/src/l/ext/raise.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;;; raise static ref
11 |
12 | (macro straise2 (code)
13 | (with-syms (nm xnm)
14 | `(begin
15 | (not.neth ()
16 | (lift-field (field object ,nm (private) (static)))
17 | (leave null)
18 | )
19 | (if (null? (not.neth () (leave ((object)(this # ,nm)))))
20 | (alet ,xnm ,code
21 | (not.neth ((object ,xnm))
22 | (this # ,nm <- ,xnm)
23 | (leave ,xnm)))
24 | (not.neth ()
25 | (leave ((object)(this # ,nm))))))))
26 |
27 |
28 |
29 | (unit-test 3 (let ((abc (fun (x) (list (straise2 (cons x x)) x))))
30 | (list (abc 10) (abc 20) (abc 30)))
31 | ( ((10 . 10) 10)
32 | ((10 . 10) 20)
33 | ((10 . 10) 30)))
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/l/boot/stage2.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;-
11 | ;- \section{Stage 2 --- compiling the core library}
12 | ;-
13 |
14 | (_Clean_Deps)
15 | (include "../options.al")
16 |
17 | (ctimex (println "Bootstrap stage: 2"))
18 |
19 | (define ENV (cc:newenv))
20 | (cc:env:defmodule ENV "boot2c" 'dll)
21 |
22 | (define compiled-environment #t)
23 |
24 | ;;(define debug-compiler-drivertop #t)
25 |
26 | (begin
27 | (cc:toplevel-devour ENV '(top-begin
28 | (include "../boot/boot.al")
29 | (include "../boot/initlib.al")
30 | (include "../boot/dotnetlib.al")
31 | (include "../boot/common.al")
32 | (define core-environment-compiled #t)
33 | ))
34 | )
35 | (cc:dump-module ENV)
36 |
--------------------------------------------------------------------------------
/src/l/core/asmlib_load.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 |
11 | (define _t_call_generic (ctime `(dotnet ,(S<< generic_pfx "CALL_GENERIC"))))
12 | (define m_Call_Generic_00 (r_mtd _t_call_generic "call_generic"
13 | t_object_array t_object))
14 |
15 | (define ms_Call_Generics_00
16 | (ctime `(noconst (list
17 | ,@(formap (i 0 SMAXARGS)
18 | `(r_mtd _t_call_generic ,(buildstring "call_generic__" i) ,@(formap (j 0 i) 't_object) t_object))))))
19 |
20 | (define ms_Call_RevGenerics_00
21 | (ctime `(noconst (list
22 | ,@(formap (i 0 SMAXARGS)
23 | `(r_mtd _t_call_generic ,(buildstring "call_r_generic__" i) ,@(formap (j 0 i) 't_object) t_object))))))
24 |
25 | ;;; now register the delegate callback:
26 | (let ((register (r_sbind _t_call_generic "register")))
27 | (register))
28 |
--------------------------------------------------------------------------------
/src/l/boot/stage3.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;-
11 | ;- \section{Stage 3 --- compiling the core library $+$ compiler}
12 |
13 |
14 | (_Clean_Deps)
15 | (include "../options.al")
16 |
17 | (ctimex (println "Bootstrap stage: 3"))
18 |
19 | (define ENV (cc:newenv))
20 | (cc:env:defmodule ENV "boot3" 'dll)
21 |
22 | (define compiled-environment #t)
23 |
24 | (begin
25 | (cc:toplevel-devour ENV '(top-begin
26 | (define core-environment-compiled #t)
27 | (include "../boot/boot.al")
28 | (include "../boot/initlib.al")
29 | (include "../boot/dotnetlib.al")
30 | (include "../boot/common.al")
31 | (include "../core/compiler.al")
32 | ))
33 | )
34 | (cc:dump-module ENV)
35 |
--------------------------------------------------------------------------------
/src/l/lib/ml/mlcore-parser2.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 |
11 | (function peg-function-mltypename (n)
12 | (p:match n
13 | ((T $v . $args) `(,v ,@args))
14 | (else (ccerror `(ML:TYPENAME ,n))))
15 | )
16 |
17 | (function peg-function-mltypeargcheck (a)
18 | (p:match a ((T $id) (list id))
19 | (else (ccerror `(ML:TYPENAME ,a))))
20 | )
21 |
22 | (function peg-function-mlmaketype (a b)
23 | (let* ((l (cons a b))
24 | (tl (cuttail l))
25 | (lt (car (lasttail l))))
26 | `(T ,lt ,@tl))
27 | )
28 |
29 | (define <*ML-INFIX*> (mkhash))
30 |
31 | (function peg-function-definfix (str)
32 | (hashput <*ML-INFIX*> str #t))
33 |
34 | (function peg-checkfunction-ml_check_infix (str)
35 | (if (hashget <*ML-INFIX*> str) #t nil))
36 |
37 |
38 | (packrat-file "./mllexer.peg")
39 | (packrat-file "./mlparser.peg")
40 |
41 |
42 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 2005-2017 Meta Alternative Ltd.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/doc/stylesheets.css:
--------------------------------------------------------------------------------
1 | #source {
2 | left: 60%;
3 | top: 60%;
4 | }
5 | #target {
6 | left: 120%;
7 | top: 120%;
8 | }
9 | svg {
10 | position: absolute;
11 | left: 0;
12 | top: 0;
13 | pointer-events: none;
14 | }
15 | line {
16 | stroke: grey;
17 | stroke-width: 2;
18 | stroke-opacity: 0.5;
19 | }
20 |
21 |
22 | .ident { color: #000099; }
23 | .keyword { color: blue; }
24 | .comment { color: green; }
25 | .lexic { color: #0099ff; }
26 | .pattern { text-shadow: 1px 1px 2px rgba(190, 190, 190, 1); }
27 | .code { font-family: monospace; border-style: dotted; border-width: 1px; font-size: 100%; }
28 | .democode { font-family: monospace; border-style: solid; border-width: 1px; font-size: 80%; }
29 | .const { color: #0099ff; }
30 | .symbol { color: #0099ff; }
31 | .column { width: 800px; text-align: justify; }
32 |
33 | .withhint { position: relative; }
34 | .hint { display: none; }
35 |
36 | .withhint:hover .hint {
37 | display: block;
38 | position: absolute;
39 | bottom: 1em;
40 | padding: 0.5em;
41 | color: #000000;
42 | background: #ebf4fb;
43 | border: 0.1em solid #b7ddf2;
44 | border-radius: 0.5em;
45 | }
46 |
--------------------------------------------------------------------------------
/src/l/core/environment.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ; A new, cleaner way of handling the compilation environment.
11 |
12 | (using ("System.Threading")
13 |
14 | (define t_mutex (dotnet "System.Threading.Mutex"))
15 | (force-class-flush)
16 |
17 | (function thr:mkmutex ()
18 | (new t_mutex))
19 |
20 | (function thr:mutex_wait (mtx)
21 | ((r_tbind t_mutex "WaitOne") mtx))
22 |
23 | (function thr:mutex_release (mtx)
24 | ((r_tbind t_mutex "ReleaseMutex") mtx))
25 |
26 | )
27 |
28 | (macro block-on (wh . body)
29 | (with-syms (res ex)
30 | `(begin
31 | (thr:mutex_wait ,wh)
32 | (let ((,res (try
33 | (begin ,@body)
34 | t_Exception
35 | (fun (,ex)
36 | (thr:mutex_release ,wh)
37 | (r_raise ,ex)))))
38 | (thr:mutex_release ,wh)
39 | ,res))))
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/cs/dll/version.cs:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////////////////////////////////////////////
2 | //
3 | // OpenMBase
4 | //
5 | // Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | //
7 | //
8 | //////////////////////////////////////////////////////////////////////////////
9 |
10 |
11 | /*
12 | [assembly: AssemblyTitle(AssemblyVersion.kDescription)]
13 | [assembly: AssemblyDescription(AssemblyVersion.kDescription)]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany(AssemblyVersion.kCompanyName)]
16 | [assembly: AssemblyProduct(AssemblyVersion.kProductName)]
17 | [assembly: AssemblyCopyright(AssemblyVersion.kCopyright)]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 | [assembly: AssemblyVersion(AssemblyVersion.kFileVersion)]
21 | */
22 |
23 |
24 | internal class AssemblyVersion
25 | {
26 | public const System.String kCopyright = "";
27 | public const System.String kProductName = "MBase";
28 | public const System.String kDescription = "MBase";
29 | public const System.String kCompanyName = "Meta Alternative Ltd.";
30 | public const System.String kFileVersion = "0.2017.03.24";
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/misc/stylesheets.css:
--------------------------------------------------------------------------------
1 | #source {
2 | left: 60%;
3 | top: 60%;
4 | }
5 | #target {
6 | left: 120%;
7 | top: 120%;
8 | }
9 | .svgarrows {
10 | position: absolute;
11 | left: 0;
12 | top: 0;
13 | pointer-events: none;
14 | }
15 | line {
16 | stroke: grey;
17 | stroke-width: 2;
18 | stroke-opacity: 0.5;
19 | }
20 |
21 |
22 | .ident { color: #000099; }
23 | .keyword { color: blue; }
24 | .comment { color: green; }
25 | .lexic { color: #0099ff; }
26 | .pattern { text-shadow: 1px 1px 2px rgba(190, 190, 190, 1); }
27 | .code { font-family: monospace; border-style: dotted; border-width: 1px; font-size: 100%; }
28 | .democode { font-family: monospace; border-style: solid; border-width: 1px; font-size: 80%; }
29 | .const { color: #0099ff; }
30 | .symbol { color: #0099ff; }
31 | .column { width: 60%; text-align: justify; }
32 |
33 | .withhint { position: relative; }
34 | .hint { display: none; }
35 |
36 | .withhint:hover .hint {
37 | display: block;
38 | position: absolute;
39 | bottom: 1em;
40 | padding: 0.5em;
41 | color: #000000;
42 | background: #ebf4fb;
43 | border: 0.1em solid #b7ddf2;
44 | border-radius: 0.5em;
45 | }
46 |
47 | body { font-family: sans-serif; font-weight: 100; }
48 |
--------------------------------------------------------------------------------
/src/l/core/graphsort.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;- A naive but fast linear sorting engine for graph colouring
11 | ;-
12 | ;- The idea is simple: range of numbers is typically quite small, so we can allocate an
13 | ;- array for a known range, fill it in a linear time and build a list out of it.
14 | ;- This must be significantly faster than quick sorting lists.
15 | ;-
16 |
17 | (function __array_sort (rng)
18 | (if rng
19 | (let ((mn 65536)
20 | (mx 0))
21 | (foreach (r rng)
22 | (alet v (cadr r)
23 | (if (< v mn) (n.stloc! mn v))
24 | (if (> v mx) (n.stloc! mx v))))
25 | (let* ((nn (+ 1 (- mx mn)))
26 | (ar (anew t_object nn)))
27 | (foreach (r rng)
28 | (let* ((pos (- (cadr r) mn))
29 | (vlu ([ pos ] ar)))
30 | (aset ar pos (cons r vlu))))
31 | (alet res nil
32 | (for (i 0 nn)
33 | (alet vv ([ i ] ar)
34 | (if vv (foreach (v vv) (n.stloc! res (cons v res))))))
35 | res)))))
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/l/lib/parsing/lib.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (ctimex
11 | (#define packrat-optimised #t))
12 |
13 | (ctimex
14 | (#define packrat-hist nil))
15 |
16 | (include "./ast.al")
17 | (include "./util.al")
18 | (include "./ranges.al")
19 | (include "./compiler.al")
20 | (include "./lrengine.al")
21 | (include "./backend.al")
22 |
23 | (include "./temporary-source.al")
24 |
25 | (macro packrat-file (nm)
26 | (alet fp (generic-filepath nm)
27 | `(generic-include ,nm
28 | ,(alet res (peg:easyparse2 peg_pegparser
29 | (peg:file->stream fp))
30 | (p:match res
31 | (((FAIL: . $err) . $r) (ccerror `(PEG: ,err ,(__peg:displaypos r))))
32 | (else (car res)))))))
33 |
34 | (macro packrat-top-s (str)
35 | (alet res (peg:easyparse2 peg_pegparser
36 | (peg:str->stream str))
37 | (p:match res
38 | (((FAIL: . $err) . $r) (ccerror `(PEG: ,err ,(__peg:displaypos r))))
39 | (else (car res)))))
40 |
41 | (include "./highlight.al")
--------------------------------------------------------------------------------
/src/l/boot/stage4.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (_Clean_Deps)
11 |
12 | (include "../options.al")
13 |
14 | (ctimex (println "Bootstrap stage: 4"))
15 |
16 | (define ENV (cc:newenv))
17 | (cc:env:defmodule ENV "boot4" 'dll)
18 |
19 | (define compiled-environment #t)
20 | (define compiler-final #t)
21 |
22 | (begin
23 | (cc:toplevel-devour ENV '(top-begin
24 | (define compiler-final #t)
25 | (define compiled-environment #t)
26 | (define core-environment-compiled #t)
27 | (include "../boot/boot.al")
28 | (include "../boot/initlib.al")
29 | (include "../boot/dotnetlib.al")
30 | (include "../boot/common.al")
31 | ;;;;;
32 |
33 | (include "../core/compiler.al")
34 | (include "../core/unit.al")
35 | ))
36 | (cc:dump-module ENV)
37 | )
38 |
--------------------------------------------------------------------------------
/src/l/lib/ml/mlprelude.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 |
11 |
12 | (function mlprint (x) (print (ml-pprint-value x)))
13 |
14 | (function terpri (x) (println ""))
15 |
16 | (function mlmkhash (x) (mkhash))
17 |
18 | (function mlstringtolist (str)
19 | (let loop ((l (string->list str)))
20 | (p:match l
21 | (($a . $b) `(Cons ,a ,(loop b)))
22 | (() `(Nil)))))
23 |
24 | (function mllisttostring (lst)
25 | (list->string
26 | (let loop ((l lst))
27 | (p:match l
28 | ((Cons $a $b) `(,a ,@(loop b)))
29 | ((Nil) nil)))))
30 |
31 | (function ml-setcar! (l c)
32 | (set-car! (cdr l) c))
33 |
34 | (function ml-setcdr! (l c)
35 | (set-car! (cddr l) c))
36 |
37 | (function ml-mkref (v) (cons v nil))
38 |
39 | (function ml-deref (v) (car v))
40 | (function ml-setref (v n) (set-car! v n))
41 |
42 |
43 | (function lispclass (v)
44 | (p:match v
45 | (() '(FNull))
46 | ($$N '(FNumber))
47 | ($$S '(FString))
48 | ($$M '(FSymbol))
49 | ($$L '(FList))
50 | (else
51 | (if (char? v) '(FChar) '(FOther)))))
52 |
53 | (function ml-lispnull (_) nil)
54 |
55 |
56 |
--------------------------------------------------------------------------------
/src/l/lib/parsing/pegbasics.peg:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////////////////////////////////////////////
2 | //
3 | // OpenMBase
4 | //
5 | // Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | //
7 | //
8 | //////////////////////////////////////////////////////////////////////////////
9 |
10 | .peg:
11 |
12 | parser pegbasics extends basics (
13 | ignoring Spaces;
14 |
15 | pegbasics := .;
16 |
17 | keyword0 := 'rule'/'token'/'term'/'ignoring'/'define'/
18 | 'parser'/'extends'/'dynhook'/'check';
19 | keyword := keyword0 !IdentRest;
20 |
21 | rule lexical := lexical => {ctoken = lexic};
22 |
23 | IdentRest := alpha/digit/'_';
24 | token ident0 := !keyword (alpha IdentRest*) => {ctoken=ident};
25 | token ident1x := (alpha/'_'/'-'/'*'/'@'/'^'/'$'/'%'/'&'/digit)+
26 | => {ctoken=ident};
27 | term ident := { ident0:i => $sval(i)}
28 | / { '[[' ident1x:x ']]' => $sval(x)};
29 |
30 | comment := (('/*' (!'*/' .) * '*/') / ('//' (!(NEWLINE) .)* NEWLINE)) => {state=comment};
31 | token innerchar := . ;
32 | token tString := SQUOTE ( !SQUOTE . ) * SQUOTE;
33 | token tComment := '"' ( !'"' . ) * '"' => {state=comment};
34 |
35 | term string := tString:t => {ctoken = const} $stripval(t);
36 | term tcomment := tComment:t => $stripval(t);
37 | Spaces := (whitespace / comment) +;
38 | )
39 |
40 |
--------------------------------------------------------------------------------
/doc/template.tex:
--------------------------------------------------------------------------------
1 | \documentclass{article}
2 | \usepackage{alltt}
3 | \usepackage{rotating}
4 | \usepackage[usenames]{color}
5 | \usepackage[framemethod=tikz]{mdframed}
6 |
7 | \global\mdfdefinestyle{codeblock}{%
8 | outerlinewidth=2pt,innerlinewidth=0pt,
9 | outerlinecolor=gray,roundcorner=3pt
10 | }
11 |
12 |
13 |
14 | \newcommand{\colobox}[1]{
15 | \begin{tikzpicture}
16 | [execute at end picture=%
17 | {
18 | \begin{pgfonlayer}{background}
19 | \path[fill=black!10,thick,draw=black!40,rounded corners=0.8mm]
20 | (current bounding box.south west) rectangle
21 | (current bounding box.north east);
22 | \end{pgfonlayer}
23 | }]
24 | \node (box) {
25 | \begin{minipage}{\textwidth}
26 | #1
27 | \end{minipage}
28 | };
29 | \end{tikzpicture}\\}
30 |
31 | \newcommand{\commentbox}[1]{\colobox{\sl #1}}
32 |
33 | \newcommand{\lspspc}{{\color{white}{\tt{\_}}}}
34 | \newcommand{\lsplp}{(}
35 | \newcommand{\lsprp}{)}
36 |
37 | \newcommand{\docstring}[1]{\sl #1}
38 | \newcommand{\docentry}[1]{\sl #1}
39 |
40 | \newenvironment{pfcodeblock}[1]{}{}
41 | \newcommand{\pfcodeblockbegin}{\begingroup\setlength{\parindent}{0cm}\vskip1mm\begin{mdframed}[style=codeblock]}
42 | \newcommand{\pfcodeblockend}{\end{mdframed}\vskip1mm\endgroup}
43 |
44 |
45 | \definecolor{light-gray}{gray}{0.5}
46 |
47 |
48 | \begin{document}
49 |
50 | \tableofcontents
51 |
52 | \newpage
53 |
54 | \input generated
55 |
56 | \end{document}
57 |
--------------------------------------------------------------------------------
/src/l/ext/unittests.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (define t_exception (dotnet "Exception"))
11 | (recfunction deep-comp (a b)
12 | (cond
13 | ((and (null? a) (null? b)) #t)
14 | ((and (list? a) (list? b))
15 | (and (deep-comp (car a) (car b))
16 | (deep-comp (cdr a) (cdr b)) ))
17 | (else (eq? a b))))
18 |
19 | (function test-to-string (expr)
20 | (to-string
21 | (let loop ((e expr))
22 | (cond
23 | ((null? e) e)
24 | ((list? e)
25 | (cond
26 | ((and (car e)
27 | (eqv? (car e) '-test-hide-))
28 | (cadr e))
29 | (else
30 | (cons (loop (car e))
31 | (loop (cdr e))))))
32 | (else e)))))
33 |
34 | (macro u:etest (expr res0)
35 | `(begin
36 | (print ,(test-to-string expr))
37 | (let ((rval ,res0)
38 | (res (try ,expr t_exception to-string)) )
39 | (print " = ")
40 | (print (to-string res))
41 | (println (if (deep-comp res rval) " [OK]"
42 | (buildstring " [FAILED], exp: "
43 | (to-string rval))))
44 | )))
45 |
46 | (macro u:test (expr rest)
47 | `(u:etest ,expr (quote ,rest)))
--------------------------------------------------------------------------------
/src/l/ext/tarjan.al:
--------------------------------------------------------------------------------
1 | (function tarjan (g v0)
2 | (let* ((g.l (mkhash)) (g.i (mkhash))
3 | (myval (fun (x)
4 | (if (null? x) -1 x)))
5 | (mymin (fun (a b)
6 | (let ((a* (myval a)) (b* (myval b)))
7 | (if (< a* b*) a* b*))))
8 | (stack (mkref nil))
9 | (index (mkref 0)))
10 | (collector (SCCadd SCC)
11 | (use-ohash (g g.l g.i)
12 | (let loop ((v v0))
13 | (g.i! v (deref index))
14 | (g.l! v (deref index))
15 | (r! index (+ 1 (deref index)))
16 | (r! stack (cons v (deref stack)))
17 | (foreach (n (g> v))
18 | (if (= (myval (g.i> n)) -1)
19 | (begin
20 | (loop n)
21 | (g.l! v (mymin (g.l> v) (g.l> n))))
22 | (when (memq n (deref stack))
23 | (g.l! v (mymin (g.l> v) (g.i> n)))
24 | )))
25 | (when (= (g.l> v) (g.i> v))
26 | (format
27 | (let iloop ((s (deref stack)) (c nil))
28 | (alet nc (cons (car s) c)
29 | (if (eqv? (car s) v) (list nc (cdr s))
30 | (iloop (cdr s) nc))))
31 | (c s)
32 | (r! stack s)
33 | (SCCadd c)))))
34 | (return (SCC)))))
35 |
36 | (function graph2graph (g)
37 | (with-ohash (h)
38 | (foreach (e g)
39 | (h! (car e) (cdr e)))
40 | (return h)))
41 |
42 |
--------------------------------------------------------------------------------
/src/l/lib/ssa/doc.tex:
--------------------------------------------------------------------------------
1 | \documentclass{article}
2 | \usepackage{alltt}
3 | \usepackage{rotating}
4 | \usepackage[usenames]{color}
5 | \usepackage[framemethod=tikz]{mdframed}
6 | \usepackage{hyperref}
7 |
8 | \global\mdfdefinestyle{codeblock}{%
9 | outerlinewidth=2pt,innerlinewidth=0pt,
10 | outerlinecolor=gray,roundcorner=3pt
11 | }
12 |
13 |
14 |
15 | \newcommand{\colobox}[1]{
16 | \begin{tikzpicture}
17 | [execute at end picture=%
18 | {
19 | \begin{pgfonlayer}{background}
20 | \path[fill=black!10,thick,draw=black!40,rounded corners=0.8mm]
21 | (current bounding box.south west) rectangle
22 | (current bounding box.north east);
23 | \end{pgfonlayer}
24 | }]
25 | \node (box) {
26 | \begin{minipage}{\textwidth}
27 | #1
28 | \end{minipage}
29 | };
30 | \end{tikzpicture}\\}
31 |
32 | \newcommand{\commentbox}[1]{\colobox{\sl #1}}
33 |
34 | \newcommand{\lspspc}{{\color{white}{\tt{\_}}}}
35 | \newcommand{\lsplp}{(}
36 | \newcommand{\lsprp}{)}
37 |
38 | \newcommand{\docstring}[1]{\sl #1}
39 | \newcommand{\docentry}[1]{\sl #1}
40 |
41 | \newenvironment{pfcodeblock}[1]{}{}
42 | \newcommand{\pfcodeblockbegin}{\begingroup\setlength{\parindent}{0cm}\vskip1mm\begin{mdframed}[style=codeblock]}
43 | \newcommand{\pfcodeblockend}{\end{mdframed}\vskip1mm\endgroup}
44 |
45 |
46 | \definecolor{light-gray}{gray}{0.5}
47 |
48 | \begin{document}
49 | \setlength{\parindent}{0pt}
50 |
51 | \tableofcontents
52 |
53 | \newpage
54 |
55 | \newcommand*{\docpath}{./}%
56 | \input{\docpath/ssa-fold}
57 |
58 | \end{document}
59 |
--------------------------------------------------------------------------------
/src/l/core/pmatchcomp.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;;
11 | ;; A tail recursion-friendly reimplementation of pattern matching
12 | ;;
13 |
14 | (expand-if (shashget (getfuncenv) 'compiler-final)
15 | (top-begin
16 | (cmacro pm:ptn-try (cnd body)
17 | `(if ,cnd ,body
18 | (pm:ptn-failed-m)))
19 |
20 | (cmacro p:match (val . ptns)
21 | (with-syms (lop agr cnt res)
22 | `(let ,lop ((,agr ,val) (,cnt 0))
23 | (switch ,cnt
24 | ,@(let loop ((ps ptns) (n 0))
25 | (cond
26 | ((null? ps) `((,n nil)))
27 | ((eqv? 'else (caar ps))
28 | `((,n ,(cadar ps))))
29 | (else
30 | `((,n
31 | (with-macros ((pm:ptn-failed-m (fun (_)
32 | (list (quote ,lop) (quote ,agr) ,(+ n 1)))))
33 | ,(pm:ptn-unroll
34 | (pm:ptn-process (caar ps))
35 | agr
36 | `(begin ,@(cdar ps)))))
37 | ,@(loop (cdr ps) (+ n 1))))
38 | ))))))
39 | ))
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/l/ext/extra.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | ;;; some extra common macros
11 | ;;; UNDOCUMENTED - for internal use only!
12 |
13 | (recfunction extra:find-opt-argvalue (lst nm)
14 | (p:match lst
15 | (() 'nil)
16 | ((=nm $v . $rest) v)
17 | (($x $v . $rest) (extra:find-opt-argvalue rest nm))
18 | (else 'nil)))
19 |
20 | (macro extra:with-optional-args ( rlist alist . body)
21 | (let ((code
22 | (foreach-map (a alist)
23 | `(,a ,(extra:find-opt-argvalue rlist
24 | (string->symbol
25 | (S<< ":" a)))))))
26 | `(let ,code
27 | ,@body)))
28 |
29 |
30 | (macro extra:generic-include ( reader fnm )
31 | (let*
32 | ((misc-reader (eval reader))
33 | (oxpath (corelib:get-lookup-path))
34 | (fn (buildstring oxpath "/" fnm))
35 | (fi (mkreader (io-open-read fn)))
36 | (res `(top-begin
37 | (ctimex (corelib:set-lookup-path ,(_getpath fn)))
38 | ,@(let loop () (let ((r (misc-reader fi)))
39 | (if (null? r) nil
40 | (cons r (loop)))))
41 | (ctimex (corelib:set-lookup-path ,oxpath))
42 | )))
43 | (xio-close fi)
44 | res))
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/l/lib/ml/mlrepl.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 | (n.module mlrepl exe)
11 | (sysdll MBaseML)
12 |
13 | (function ml-read-eval-print (lst)
14 | (alet res (read-compile-eval `(ml ,(list->string lst)))
15 | (println (S<< ":>> " (ml-pprint-value res)))
16 | ))
17 |
18 | (define sem (car (string->list ";")))
19 | (function ml-read-eval-print-loop (redr)
20 | (let loop ((buf nil))
21 | (if (null? buf) (print "<< "))
22 | (format
23 | (p:match buf
24 | (($a $b . $r) (list a b))
25 | (else (list 0 0))) (a b)
26 | (if (and (eq? a sem) (eq? b sem))
27 | (begin
28 | (ml-read-eval-print (reverse buf))
29 | (loop nil))
30 | (alet chr (not.neth ((System.IO.StreamReader redr))
31 | (chr = (redr@Read))
32 | (object ret = null)
33 | (if (>= chr 0) (ret <- ((object)((char)chr))))
34 | (leave ret))
35 | (if (not chr) nil
36 | (loop (cons chr buf))))))))
37 |
38 | (function main ()
39 | (shashput (getfuncenv) 'main nil)
40 | (read-int-eval `(n.module DefaultML))
41 | (ml-read-eval-print-loop
42 | (not.neth ()
43 | (leave ((object)(new System.IO.StreamReader
44 | (System.Console@OpenStandardInput)))))))
45 |
46 |
--------------------------------------------------------------------------------
/src/l/tests/common.al:
--------------------------------------------------------------------------------
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 | ;;
3 | ;; OpenMBase
4 | ;;
5 | ;; Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | ;;
7 | ;;
8 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 |
10 |
11 | (expand-if (not (shashget (getfuncenv) 'test-to-string))
12 |
13 | (define t_exception (dotnet "Exception"))
14 | (recfunction deep-comp (a b)
15 | (cond
16 | ((and (null? a) (null? b)) #t)
17 | ((and (list? a) (list? b))
18 | (and (deep-comp (car a) (car b))
19 | (deep-comp (cdr a) (cdr b)) ))
20 | (else (eq? a b))))
21 |
22 | (function test-to-string (expr)
23 | (to-string
24 | (let loop ((e expr))
25 | (cond
26 | ((null? e) e)
27 | ((list? e)
28 | (cond
29 | ((and (car e)
30 | (eqv? (car e) '-test-hide-))
31 | (cadr e))
32 | (else
33 | (cons (loop (car e))
34 | (loop (cdr e))))))
35 | (else e)))))
36 |
37 | (macro u:etest (expr res0)
38 | `(begin
39 | (print ,(test-to-string expr))
40 | (let ((rval ,res0)
41 | (res (try ,expr t_exception to-string)) )
42 | (print " = ")
43 | (print (to-string res))
44 | (println (if (deep-comp res rval) " [OK]"
45 | (buildstring " [FAILED], exp: "
46 | (to-string rval))))
47 | )))
48 | )
49 |
50 | (macro u:test (expr rest)
51 | `(u:etest ,expr (quote ,rest)))
52 |
53 | (macro test (expr rest)
54 | `(u:etest ,expr (quote ,rest)))
55 |
56 | (macro etest rest
57 | `(u:etest ,@rest))
58 |
59 |
--------------------------------------------------------------------------------
/src/l/lib/parsing/basics.peg:
--------------------------------------------------------------------------------
1 | //////////////////////////////////////////////////////////////////////////////
2 | //
3 | // OpenMBase
4 | //
5 | // Copyright 2005-2017, Meta Alternative Ltd. All rights reserved.
6 | //
7 | //
8 | //////////////////////////////////////////////////////////////////////////////
9 |
10 | .peg:
11 |
12 | parser basics (
13 | alpha := [a-z]/[A-Z] ;
14 | digit := [0-9] ;
15 | lcalpha := [a-z];
16 | ucalpha := [A-Z];
17 |
18 | CR := 13;
19 | SQUOTE := 0x27;
20 | TAB := 9;
21 | NEWLINE := 10;
22 | whitespace := (' '/CR/TAB/NEWLINE)+ ;
23 |
24 | fpnumber := '-'? digit+ ('.' digit+)? ;
25 | intnumber := '-'? digit+ ;
26 | word := alpha+ ;
27 | define cslist