I can recommend the book „Compilers: Principles, Techniques and Tools“ [often called „Dragon Book“]. It explains from the basics with all the theory how to write a Leser, parser and much more features. It is one of the few books I bought after university.<p><a href="https://en.m.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools" rel="nofollow">https://en.m.wikipedia.org/wiki/Compilers:_Principles,_Techn...</a>
Depends on what you want to learn. Structure and interpretation of computer programs is good for a high-level view of what a compiler does, but it compiles a lisp-like language, so it won’t learn you much about parsing or about generating good error messages when given syntactically or semantically incorrect programs (typically more work than parsing correct programs), and it compiles to some abstract ‘instruction set’, so it won’t be worthwhile if you want to know how to wring maximum performance out of any specific CPU.
This book is not completionist but instead it's to the point and avoids wasting your time: <a href="https://www.amazon.com/gp/aw/d/155558179X/" rel="nofollow">https://www.amazon.com/gp/aw/d/155558179X/</a><p>[Edit: it's <i>Building an Optimizing Compiler</i> by Bob Morgan.]<p>That's assuming you don't want to waste your time reading about parsing, type checking, or serializing an AST into some form of assembly, the parts of a compiler which just aren't that interesting.
Assuming you want to know this to make your own programming language...<p>Step one is to learn about BNF grammers.<p>When I was in school we used a book called Princples of Compiler Design. I felt this was an excellent bok at the time. It taught me a lot about how toprogram well.