Use a more generic serialization function to emit the parser rules

This allows the compiler to focus just on rule-set transformations.