Commit Graph

174 Commits

Author SHA1 Message Date
Aryadev Chavali
55ed8c5939 lisp: lisp_reset, vec: vec_reset
Reset method to "clear the memory" of a lisp object.  Only operates on
heap allocated objects.
2026-03-05 22:11:23 +00:00
Aryadev Chavali
edce319957 main: fix issue with unused variable on release mode builds 2026-03-05 20:33:41 +00:00
Aryadev Chavali
775d9f51bf reader: add position restoration for read_vec and read_list
Same as read_str really, using a label to push control flow.
2026-03-05 20:27:13 +00:00
Aryadev Chavali
c65ec319f5 lisp: lisp_print: implement support for strings 2026-03-05 20:27:00 +00:00
Aryadev Chavali
fd9cc93c45 lisp: lisp_print: fix issue with extra space when printing vectors 2026-03-05 20:26:40 +00:00
Aryadev Chavali
e594b6ce70 reader: read_str restores stream position for no closing speechmarks
Say you have the following Lisp code: `"hello world` (no closing
speechmark).  This read_str implementation will now place
stream->position at the first speechmark rather than at the
EOF (what happened previously) which is a bit nicer.
2026-03-05 20:25:03 +00:00
Aryadev Chavali
fee6614670 reader: implement reader for strings 2026-03-05 20:13:52 +00:00
Aryadev Chavali
1998954b56 reader: slight adjustments based on change INT -> SMI 2026-03-05 20:13:18 +00:00
Aryadev Chavali
e629b9919e Makefile: added -Wswitch-enum to warning flags 2026-03-05 19:59:59 +00:00
Aryadev Chavali
37d1764c6e reader: use make_list in read_quote 2026-03-05 19:59:46 +00:00
Aryadev Chavali
cb8d1b1139 sys: make_list constructor
Takes a fixed array of lisp_t pointers, and makes a cons list out of
them.
2026-03-05 19:59:23 +00:00
Aryadev Chavali
2a13c89496 doc: add r7rs PDF for reference 2026-03-05 19:48:00 +00:00
Aryadev Chavali
b925a68986 vec: FOR_VEC macro 2026-03-05 19:47:46 +00:00
Aryadev Chavali
99448f6702 allocator|lisp: support for strings 2026-03-05 19:47:03 +00:00
Aryadev Chavali
bbb66d5fb1 string: new string library
Strings are simply byte vectors.  We want a separate type so when
tagging/untagging we can have some level of type separation.
2026-03-05 19:44:58 +00:00
Aryadev Chavali
b93042fd27 lisp: INT -> SMI
when we implement big integer support, we should use INT there
instead.  SMI signals intent much better.
2026-03-05 19:41:16 +00:00
Aryadev Chavali
a50ca72b24 lisp: 63 bit -> 56 bit SMI
This massively simplifies the tagging implementation as all types now
have a 1 byte tag.  However, this does make the need for Big Integers
much greater as we've lost 8 bits of precision.
2026-03-05 18:36:43 +00:00
Aryadev Chavali
7f2dcc3ad2 alisp.org: mark TODOs 2026-03-05 17:32:52 +00:00
Aryadev Chavali
4bc615ab29 lisp_print: print verbose logs for lisp types on VERBOSE_LOGS=2 2026-03-05 17:32:52 +00:00
Aryadev Chavali
fc602f1664 allocator: free_list -> free_vec 2026-03-05 17:32:52 +00:00
Aryadev Chavali
30a87d4a1b some small updates 2026-03-05 17:32:52 +00:00
Aryadev Chavali
9940651ac0 alloc: arena_t -> alloc_t
arena_t doesn't really make sense given we also have a free list.
Better to name it generic.
2026-03-05 17:32:52 +00:00
Aryadev Chavali
be0a6dd0c8 allocator: arena_make now takes nodes off the free list first. 2026-03-05 17:32:52 +00:00
Aryadev Chavali
9a91511e48 sys: plug in allocator 2026-03-05 17:32:52 +00:00
Aryadev Chavali
f9a044f631 allocator: implement a basic allocator 2026-03-05 17:32:52 +00:00
Aryadev Chavali
0e75b541df vec: vec_try_append
Essentially a method to attempt to append data but without doing any
reallocation - stay within the bounds of the capacity.
2026-03-05 17:32:52 +00:00
Aryadev Chavali
e6e501c5a3 lisp: tag_generic, tag_sizeof, and lisp_sizeof 2026-03-05 17:32:52 +00:00
Aryadev Chavali
a79f60a203 lisp: split lisp into lisp and sys
Generic definition of tagged pointers, along with simple
constructor/destructors should be in lisp.h for use by other headers.

