summaryrefslogtreecommitdiff
path: root/src/lisp
Commit message (Collapse)AuthorAge
* altos/scheme: Rename to 'scheme', clean up buildKeith Packard2017-12-05
| | | | | | | | | Constant block is now built in a subdir to avoid messing up source directory. Renamed to ao_scheme to reflect language target. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Switch to scheme formal syntax for varargsKeith Packard2017-12-03
| | | | | | | | | | Scheme uses bare symbols to indicate a varargs parameter; any bare (i.e., not wrapped in a cons cell) parameter will get the 'rest' of the parameter list. This works for lambdas, nlambdas and macros. As a result, the 'lexpr' form has been removed as it is equivalent to a lambda with a varargs formal. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix stash usage across frame allocationKeith Packard2017-12-03
| | | | | | | Must un-stash before allocation failure check. Use frame_stash instead of poly_stash for frames. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Check only cdr base type when moving cons cellsKeith Packard2017-12-03
| | | | | | | | The cdr may have moved, so we can't look at the target object type. Fortunately, the base type encoded in the reference itself is sufficient to check for a non-cons cdr. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Split out read debug, add memory validationKeith Packard2017-12-03
| | | | | | | | Split read debug into a separate #define to reduce debug noise Add some memory validation -- validate stash API, and validate cons_free calls. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: use strtof instead of atofKeith Packard2017-12-02
| | | | | | atof returns double, strtof returns float. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Convert more builtin lisp code to scheme formatKeith Packard2017-12-02
| | | | | | Use defines where possible, use (define (name args ...)) form for lambdas Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Overflow int computations to floatKeith Packard2017-12-02
| | | | | | When an int computation overflows, switch to float. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: split set/def. Add def support to lambdasKeith Packard2017-12-01
| | | | | | | | In scheme, set can only re-define existing variables while def cannot redefine existing variables in lambda context. Def within lambda creates a new variable at the nearest enclosing scope. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Split out frame vals from frame structKeith Packard2017-12-01
| | | | | | | This lets the frame be resized without moving the base structure. The plan is to allow all frames to be resized, not just the global frame. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Make let distinct from let*Keith Packard2017-12-01
| | | | | | | | let is supposed to define the values all at once, evaluating the initializers in the enclosing context. let* defines the new names and then initializes them one at a time. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: return from unmatched cond is #f, not nilKeith Packard2017-12-01
| | | | | | | Fix the return value when we fall off the end of a cond expression to be #f Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix pairp builtinKeith Packard2017-12-01
| | | | | | Pairs are non-nil cons values; add an explicit check for nil here Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add quasiquoteKeith Packard2017-12-01
| | | | | | | This adds read support for quasiquote syntax, and then adds a quasiquote implementation in lisp Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Rename progn to beginKeith Packard2017-11-25
| | | | | | Match scheme name. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add floatsKeith Packard2017-11-19
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix some scheme compat issuesKeith Packard2017-11-18
| | | | | | | | | | flush -> flush-output nth -> list-ref (oh, and add list-tail) add let* (same as let for now) write control chars in octal make hanoi example work Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add 'big' ints -- 24 bits wideKeith Packard2017-11-18
| | | | | | | With the default ints being only 14 bits, having a larger type with more precision seems useful. This is not exposed to the application. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Finish first pass through r7rsKeith Packard2017-11-17
| | | | | | | | | | * print -> write, patom -> display * Add read-char, write-char * Add exit, current-jiffy, current-second, jiffies-per-second * Add for-each and string-for-each * Avoid duplicate builtins with different atoms Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add applyKeith Packard2017-11-17
| | | | | | And all of the library routines that use it, map, string-map and friends. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Character consts. String and assoc builtins.Keith Packard2017-11-17
| | | | | | Also add back escaped characters in strings. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Generate built-in lambda atoms for const creationKeith Packard2017-11-17
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Lots more scheme bitsKeith Packard2017-11-16
| | | | | | | | * Arithmetic functions and tests * append, reverse and list-tail * set-car! and set-cdr! Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: More schemismsKeith Packard2017-11-16
| | | | | | | | | | Add 'if'. setq -> set!, but doesn't define new variables def -> define Add pair? and list? Add eq? and eqv? as aliases for = Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add 'else' sematics to condKeith Packard2017-11-16
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add scheme-style bools (#t and #f)Keith Packard2017-11-16
| | | | | | Cond and while compare against #f, just like scheme says to. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add non-cons cdr supportKeith Packard2017-11-16
| | | | | | | The cdr of a cons can be any value; add support for lexing and printing them. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos: Escape lisp REP loop with () inputKeith Packard2017-04-09
| | | | | | | Provide a way to get out of a lisp read-eval-print loop that can be easily input from the keyboard. Signed-off-by: Keith Packard <keithp@keithp.com>
* lisp: Fix up lisp build so projects can get ao_lisp_const.h built as neededKeith Packard2017-04-02
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Not quite ready to start making it look like scheme yetKeith Packard2017-02-20
| | | | | | Lots more code to write before these symbols can be exposed. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Start adding scheme symbolsKeith Packard2017-02-20
| | | | | | Migrating to something more like scheme Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add casts to keep the latest GCC from whingingKeith Packard2017-02-20
| | | | | | Something about alignment issues. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Tell compiler that the two lisp memory pools are alignedKeith Packard2017-02-20
| | | | | | | Otherwise, it will generate unaligned accesses to things fetched from them. Sigh. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Move stack recursion check after null checkKeith Packard2017-02-20
| | | | | | Don't crash when printing null stack this way. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Cleanup some DBG definesKeith Packard2017-02-20
| | | | | | Get rid of the remaining duplicate defines. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Share binary search for memory chunk between mark and moveKeith Packard2017-02-20
| | | | | | Save some text space. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add builtin 'collect'Keith Packard2017-02-20
| | | | | | Collect memory, return amount free. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Sort frames by atomKeith Packard2017-02-20
| | | | | | | | | Fortunately, the collector always retains the relative order between addresses, so we can sort based on the atom address itself. This reduces the time spent looking for names in larger (e.g. global) frames. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: bounds check in move_map plus binary searchKeith Packard2017-02-20
| | | | | | | | | | This makes move_map faster by skipping all addresses which aren't changing. Also changed the interface from address to offset to avoid computing the offset multiple times. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Empty lambda body is not an errorKeith Packard2017-02-20
| | | | | | It's not very exciting, but it's still legal Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Use poly stashes for stacksKeith Packard2017-02-20
| | | | | | Saves some memory. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Make DBG settings globalKeith Packard2017-02-20
| | | | | | This avoids having different values in different files, which wasn't useful. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Add continuationsKeith Packard2017-02-20
| | | | | | This provides call/cc and makes 'stacks' visible to the application. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: have 'while' return the last body valueKeith Packard2017-02-20
| | | | | | | Instead of always returning 'nil', let while return the last body value. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Take advantage of implicit progn in ROM codeKeith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Make lambda, cond and while all have implicit prognsKeith Packard2017-02-20
| | | | | | | This lets all of these execute more than one sexpr, returning the value of the last. Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Compile ao_lisp_make_const -no-pieKeith Packard2017-02-20
| | | | | | Makes debugging easier Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix uninitialized values in ao_lisp_make_constKeith Packard2017-02-20
| | | | Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Dump globals on errorKeith Packard2017-02-20
| | | | | | Useful for debugging Signed-off-by: Keith Packard <keithp@keithp.com>
* altos/lisp: Fix error atom name in ao_lisp_lengthKeith Packard2017-02-20
| | | | | | Cut&paste error. Signed-off-by: Keith Packard <keithp@keithp.com>