|
|
|
|
|
by uncircle
361 days ago
|
|
The code in the screenshot/asciinema isn't s-expr by any common conception of the term, or as a Lisp would parse it. (flatten '( '(a '( b)) '( c d)))
That argument to flatten is in fact [macroexpanding manually, forgive errors] '((quote (a (quote (b)))) (quote c d))
which flattens to '(quote a quote b quote c d)
---Parsing sexprs is quite easy, no need to use a complex parser generator. The core of parsing sexprs is you have a "read_list" function, which accumulates values until it finds a ')', and whenever you encounter a '(' character, you recurse into that same read_list function. You don't even need a lexer. Also, this is divided in 8 crates for some reason... don't take this the wrong way, but is it the result of vibe coding? |
|