parser: move specification independent code to a template module

Signed-off-by: Peter Williams <pwil3058@gmail.com>