Move much of the code that was inline in tree.hh into other modules

- The motivation here is to hide the parts that are really only useful
  for parser.  That was all moved to tree_cr.hh/.cc.

- In parser.yy itself, we now hide some of the stuff that relies on
  availability of the template definitions that used to be in tree.hh.
  This cleans up parser.hh a bit.
Constant domains know their own name
Support constant domain casting