By reading any of the many books on the topic. Here are a few of them. Also see message 93-01-155 which reviews many compiler textbooks.
Describes clearly and completely lexing and parsing techniques including the ones in yacc and lex. The authors work or have worked at Bell Labs with Steve Johnson and Mike Lesk, the authors of Yacc and Lex.
A large book containing the complete source code to a reimplementation of yacc and lex and a C compiler. Quite well written, too, though it has a lot of errors. The fourth printing is supposed to correct most of them. An errata list is in message 90-06-081.
A concise introduction with completely worked out examples and an extensive reference section. The new edition is completely revised from the earlier 1990 edition. Source code can be FTP'ed from ftp.ora.com.
As with everything else from the FSF, full source code is included.
Oriented to tutorial work. Good for beginners. Develops a small subset-of-C compiler through the book. (Recommended by Eric Hughes <hughes@ocf.Berkeley.EDU>.) Richard Hash <rgh@shell.com> comments that the book has many typographical errors, and readers should be suspicious of the examples until they actually try them. Richard Y. Kim <richard@ear.mit.edu> reports that sources are available for FTP as a.cs.uiuc.edu:pub/friedman/tar.
It's intended for a first course in modern compiler techniques, is very clearly written, and has a full chapter on YACC. I found it to be a good introductory text before getting into the 'Dragon book'. (Recommended by John Merlin <J.H.Merlin@ecs.southampton.ac.uk>.) Source code is available at ftp.bath.ac.uk.
Erich Nahum <nahum@cs.umass.edu> writes: A key compiler reference. We used the original to great effect in Eliot Moss' graduate compiler construction class here at UMass. My feeling is that Fischer & LeBlanc is a good tutorial, and one should use Aho, Sethi, & Ullman as a reference.
Adrian Howard <adrianh@cogs.sussex.ac.uk> writes: This is the kindest, most readable introduction to compilers at the graduate level I have ever read - an excellent example of what textbooks should all be like.
Dick Grune <dick@cs.vu.nl> writes: A theoretical approach to compiler construction. Refreshing in that it gives a completely new view of many subjects. Heavy reading, high information density.
Dick Grune <dick@cs.vu.nl> writes: Extensive and detailed. Heavy reading. To be consulted when other sources fail.
William Jhun <ec_ind03@oswego.edu> writes: It explaines the C-language is thorough....and explains every single aspect of the compiler. The book compares source code to p-code to assembly. It goes over a nice set of optimization routines, explains the parser, the back end, and even includes source code, which the compiler on the disk can actually compile itself. It's an extremely interesting book, check it out.
Andrew Tucker <a_tucker@paul.spu.edu> writes: This 512-page book presents a strictly hands on approach, developing a Pascal interpreter and interactive debugger, then completing with a compiler which emits 8086 assembly. All source code is provided in print and on disk. This book is very low to non-existent in theoretical content, but is very practical and readable for an introduction. Taylor Hutt <thutt@access.digex.net> comments that the book is a piece of junk. The code that is contained in the book is full of bugs, and the code that it generates will not work.
Franklin L. Vermeulen <vfrank@vnet3.vub.ac.be> writes: This is a very nicely written and straightforward text on compiler construction. There is a certain (unavoidable?) amount of overlap with a course on automata (as in Aho, Sethi and Ullman). It is based on Modula-2 and on an experimental tool, the TAG compiler-compiler (Transformational Attribute Grammar) which seems to be a C-independent superset of lex/yacc, because its syntax allows you to specify all semantic actions without a single line of C-code (or any other implementation language, for that matter).
Gabriela O. de Vivo <gdevivo@dino.conicit.ve> writes: The book covers the general principles of compiler design and presents a good number of examples focusing on the building of pieceparts of compilers for C and Pascal. The implementation (construction) language is C. Note that this edition (in contrast with the previous one) is very related to the Unix world, including the use of tools like Lex, Yacc, and standard utilities.