Use a more generic serialization function to emit the parser rules

This allows the compiler to focus just on rule-set transformations.
Eliminate output of undefineds
Use Javascript "generated identifier" syntax for uniqids
Use output helpers to make the emitter robust to change