sys.h on the other hand contains all the general system methods.
2026-03-05 17:32:52 +00:00
Aryadev Chavali
79f53c7916 alisp.org: rework TODOs, setup one for allocators. 2026-02-12 23:03:05 +00:00
Aryadev Chavali
042cc48e8c lisp: split memory into its own structure 2026-02-12 22:51:29 +00:00
Aryadev Chavali
b51aaa3d65 lisp: replace sys_register with sys_alloc
Allows us to abstract allocation away, creating Lisps automatically.
2026-02-12 22:51:29 +00:00
Aryadev Chavali
6499a9dd6d lisp: combine tag.h into lisp.h 2026-02-12 22:51:29 +00:00
Aryadev Chavali
c1cdb8607d lisp: split memory into conses and vectors
During garbage collection, we'll iterate through these two vectors.
Instead of freeing the memory, we can swap cells in the vector and
decrement its size.

The idea is we can attach an allocator to the system where we reuse
memory instead of just allocating everytime.
2026-02-12 22:51:29 +00:00
Aryadev Chavali
7df292ed9e alisp.org: mark WIP -> TODO 2026-02-11 10:31:23 +00:00
Aryadev Chavali
4aad62fec9 alisp.org: update 2026-02-11 10:29:57 +00:00
Aryadev Chavali
a4fb48a863 reader: implement read_vec and setup errors for random closed brackets 2026-02-11 10:29:57 +00:00
Aryadev Chavali
5f05a6a108 lisp: implement TAG_VEC lisp_print method 2026-02-11 10:29:57 +00:00
Aryadev Chavali
e60a7459e0 reader: fix issue with read_list of infinite loop 2026-02-11 10:29:57 +00:00
Aryadev Chavali
4936460b39 reader: factor out read_negative 2026-02-11 10:29:57 +00:00
Aryadev Chavali
04be0ecad0 alisp.org: update todos 2026-02-11 10:29:57 +00:00
Aryadev Chavali
f09e0d33a4 reader: deal with negative prefix numbers in read 2026-02-11 10:29:57 +00:00
Aryadev Chavali
d1d0783fc3 reader: implement read_int 2026-02-11 10:29:57 +00:00
Aryadev Chavali
21254e77bf tag: INT_MAX/INT_MIN are now i64 by default 2026-02-11 10:29:57 +00:00
Aryadev Chavali
e772b06ae5 main: rearrange code and setup prototypes 2026-02-11 10:29:57 +00:00
Aryadev Chavali
eca46069f8 main: print out expressions from reading 2026-02-11 10:29:57 +00:00
Aryadev Chavali
c2f1835b4c main: factor out the stream init code into its own function 2026-02-11 10:29:57 +00:00
Aryadev Chavali
93a52db7cc alisp.org: add TODO about reader macros 2026-02-11 10:29:57 +00:00
Aryadev Chavali
d88bc2baeb alisp.org: mark some TODOs 2026-02-11 10:29:57 +00:00
Aryadev Chavali
2dc0c6080e reader: deal with quotes
This is currently implemented as a parse-time primitive.  Scheme
doesn't seem to have reader macros (which is INSANE) but Common Lisp
does.  We'll need to add a TODO about this.
2026-02-11 10:29:57 +00:00
Aryadev Chavali
8e81e6f762 reader: at every iteration of read_all, skip comments and whitespace 2026-02-11 10:29:57 +00:00