For Java, you can use JavaCC for the parser / lexer. I have used this in numerous projects. It is pretty easy to use. One example, I think, involves arithmetic parsing. JavaCC will build a syntax tree that you could go through.
An attempt at arithmetic using JavaCC will provide a good introduction to the context free grammar and the concept of an abstract syntax tree. If you're a student, then this is a good step to try, as @emboss suggested
momo
source share