The calculator example reads an expression from standard input, builds a syntax tree and prints the tree. Finally it evaluates the tree and prints the result. Download here.
This example includes two predictive (recursive-descent) parsers: "calc.c" that evaluates expressions and "to-tree.c" that builds syntax trees. Download here.
Compiler book examples here
A list of other resources that you might find helpful.
C/C++ and UNIX:
Extensive C/C++ documentation can be found here. Further documentation and tutorials can be found through Google.
Quick guide to UNIX development tools (one of the many useful documents available in Nick Parlante's ever-growing CS library)
References on Lex & Yacc:
lex is the original lexical scanner developed by Lesk and Schmidt; Paxson's improved version is flex. Similarly, yacc is Johnson and Sethi's original parser; bison is the GNU-equivalent written by Corbett and Stallman. Both are designed to be upward-compatible with the original while adding extensions and improvements.
Original documentation by the authors of the tools themselves. These papers are quite readable and serve as an excellent introduction for familiarizing yourself with the tools.
GNU's online documentation (full manuals, long, but very complete)
The lex & yacc page from Combo.org.
An article from the Linux Journal singing the praises of lex & yacc.
Help with the gdb debugger:
GNU's online gdb users guide
References on MIPS & SPIM:
The SPIM home page (downloadable versions, more docs).
Just for fun:
A list of funny error messages from the old MPW C compiler.