fortran-src icon indicating copy to clipboard operation
fortran-src copied to clipboard

Fortran 90 lexer is not failed if parameter does not have initializer

Open foxtran opened this issue 5 years ago • 4 comments

The following code should lead to an error of Fortran 90 lexer, but it does not:

      program main
      integer, parameter :: val
      end

foxtran avatar Jan 10 '20 11:01 foxtran

Why would that be an error?

madgen avatar Jan 10 '20 11:01 madgen

It seems to me that it is only one way to declare the value of parameter: initialize it in line, where parameter statement is set.

And also, gfortran produces the following error for this code:

test_2.F:2:31:

    2 |       integer, parameter :: val
      |                               1
Error: PARAMETER at (1) is missing an initializer

foxtran avatar Jan 10 '20 11:01 foxtran

Maybe not lexer, but something else should be failed. :-)

foxtran avatar Jan 10 '20 12:01 foxtran

Unlike gfortran, fortran-src is not a compiler, it's a frontend with emphasis on lexing, parsing, and syntactic manipulations.

It does know about name resolution as it has a dataflow analyses builtin, but it assumes that you start with a legal program. It would be very nice if we had a more suspicious name resolution procedure but at the moment we don't.

If you want to work on that, I'm sure @mrd can give you some pointers.

madgen avatar Jan 10 '20 12:01 madgen