Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting series. Here's a different approach to code parsing which some people may find easier using Top Down Order Precedence:

http://javascript.crockford.com/tdop/tdop.html

The example explained on that page by Douglas Crockford (Yahoo's Javascript guru) is a TDOP parser written in Javascript thats parses Javascript (it's a concept demo, not a practical use case) What's nice about his example is he covers lots of different features like scope, functions, and objects, which are sometimes glossed over in other texts about how compilers work. This is not a complete compiler because it only produces a syntax tree, but going from syntax tree to interpreter/compiler is the easier part.



In my experience going from syntax tree to interpreter/compiler is definitely the harder part. Parsing is a relatively straightforward task.


That is my experience as well, but keep in mind that the design of the source language affects this. For instance, writing a parser for C++ would be a nightmare full of bookkeeping, but a basic translation to machine code would be relatively straight forward.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: