Skip to content

Comment on Ask HN: What's the process of writing a new programming language?parent

Comments

Is there a typical preferred language to write lexers and parsers in? I imagine Python would be quite intuitive...

Lisps and MLs can be really good parsing languages. I needed to parse some stuff and took the "easy" way of just using clojure's instaparse library and wrote a grammar which the library turned into a parsing function. After that you write your transform functions to manipulate the resulting parse tree. My target text wasn't a programming language but it would have been a nightmare to do with regexes.

I had never tried to write a parser before and it took about a day to go from no idea what I was doing to "I can pretty much see where to go next were I to want to write a toy language". Something you might want to take a look at is http://norvig.com/lispy.html

AboutSource Built by g1lg1l

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