Implement part of the translation from AST to terms.