macro-processor: allow for nested variables

  1. Related to https://forum.dynare.org/t/total-number-of-periods-given-by-variable/11200/3

We should allow

@#define J=10
@#define K=1:@{J}

but currently the lexer gives an error when encountering the @{J} in the second line.

  1. Related to this, according to the manual, we have at the command line -DMACRO_VARIABLE=MACRO_EXPRESSION But we do not really macro expressions as dynare macro.mod -D=[1,2] fails.

  2. I tried to get around this by using

n_countries=2;
fid=fopen('n_countries_def.txt','w+');
fprintf(fid,'@#for co in 1:%u\n',n_countries)
fclose(fid)

to write a text file creating the first statement and then using

@#include "n_countries_def.txt"
var C_@{co};
@#endfor

But this is also not allowed:

ERROR in macro-processor: n_countries_def.txt:1.15: @#for loop not matched by an @#endfor or file does not end with a new line (unexpected end of file)

because apparently the macro processor checks for completeness of the macro in each included file instead of the whole created file.