3 ms·
It's JSON lists as s-exps, which means (as I understand it) that the author doesn't need to implement parsing, only traversal and evaluation. (Which can essenti
by mattdw 12y ago
It's JSON lists as s-exps, which means (as I understand it) that the author doesn't need to implement parsing, only traversal and evaluation. (Which can essentially be a big-ass case statement.)
["def", "foo", 1]
["fn", "foo", ["a", "b"], […]]
It's not the most attractive Lisp I've seen…
- infogulch 12y agoSo write a lisp parser, then dump the result into this. I like that they didn't include a parser in compacted code, such a parser wouldn't be very interesting.
- zardeh 12y agoSo, uhmm, def parse(s): return json.loads('['+re.sub('([")])\s*(["(])','\g<1>,\g<2>',re.sub('[^()\s]+','"\g<0>"',s)).replace('(','[').replace(')',']')+']') works for python, I'm assuming javascript has something equally small
- infogulch 12y agoYes, uninteresting, as I said. Lisp syntax is quite simple, so I would not expect it to be very difficult to make a regex to parse it. Btw, does that handle quoted strings, strings with syntax characters in them, and strings with escapes?
- agumonkey 12y agoAnd dotted pairs ? I had a super cute sexp parser in PHP, until I started handling sexp fully.
- gps408 12y agoWould dotted pair notation make sense for this lisp where lists are arrays, not linked cons cells?
- agumonkey 12y agoIMHO, yes, binary building blocks matter a lot in lisp philosophy, whether or not they're built on javascript arrays.
- gps408 12y agoThanks for responding, man. That's my point though. There is no cons building block in this lisp. I don't think (1 2 . 3) can be represented in it so having the notation for it makes no sense.