flisp repl implemented completely in Lisp itself#62
Open
jorge-leon wants to merge 93 commits into
Open
Conversation
See test/1_dired.lsp for a demo test suite Run `make ltest` to execute it.
tap code is simplified: instead of appending a test to the test list it is prepended and the list of tests is reversed before iterating over it. This adds `reverse` and `flip` to the flisp library.
The `run` test suite runner is renamed to `test` and it got proper command line parsing. All test suites must be named *.test. The first line determines if it is to be tested by poor mans shell test runner within flips or by the Lisp implementation tap.lsp within femto. The first line must contain the Emacs mode string: -*- mode: _type_ -*- where type is `sh` for flisp and `lisp` for femto. `tap.lsp` has a simple command line parser to specifiy the test(s) to run. For writing test scripts: Write a function which returns a true value if the test passes. Register the function and a test comment with tap.lsp: `(tap-register comment function)`
Will need this for file mode operations.
Added file.h, flisp_file_primitives struct in file.c and load it in initRootEnv() in lisp.c
Parametrized readNumberOrSymbol to compile for integer only if double extension is not required.
Since the double extension is practically required, it must be declared in the build of all extension files to not get the type enums wrongly ordered.
fstat returns a property list with size, mode uid, gid and type, type as string. It throws one of the following exceptions: - permission-denied - not-found - io-error (catch (fstat path)) can therefore be used to test for existence of files.
Duplicate "catch" code in lisp-eval() is replaced by using evalCatch. The only interface with the interpreter is now interp->object, which receives a catch object (error_type message object). If error_type == nil, object is the result, otherwise object is the err'ed object (or nil) and message a string object, message->string the error message.
to- and fromSpace are allocated individually and resized on demand. FLISP_MEMORY_INC_SIZE determines the size of allocation junks. Note: While all tests pass when sufficient initial memory is given, gc_always still segfaults.
Must be rewritten in Lisp
…ory size The interpreter allocates a minimal chunk of memory to boot itself on start. After that, every time the Lisp object memory is to small, it is increased by a specific chunk size. Both parameters: FLISP_MIN_MEMORY and FLISP_MEMORY_INC_SIZE are defined lisp.h. While the approach is working well, there are problems with segfaults, when using gc_always. These seem to be related to wrong GC_TRACE'ing Note: on startup the interpreter prints out, how much memory is used for the initial startup. We round it up manually to the chunk size.
All done items sorted into their version section.
- Fix: Femto did not include the file extension.
- Implement a log facility in startup.lsp.
- Use (catch (fstat ..)) instead of (sytem ("test .." ..)) to test for
existance of user rc file.
- Improve (getopts) - currently to not allow any command line option.
- Autoload oxo to reduce startup load.
- Set up sensible logging for rc file loading and command line parsing.
femto.rc includes a repl which only prints out something when stdin is a tty. No additional library is loaded on startup. Moved append, fold-left, flip, reverse, apply, print, princ to core.lsp to be able to use apply, princ and print. Pending: - (flisp input) - (flisp version) - If stdin is not a tty just set interp input to it.
fprintf of fixed strings are waste of computing power. The %p format differs in output for different platforms. For printing the stream serialization we use now the uintptr_t to print the file descriptor.
The (flisp) command will provide introspection and configuration of the current interpreter. The 'version sub command returns the full version string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR simplifies the
flispcommand substantially, by implementing the complete Read Eval Print Loop (repl) in Lisp itself.Previous PR's have added some required features, this PR adds a new function
interpfor introspection and configuration of the Lisp interpreter. Currently it only supports reading the version string and setting the input stream of the interpreter.Several other pending simplification have been included: The
stdlib.lspwas integrated intoflisp.lsp, thus the number of Lisp files (test suites and documentation chapters) is reduced. Several useful functions have been moved into thecore.lsplibraryand thus are loaded on startup.
The fLisp core has been reduced further, by replacing some fprintf's with fputs and introducing the
bindfunction.setqis implemented as a macro in terms ofbind. All I/O functions not related to fLisp startup itself are move to the file extension.Documentation and test suites have been expanded.
Change List:
input subcommands.