@MichelJuillard, in testing the changes I made to separate the writing of M_ I ran into a problem. I spoke with @stepan-a about it and he told me to make a note about it here to see if you had an idea.
The changes are on the origin/separateM_ branch: 6d114289.
Here, we are trying to pick out the definition of the M_ structure, placing it in a separate file. The problem comes from native Matlab statements which are processed in a linear fashion. This is a problem because they can depend on what comes before them.
Take tests/expectations/expectation.mod for example. Here, phi = 0.1; is a native statement and is used in the shocks block, becoming an input to M_.Sigma_e. When we move the creation of M_ to a different file, phi is no longer accessible. However, if we write native statements to the separate file that creates M_, we could run into a problem if the user entered the following at the end of the .mod file:
save('myoo_.mat','oo_');
as processing will halt because oo_ is not known to that function. I thought about using a try/catch block in the file that creates the M_ structure, but here we would encounter a problem if there were a native statement between two .mod file blocks that modify the M_ structure.
Okay. I have the impression that we will have to abandon this...
The idea was to be able to do things with models without having to preprocess a mod file. This would make life much easier when we want to play with different models. Also I need this for the Julia version, where the preprocessor would write a module with definitions of M_, functions for the dynamic/static models and the steady state, I have posted an example here. I wonder if the best solution is not to extract what I need from the preprocessor's code...