See also, "preliminary step a of part 2 of my senior compiler project."
Aren't compilers classes common in undergraduate CS programs? Don't they all do this?
E: In case you were curious, "part 2" of the project was implementing a LL(1) recursive descent parser, so you had to juggle the grammar to work with that kind of parser.