Java compiler for a simple grammar