New to functions, having difficulty with code

I want to run a script with a simple function. However, I keep getting this error:

Calling Dynare with arguments: none
Starting preprocessing of the model file …
ERROR: PS_4.mod: line 25, cols 1-0: syntax error, unexpected end of file

Is there any way to fix this code so that the function will work. I’ve spent hours and really need some help. Thank you very much.

G = 0.4;
alpha = 0.8;
beta = 0.9;
sigma = 0.7;

results = optimize(0.3);
disp(results);

function sol = optimize(T)
syms x y
eqns = [
x^sigma == ((1-T)*(1-alpha))/(y^alpha);
x + G == y^(1-alpha);
];
solRaw = vpasolve(eqns,[x, y]);
sol = [double(solRaw.x), double(solRaw.y)];
end;

What you posted is not Dynare code. If you want to include this in a Dynare file, you may have to put it into a verbatim-block. Also, you cannot nest functions within a mod-file.