|
|
||
|---|---|---|
| .vscode | ||
| clib | ||
| doc | ||
| stdlib | ||
| tests | ||
| tmp | ||
| usql | ||
| utils | ||
| .gitignore | ||
| CMakeLists.txt | ||
| Readme.md | ||
| debug.lsp | ||
| ml.cpp | ||
| ml.h | ||
| ml_date.cpp | ||
| ml_date.h | ||
| ml_io.cpp | ||
| ml_io.h | ||
| ml_profiler.cpp | ||
| ml_profiler.h | ||
| ml_string.cpp | ||
| ml_string.h | ||
| ml_usql.cpp | ||
| ml_usql.h | ||
| ml_util.cpp | ||
| ml_util.h | ||
| wip.lsp | ||
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
- in (include "file.lsp") are not available stdlib.lsp finctions like (string-trim ..) etc
- (read-url "https://api.nasdaq.com/api/calendar/dividends/") ; hangs in sslclient.cpp line 132
TODO
- add functions from stdlib into doc
- string-case, save-csv fix doc
- add test for >>> (range 1.5 (inc 5.5)) => (1.500000 2.500000 3.500000 4.500000 5.500000)
- better formating of help
- unify -f and -run options
- add debug support, at least call stack
- multiline editing (see kilocpp editor)
- execute system command should capture stderr
- add some mem stats to benchmark
- order of arguments in functions like member and filter - filter swap lambda and list
Doc
- fix man entry on (member) example and retval
- doc for set!
- doc for doc::??? functions
Code
- tcpnet should use RAII
- add documentation - some code lide (doc::add func_name desc example flags), (doc::help name), (doc::appropos text)
- add more unit test, mainly for usql
- add instrumentation (time, nr of evals, num of atoms, debug info, debug environment etc)
Language
- string functions
- compare - needed for sorting, cmp ignore case
- regexp match, regexp tokens
- date support
- decode-universal-time (http://www.lispworks.com/documentation/HyperSpec/Body/f_dec_un.htm)
- env functions
- get-env, set-env; set-env cannot be implemented in stdlib.lsp, because popen is in fact subshell
Performance
- push_back - repeatedly without reserving size
- mini_sprintf - unnecesary copying between vector and list
- (do, scope, cond ..) repeatedly assign to acc
Links
https://github.com/adam-mcdaniel/wisp
https://github.com/dropbox/json11
https://github.com/antirez/linenoise