tweaks for self-compilation
Self-compilation: don't use TOK_FAIL macro
rewrite tree.c so it selfcompiles