Go to file
Vaclav Tvrdik 17bdfdcbcb a bit od examples in doc 2022-12-29 14:13:56 +01:00
.vscode .vscode dir updates 2022-02-17 20:43:28 +01:00
clib constexpr instead const 2022-05-16 20:32:26 +02:00
doc a bit od examples in doc 2022-12-29 14:13:56 +01:00
docker no cache in docker file 2022-05-05 18:01:37 +02:00
stdlib fix erroneous paren 2022-09-12 16:05:08 +02:00
tests small updates 2022-05-27 17:35:22 +02:00
tmp nothing important 2022-01-27 00:01:45 +01:00
usql double is alias of float 2022-06-02 14:14:06 +02:00
utils added comment for creating installation dirs 2022-09-12 16:04:48 +02:00
.gitignore .vscode dir updates 2022-02-17 20:43:28 +01:00
CMakeLists.txt monterey homebrew directory change 2022-09-12 15:45:35 +02:00
Readme.md clear warning 2022-06-02 14:13:38 +02:00
debug.lsp small updates 2022-05-27 17:35:22 +02:00
debug_cron_wip.lsp doc updates 2022-03-06 19:58:30 +01:00
ml.cpp load_std_lib moved to anothep place in file 2022-06-16 17:08:58 +02:00
ml.h mkdir and rmdir basic implementation 2022-03-21 17:46:32 +01:00
ml_date.cpp get-universal-time-ms added 2022-05-27 17:34:57 +02:00
ml_date.h get-universal-time-ms added 2022-05-27 17:34:57 +02:00
ml_io.cpp tcp nes wip 2022-05-05 18:37:51 +02:00
ml_io.h tcp nes wip 2022-05-05 18:37:51 +02:00
ml_profiler.cpp clear warning 2022-06-02 14:13:38 +02:00
ml_profiler.h defmacro added, doc improvements 2022-01-29 15:35:42 +01:00
ml_string.cpp handling nil fix 2022-01-22 23:03:13 +01:00
ml_string.h restore correct datatype 2022-01-16 19:54:06 +01:00
ml_usql.cpp small refactorings 2021-12-19 16:31:54 +01:00
ml_usql.h very basic version of usql 2021-07-14 12:01:44 +02:00
ml_util.cpp input2 added 2022-05-19 18:38:52 +02:00
ml_util.h input2 added 2022-05-19 18:38:52 +02:00
wip.lsp move test to its files 2022-05-05 18:01:19 +02:00

Readme.md

ml

is a small lisp interpreter based on Adam McDaniel's wisp interpreter (https://github.com/adam-mcdaniel/wisp). It's main purpose is to learn something about more recent c++

Example of use

cat <<EOT > /tmp/qs.lsp
(defn qs (l)
    (if (<= (len l) 1)
        l
        (do
            (def pivot (first l))
            (+
                (qs (filter (lambda (n) (> pivot n)) l))
                (list pivot)
                (qs (tail (filter (lambda (n) (<= pivot n)) l)))
            ))
    ))

(print (qs '(10 9 8 7 6 5 4 3 2 10)))
EOT

ml -f /tmp/qs.lsp

or

ml -f tests/test.lsp

Interactive mode

ml

Documentation

see /doc/Doc.md

Dependencies

  • libssl-dev

Compile

gcc -std=c99 -c -O2 -o linenoise.o clib/linenoise.c
c++ -c -O2  -I/usr/local/opt/openssl/include -Iclib -I./ --std=c++17  ml.cpp ml_io.cpp ml_date.cpp ml_string.cpp ml_util.cpp ml_profiler.cpp ml_usql.cpp clib/json11.cpp clib/csvparser.cpp clib/sslclient.cpp clib/printf.cpp clib/sslclient.cpp clib/tcpnet.cpp usql/exception.cpp usql/lexer.cpp usql/parser.cpp usql/usql.cpp usql/table.cpp usql/table.h usql/row.cpp usql/csvreader.cpp usql/usql.cpp usql/usql_ddl.cpp usql/usql_dml.cpp usql/usql_function.cpp  usql/settings.cpp

// on linux c++ -o ml -O2 -L/usr/local/lib -L/usr/local/opt/openssl/lib -lm -lstdc++ -lcrypto -lssl *.o
c++ -o build/ml -O2 -L/usr/local/lib -L/usr/local/opt/openssl/lib -lm -lstdc++ -lcrypto -lssl -Wl,-stack_size -Wl,0x1000000 *.o

or use

cmake .
make

Install

cp build/ml /usr/local/bin/ml
cp stdlib/*.lsp /usr/local/var/mlisp/
cp doc/*.md /usr/local/var/mlisp/

or

utils/local_install.sh

KNOWNN BUGS

TODO

  • order of arguments in functions like member and filter - filter swap lambda and list
  • add possibility to specify filename for input2 history file
  • better output of !e in repl (resp !e !ee)
  • unify -f and -run options
  • add debug support, at least call stack
  • add mem stats to benchmark
  • execute system command should capture stderr
  • multiline editing (see kilocpp editor)

Doc

  • add functions from stdlib into doc
  • doc for set!

Code

  • tcpnet should use RAII
  • add more unit test, especially for usql
  • add instrumentation (time, nr of evals, num of atoms, debug info, debug environment etc)

Language

  • string functions
    • regexp match, regexp tokens

Performance

  • push_back - repeatedly without reserving size
  • mini_sprintf - unnecesary copying between vector and list
  • (do, scope, cond ..) repeatedly assign to acc

https://github.com/adam-mcdaniel/wisp
https://github.com/dropbox/json11
https://github.com/antirez/linenoise

read stdout and stderr from popen

https://stackoverflow.com/questions/478898how-do-i-execute-a-command-and-get-the-output-of-the-command-within-c-using-po