Go to file
VaclavT 8124724bca Readme update 2022-01-10 22:53:28 +01:00
.vscode debugger mode 2022-01-10 20:30:14 +01:00
clib supress two compiler warnings 2022-01-10 20:26:31 +01:00
doc some refactorings 2022-01-02 17:55:00 +01:00
stdlib stdlib additions 2022-01-10 20:28:37 +01:00
tests new test file 2022-01-10 20:28:50 +01:00
tmp debug changes 2021-03-07 17:23:09 +01:00
usql nul ass function parameter allowed 2022-01-10 20:29:21 +01:00
utils Merge branch 'master' of https://bitbucket.org/vaclavt/mlisp 2022-01-10 20:33:29 +01:00
.gitignore small lisp updates 2021-02-21 21:53:45 +01:00
CMakeLists.txt Merge branch 'master' of https://bitbucket.org/vaclavt/mlisp 2022-01-10 20:33:29 +01:00
Readme.md Readme update 2022-01-10 22:53:28 +01:00
debug.lsp tcp-server/client a bit improved 2021-11-05 15:27:21 +01:00
ml.cpp true and nil can be casted to string now 2022-01-10 20:25:57 +01:00
ml.h some refactorings 2022-01-02 17:55:00 +01:00
ml_date.cpp missing includes 2022-01-05 14:34:57 +01:00
ml_date.h some small refactoring 2021-12-19 13:34:29 +01:00
ml_io.cpp some small refactoring 2021-12-19 13:34:29 +01:00
ml_io.h #t and #f added to language, datetime fixes 2021-10-12 13:26:38 +02:00
ml_profiler.cpp supress two compiler warnings 2022-01-10 20:26:31 +01:00
ml_profiler.h detailed stracktrace only when option -d, second implemented in c++ 2021-10-11 12:04:49 +02:00
ml_string.cpp some refactorings 2022-01-02 17:55:00 +01:00
ml_string.h some refactorings 2022-01-02 17:55:00 +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 some refactorings 2022-01-02 17:55:00 +01:00
ml_util.h fixes & enhandcements 2021-03-14 16:15:04 +01: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
(defun qs (l)
    (if (<= (len l) 1)
        l
        (do
            (define 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

mkdir -p build
gcc -std=c99 -c -O2 -o linenoise.o clib/linenoise.c
c++ -c -O2  -I/usr/local/opt/openssl/include -Iclib --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 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/settings.cpp

// on linux c++ -o build/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/

or

utils/local_install.sh

KNOWNN BUGS

(read-url "https://api.nasdaq.com/api/calendar/dividends/") ; hangs in sslclient.cpp line 132

TODO

  • tcp-client, add support for list of requests returning list of responses
  • add debug support, at least call stack
  • multiline editing (see kilocpp editor)
  • execute system command should capture stderr
  • add some mem stats to benchmark

Code

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

Language

Performance

  • push_back - repeatedly without reserving size
  • range - with for(int i...) and reserving result size can be 3times faster on (range 1 10000)
  • 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