computability – Algorithmically find a formal grammar for a recursively enumerable formal language

The algorithmic problem is as follows.

The input is the source code of a program accepting an integer as input and outputting a finite binary sequence. This program defines a recursively enumerable formal language.

The output is a formal grammar generating this language.

How can we solve this problem?