TITLE: Are Major Languages' Parsers Implemented By Hand? AUTHOR: Eugene Wallingford DATE: January 10, 2023 2:20 PM DESC: ----- BODY: Someone on Mastodon posted a link to a 2021 survey of how the parsers for major languages are implemented. Are they written by hand, or automated by a parser generator? The answer was mixed: a few are generated by yacc-like tools (some of which were custom built), but many are written by hand, often for speed. My two favorite notes:
Julia's parser is handwritten but not in Julia. It's in Scheme!
Good for the Julia team. Scheme is a fine language in which to write -- and maintain -- a parser.
Not only [is Clang's parser] handwritten but the same file handles parsing C, Objective-C and C++.
I haven't clicked through to the source code for Clang yet but, wow, that must be some file. Finally, this closing comment in the paper hit close to the heart:
Although parser generators are still used in major language implementations, maybe it's time for universities to start teaching handwritten parsing?
I have persisted in having my compiler students write table-driven parsers by hand for over fifteen years. As I noted in this post at the beginning of the 2021 semester, my course is compilers for everyone in our major, or potentially so. Most of our students will not write another compiler in their careers, and traditional skills like implementing recursive descent and building a table-driven program are valuable to them more generally than knowing yacc or bison. Any of my compiler students who do eventually want to use a parser generator are well prepared to learn how, and they'll understand what's going on when they do, to boot. My course is so old school that it's back to the forefront. I just had to be patient. (I posted the seeds of this entry on Mastodon. Feel free to comment there!) -----