Skip to content

Comment on Ask HN: What does a developer need to know to build their own Lisp from scratch?parent

Comments

A lisp parser is trivial! Don't live with that ugly syntax to save a page of code. It'd be very demotivating.

It's trivial for you, but are you sure you've got the OPs best interest at heart? Remember, you're trying to help someone else here.

I think the magic is in getting the interpreter to work, and depending on the personality, that might be what's motivating.

It's really trivial for everyone. To start with you only need three classes of characters: parentheses, whitespace, and everything else defines a symbol.

I bought the dragon book long ago. I got about halfway through and it was still on parsing! What a waste. That's not a problem for s-expressions.

I bought the dragon book long ago.

That makes me think you might've forgotten what it's like to be a beginner. Imagine teaching a high school student and that every other word you're using doesn't make complete sense to them yet.

That makes me think you might've forgotten what it's like to be a beginner.

Let's put things in perspective: the parser bit of putting together your own lisp is by far the easiest task of all.

Complaining that parsing lisp is hard to a beginner but everything else is accessible makes no sense at all. I mean, a parser for s-expressions requires what? Five or six terminal tokens and three or four non-terminal tokens? That's less than 50loc.

Assuming the developer is competent in their language of choice should rule out anyone who can't write a Lisp parser in their language of choice.

If you're not undertaking this to learn how to write a Lisp, which includes writing a parser, what's the point? Get this tribe 3 shit out of here...

Assuming the developer is competent in their language of choice should rule out anyone who can't write a Lisp parser in their language of choice.

I didn’t write a s-expr parser for the minischeme interpreter I like to play around with but I did use re2c/lemon to generate a parser. Then I got Unicode working…

Couldn’t even imagine what it would take to hand write a lexer that does Unicode properly, even the scheme string and char functions call into generated functions (and a library for utf8 strings) since that stuff is complex.

Also don’t know what tribe 3 is, one of those things the cool kids talk about?

imagine thinking the difference between parsing a string and using a pre-parsed datastructure was "trivial for everyone" because you could count off how many classes of character were involved

one major difference is that you don't have to write the parser at all the other way

It's trivial for you, but are you sure you've got the OPs best interest at heart?

It's trivial to anyone.

Furthermore, there are already s-expression parsers out there.

Suggesting JSON is simply poor, ill-thought out advice.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.