You are given a toy programming language with the following grammar: Primitives: char, int, float (lowercase strings) Generics: Uppercase letter + number, e.g. T1, T2, T3, ... Tuples: Comma-separated list of primitives, generics, or other tuples enclosed in brackets, e.g. [int, T1, char] or nested [int, char, [int, T1]] Functions:…