Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Let's make a shit JavaScript interpreter Part one. (renesd.blogspot.com)
23 points by illumen on July 1, 2010 | hide | past | favorite | 4 comments



The Crockford article is great, since it is free, short, and well written javascript. Unlike the 1973 paper it gets the ideas from... which is behind a paywall, long, and uses a 1973 language called "(l,(i,(s,(p))))".

The article's goals are noble, but in this one spot, we seem to be flirting with flaunting one's ignorance and thinking it wit.

Anyhow, here's a slicker way of doing it. Grab an ANTLR grammar for ecmascript. A quick Google for "ANTLR ecmascript grammar" yields:

http://www.antlr.org/grammar/1153976512034/ecmascriptA3.g

In addition, there is a (somewhat buggy) Python target for ANTLR 3 which is probably good enough for a project like this.

http://www.antlr.org/wiki/display/ANTLR3/Antlr3PythonTarget

Voila, a way to generate a parser in Python.


"The article's goals are noble, but in this one spot, we seem to be flirting with flaunting one's ignorance and thinking it wit."

There are plenty of valid reasons to not be a member of the lisp cult.

"Anyhow, here's a slicker way of doing it."

Which entirely misses the point of the article, which is to DIY, not rely on some tool to generate it for him.


> "(l,(i,(s,(p))))"

And Lisp doesn't even use commas (very much).


  ((l i) (s p))
would have been better. Would have emphasized that functions are first-class citizens. (I know, this syntax works only in Scheme.)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: