Work on using bison to track state.

I had been doing state tracking manually.  This code
use bison to track state instead.