implement compile_term()