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
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
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
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
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
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
Aryadev Chavali
a49492b27f
stream: clean up
2026-02-11 10:29:57 +00:00
Aryadev Chavali
8b2fe97fc2
lisp: sys_cost for memory footprint
2026-02-11 10:29:57 +00:00
Aryadev Chavali
ff512986f8
symtable: sym_table_cost
...
Useful for figuring out the rough memory footprint (actually utilised)
by the symbol table.
2026-02-11 10:29:57 +00:00
Aryadev Chavali
47f33cb969
tag: make function inputs constant
2026-02-11 10:29:57 +00:00
Aryadev Chavali
39e5b76f8b
lisp: lisp_print
2026-02-11 10:29:57 +00:00
Aryadev Chavali
b91e79933b
symtable: refactor for SV changes and propagate
2026-02-11 10:29:57 +00:00
Aryadev Chavali
3e7734037c
sv: rearrange sv_substr and sv_truncate
2026-02-11 10:29:57 +00:00
Aryadev Chavali
9f3bb57972
sv: major refactor
...
- Internal data pointer is read only by default => any uses that
require use of the pointer itself (freeing, mutating) must perform a
cast.
- refactor tests to use some new sv macros and functions, and clean
them up.
- slight cleanup of sv.c
2026-02-11 10:29:57 +00:00
Aryadev Chavali
b646ae3f7e
sv: fix sv_substr
...
Issue I came up with when looking at the code, based on
sv_chop_right's impl. Why do we keep this function around again?
2026-02-11 10:29:57 +00:00
Aryadev Chavali
daa1d3d565
lisp: add and implement lisp_free_rec
...
May be useful for testing.
2026-02-11 10:29:57 +00:00
Aryadev Chavali
b7fc5170b0
reader: implement read_sym and read_list
...
To be tested properly.
2026-02-11 10:29:57 +00:00
Aryadev Chavali
7ef6905d7a
main: fit reader into main.
2026-02-11 10:29:57 +00:00
Aryadev Chavali
c12f4b2d2c
reader: some work done on basic API
2026-02-11 10:29:57 +00:00
Aryadev Chavali
fe727d75e4
remove breaks after return in switch-case
2026-02-09 09:57:04 +00:00
Aryadev Chavali
06a4eafbb9
stream: optimise stream_substr_abs, stream_till, stream_while
...
In the base cases of STRINGS and FILES, these functions should be very
quick (operating on stuff in memory), and amortized for pipes.
2026-02-09 09:57:04 +00:00
Aryadev Chavali
fc5a6eb8fb
stream: refactor stream_seek_forward for changes in FILE API
2026-02-09 09:57:04 +00:00
Aryadev Chavali
5c7fb0fabd
stream: stream_stop -> stream_free
2026-02-09 09:57:04 +00:00
Aryadev Chavali
f164427b47
stream: stream_reset
...
We can reuse the same stream by resetting it. We don't delete the
cached data.
2026-02-09 09:57:04 +00:00
Aryadev Chavali
2238f348e1
stream: stream_line_col includes current position in computation
2026-02-09 09:57:04 +00:00
Aryadev Chavali
f56a59ff7a
stream: STREAM_TYPE_FILE will now read file upfront
...
No more having to chunk read - if ~stream_init_file~ is used, the
constructor slurps the entire file into the cache. This pays up front
for a bunch of checks essentially.
~stream_init_pipe~ should be used for chunked reading.
2026-02-09 09:57:04 +00:00
Aryadev Chavali
6a54c54bfb
stream: a bit of tidying up
2026-02-09 09:57:04 +00:00
Aryadev Chavali
2855536bdd
stream: a few further refactors due to new sv functions
2026-02-09 09:57:04 +00:00
Aryadev Chavali
8426f04734
sv: refactor to use sv_truncate
2026-02-09 09:57:04 +00:00
Aryadev Chavali
459f434e5d
stream: bug fix on stream_while/stream_till (due to eda2711)
...
The new versions of stream_substr require exact sizes.
2026-02-09 09:57:04 +00:00
Aryadev Chavali
9ee8955908
stream: Refactor stream_substr and stream_substr_abs using stream_sv
...
Bit more elegant, and allows the caller code to focus on the task
rather than string management.
2026-02-09 09:57:04 +00:00