Re:Lisp implemented in under 1K of JavaScript
by infogulch on Wednesday February 25, 2015 @06:20PM
(#9110445)
So 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.
[ Parent
| on HN ]
Re:Lisp implemented in under 1K of JavaScript
by zardeh on Wednesday February 25, 2015 @06:44PM
(#9110535)
So, 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
Re:Lisp implemented in under 1K of JavaScript
by infogulch on Wednesday February 25, 2015 @07:12PM
(#9110634)
Yes, 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?
Re:Lisp implemented in under 1K of JavaScript
by agumonkey on Wednesday February 25, 2015 @07:52PM
(#9110758)
And dotted pairs ? I had a super cute sexp parser in PHP, until I started handling sexp fully.
Re:Lisp implemented in under 1K of JavaScript
by gps408 on Thursday February 26, 2015 @04:54AM
(#9111816)
Would dotted pair notation make sense for this lisp where lists are arrays, not linked cons cells?
Re:Lisp implemented in under 1K of JavaScript
by agumonkey on Thursday February 26, 2015 @08:42AM
(#9112404)
IMHO, yes, binary building blocks matter a lot in lisp philosophy, whether or not they're built on javascript arrays.