Syntax of interactive Fortran

It looks like we can pretty robustly parse statements and expressions at the global scope with the current parser. So indeed, we can then enable rejecting expressions in the AST->ASR transformation, so if you start LFortran with an option, it will only allow statements. And we can keep the current parser that we have.

I think we just need to play with this. I don’t know what I would like myself. The logical progression of making Fortran interactive thus is:

  1. Regular Fortran. Global scope allows program, modules, procedures, common block, data block

  2. In addition to 1), also allow statements at global scope. That means use statements, declarations and any statement that you can put in a procedure or main program body.

  3. In addition to 2), also allow expressions at global scope.

  4. In addition to 3), also allow some other simplifications, such as inferring variables from RHS, maybe not require call, etc.

Right now LFortran does 3), but we can easily revert to 2) or make it configurable.

Indeed, as @lmiq said, we need an option to export the notebook to a fully compatible regular Fortran source code. And that should allow us to experiment a bit with different approaches.

Let’s keep the options open. I am happy to prototype things and we can test them out and see what we would like.

2 Likes