<p>I've been wanting to play around with writing my own language for a while now (ostensibly for the learning experience) and as such need to be relatively grounded in the construction of Parsers, Interpreters, and Compilers. So:</p>

<ul>
<li><strong>Does anyone know of any good resources on constructing Parsers, Interpreters, and Compilers?</strong></li>
</ul>

<p>EDIT: I'm not looking for compiler-compilers/parser-compilers such as Lex, Yacc and Bison...</p>

[{'answer_id': 41790, 'author': 'Ralph M. Rickenbach', 'author_id': 4549416, 'author_profile': 'https://Stackoverflow.com/users/4549416', 'pm_score': 3, 'selected': False, 'text': '<p>Not very easy, but exhaustive: <a href="http://en.wikipedia.org/wiki/Dragon_Book" rel="noreferrer">the dragon book</a></p>\n'}, {'answer_id': 41791, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 3, 'selected': False, 'text': '<p><a href="https://rads.stackoverflow.com/amzn/click/com/0534939724" rel="noreferrer" rel="nofollow noreferrer">Compiler Construction: Principles and Practice</a> is a best book on the subject.</p>\n'}, {'answer_id': 41798, 'author': 'Chris Conway', 'author_id': 1412, 'author_profile': 'https://Stackoverflow.com/users/1412', 'pm_score': 3, 'selected': False, 'text': '<p>Aho\'s "Dragon book" is <em>the</em> standard reference, but another good choice is Andrew Appel\'s <a href="http://www.cs.princeton.edu/~appel/modern/java/" rel="noreferrer"><em>Modern Compiler Implementation in Java</em></a> (also available in <a href="http://www.cs.princeton.edu/~appel/modern/ml" rel="noreferrer">ML</a> and <a href="http://www.cs.princeton.edu/~appel/modern/c" rel="noreferrer">C</a> flavors). It walks you step-by-step through each of the necessary components of a compiler/interpreter and provides a lot of useful source code.</p>\n'}, {'answer_id': 41805, 'author': 'Chris Conway', 'author_id': 1412, 'author_profile': 'https://Stackoverflow.com/users/1412', 'pm_score': 1, 'selected': False, 'text': '<p>RE: lex, yacc, bison</p>\n\n<p>Do you mean you don\'t need pointers to them or that you aren\'t interested in using them? I don\'t recommend writing a lexer or parser by hand.</p>\n\n<p>EDIT: You may have an exaggerated sense of what a "compiler-compiler" can accomplish: the really hard part of compilation begins after you\'ve built the AST. The Aho, Louden, and Appel books are all quite good.</p>\n'}, {'answer_id': 41812, 'author': 'McKenzieG1', 'author_id': 3776, 'author_profile': 'https://Stackoverflow.com/users/3776', 'pm_score': 3, 'selected': False, 'text': '<p>This highly-entertaining blog post by Steve Yegge (<a href="http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html" rel="noreferrer">Rich Programmer Food</a>) won\'t tell you everything you need to know about <em>how</em> to build a compiler (although it does include a fair amount of good insight), but it does a great job of explaining <em>why</em> you want to understand compliers.</p>\n\n<p>Heck, that post almost got me to start studying compilers, and I have a full-time job, a 3-year-old at home, and about -1.5 free hours per day on average.</p>\n'}, {'answer_id': 41957, 'author': 'slm', 'author_id': 4262, 'author_profile': 'https://Stackoverflow.com/users/4262', 'pm_score': 2, 'selected': False, 'text': '<p>I recommend <a href="https://rads.stackoverflow.com/amzn/click/com/0133049574" rel="nofollow noreferrer" rel="nofollow noreferrer">Compiler Design in C</a> which you would have to find in a used book site unfortunately. The only real problem with the book is that it was written back when speed of compilation was an important factor so the compiler is written in C. That\'s enough of a low level language that sometimes the implementation theory is buried under the implementation code.</p>\n\n<p>You mentioned both Interpreters and Compilers. I\'d actually recommend starting with an Interpreter rather than a Compiler. It\'s much easier to get started with an Interpreter and they tend to be more fun to work on because you can get immediate feedback on how you\'re doing. </p>\n'}, {'answer_id': 41986, 'author': 'robaker', 'author_id': 190, 'author_profile': 'https://Stackoverflow.com/users/190', 'pm_score': 2, 'selected': False, 'text': '<p>I recently read <a href="http://www.amazon.co.uk/gp/product/0130257869?ie=UTF8&amp;tag=mywebsi-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=0130257869" rel="nofollow noreferrer">Programming Language Processors in Java</a> and would recommend it to you as it starts with basic concepts and then takes you through the implementation of a recursive-descent compiler including code generation with plenty of discussion of alternative approaches.  I\'ve not read the other suggested books in this thread though, so can\'t offer a comparison with those. Don\'t be put off by the In Java part, if you don\'t know java, as the concepts and their implementation are well enough explained that you get the gist without needing a detailed understanding of Java.</p>\n'}, {'answer_id': 42021, 'author': 'Martin Salias', 'author_id': 4020, 'author_profile': 'https://Stackoverflow.com/users/4020', 'pm_score': 2, 'selected': False, 'text': '<p>Just in case you:</p>\n\n<ul>\n<li>Are willing to play</li>\n<li>Like the chance to build something quicker, then go deeper</li>\n<li>Are ok with using .NET at an underlying platform</li>\n</ul>\n\n<p>...then I\'d recommend you to check Microsoft\'s Dynamic Language Runtime, which is provided as source code inside the whole Dynamic Silverlight SDK.</p>\n\n<p><a href="http://www.codeplex.com/sdlsdk" rel="nofollow noreferrer">http://www.codeplex.com/sdlsdk</a></p>\n\n<p>Some nice things about it is that it provides lots of ready-to-use features like a console, a common type system, a generic abstract syntax tree, etc. And the package includes three implementations: Python, Ruby and Javascript.</p>\n\n<p>Maybe it is a good chance to implement a short language other the DLR, then start checking the actual DLR code, and then start building the basic stuff on your own.</p>\n\n<p>In any case, best luck from another language freak!</p>\n'}, {'answer_id': 42036, 'author': 'Mark Krenitsky', 'author_id': 1121861, 'author_profile': 'https://Stackoverflow.com/users/1121861', 'pm_score': 2, 'selected': False, 'text': '<p>The MIT OpenCourseWare(OCW) site has a class whose project is to build a complier...they refer to the Dragon book and Appel\'s book, but in addition, there are also class notes and lectures available. The class is <a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-035Fall-2005/CourseHome/index.htm" rel="nofollow noreferrer">6.035 - Computer Language Engineering</a>. </p>\n\n<p>I found the class notes very useful for explaining recursive-descent parsers. </p>\n'}, {'answer_id': 102961, 'author': 'Eli Bendersky', 'author_id': 8206, 'author_profile': 'https://Stackoverflow.com/users/8206', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve found <a href="http://compilers.iecc.com/crenshaw/" rel="noreferrer">"Let\'s build a compiler"</a> - the tutorial by Jack Crenshaw, very easy to follow and understand. Jack builds a compiler for Pascal, from the ground up, with very detailed explanations of every step.</p>\n'}, {'answer_id': 103808, 'author': 'Bruce Alderman', 'author_id': 311, 'author_profile': 'https://Stackoverflow.com/users/311', 'pm_score': 0, 'selected': False, 'text': "<p>It's an old book, and rather dated, but I've found <em>Brinch Hansen on Pascal Compilers</em> to be a very practical introduction to creating a language and building the elements of a compiler. Despite the name, it's not specific to Pascal. It's very worthwhile if you can find a copy.</p>\n"}, {'answer_id': 1005680, 'author': 'Ira Baxter', 'author_id': 120163, 'author_profile': 'https://Stackoverflow.com/users/120163', 'pm_score': 4, 'selected': False, 'text': '<p>The best paper I ever read on compilers is dated <strong>1964</strong>\n"META II a syntax-oriented compiler writing language" by Val Schorre.\n(<a href="http://doi.acm.org/10.1145/800257.808896" rel="noreferrer">http://doi.acm.org/10.1145/800257.808896</a>)</p>\n\n<p>In 10 pages, he shows you how to build an astoundingly simple but\nvery effective compiler-compiler, provides\nyou with with the compiler-compiler grammar and provides you with enough\ndetails for you to hand implement it in an afternoon (with one <em>astonishing</em>\nconceptual moment when you realize how it recurses), and just for grins implements an\nALGOL-like language.  The paper is a complete gas and really should\nbe required reading for anybody working with compiler technology.</p>\n\n<p>Here\'s a link to play with an great tutorial on metacompiling,\nbased on the paper. \n<a href="http://www.bayfronttechnologies.com/mc_tutorial.html" rel="noreferrer">http://www.bayfronttechnologies.com/mc_tutorial.html</a></p>\n'}]
['https://Stackoverflow.com/questions/41785', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/145/']