adapt to incompatible changes in bison 3.0

PR #51 history became too tangled with duplicate commits and merges, so here is a clean rebase.