4 ms·
Femtolisp has a nice, comprehensible Lisp reader written in C, with syntax very similar to Common Lisp: https://github.com/JeffBezanson/femtolisp/blob/master/r
by ct-1111 6y ago
Femtolisp has a nice, comprehensible Lisp reader written in C, with syntax very similar to Common Lisp:
https://github.com/JeffBezanson/femtolisp/blob/master/read.c https://github.com/JeffBezanson/femtolisp/blob/master/read.c
CMUCL has a fairly complex, but still comprehensible implementation of a Common Lisp reader:
https://gitlab.common-lisp.net/cmucl/cmucl/-/blob/master/src/code/reader.lisp https://gitlab.common-lisp.net/cmucl/cmucl/-/blob/master/src...
It uses a FSM to recognize numbers and symbols when tokenizing, and it demonstrates an implementation of Common Lisp readtables.
Here's how the Common Lisp Hyperspec specifies the Common Lisp reader (as an algorithm):
http://www.lispworks.com/documentation/HyperSpec/Body/02_b.htm http://www.lispworks.com/documentation/HyperSpec/Body/02_b.h...