The MathLight compiler

MathLight is a lightweight implementation of MATLAB.
As a programming language, it allows basic matrix manipulations and
common statistics computations. Our goal is to make it as an easy,
fast and flexible language and the basic syntax is similar to C/C++.

It needs the OCaml llvm library, which is most easily installed through opam.

Install LLVM and its development libraries, the m4 macro preprocessor,
and opam, then use opam to install llvm.

The version of the OCaml llvm library must match the version of the LLVM
system installed on your system. At the time of the development, we use
ocaml 4.07 and llvm 7.0.0.

testall.sh runs the mathlight
executable on each testcase (.txt file) to produce a .ll file, invokes
"llc" (the LLVM compiler) to produce a .s (assembly) file, then
invokes "cc" (the stock C compiler) to assemble the .s file,
and generate an executable.  See testall.sh for details.

------------------------------
To run and test:

$ make
opam config exec -- \
  ocamlbuild -use-ocamlfind mathlight.native
Finished, 25 targets (0 cached) in 00:00:02.
./testall.sh
-n test-abs...
OK
-n test-comments...
OK
-n test-declare-and-assign...
OK
-n test-demo2...
OK
-n test-demo3...
OK
-n test-determinant...
OK
-n test-dim...
OK
-n test-double_add_mat...
OK
-n test-double_mul_matrix...
OK
-n test-double_ope_int...
OK
-n test-double_operator...
OK
-n test-element-change...
OK
-n test-fill...
OK
-n test-for...
OK
-n test-func-inv...
OK
-n test-func-matrix-return...
OK
-n test-func-matrix...
OK
-n test-func...
OK
-n test-global-declare-and-assign...
OK
-n test-helloworld...
OK
-n test-if...
OK
-n test-integer_operator...
OK
-n test-log...
OK
-n test-logical-op...
OK
-n test-lr-calc...
OK
-n test-mat_1d_ele...
OK
-n test-mat_add...
OK
-n test-mat_concat_hor...
OK
-n test-mat_concat_ver...
OK
-n test-mat_mul...
OK
-n test-mat_ope_int...
OK
-n test-mat_sub...
OK
-n test-matrix_dot_div...
OK
-n test-matrix_dot_mul...
OK
-n test-matrixaccess...
OK
-n test-max_eigvalue...
OK
-n test-mean...
OK
-n test-neg...
OK
-n test-norm1...
OK
-n test-norm2...
OK
-n test-not...
OK
-n test-pow...
OK
-n test-primitive-op...
OK
-n test-printbool...
OK
-n test-printdouble...
OK
-n test-printint...
OK
-n test-printmatrix...
OK
-n test-printmatrix_lit...
OK
-n test-sqrt...
OK
-n test-sum...
OK
-n test-tr...
OK
-n test-transpose...
OK
-n test-variable...
OK
-n test-while...
OK
-n fail-assignerr...
OK
-n fail-duplicatefuncs...
OK
-n fail-duplicatevars...
OK
-n fail-forloop...
OK
-n fail-funcnotexist...
OK
-n fail-funcwrongargslen...
OK
-n fail-funcwrongargstype...
OK
-n fail-funcwrongreturntype...
OK
-n fail-helloworld...
OK
-n fail-ifwrongcond...
OK
-n fail-illegalbinop...
OK
-n fail-illegalcharacter...
OK
-n fail-illegalmatrixbinop...
OK
-n fail-matrixaccess...
OK
-n fail-matrixaccesstype...
OK
-n fail-matrixconcat...
OK
-n fail-matrixmodifytype...
OK
-n fail-nomain...
OK
-n fail-noreturn...
OK
-n fail-varnotexist...
OK
-n fail-wrongrange...
OK
-n fail-wrongrangetype...
OK