camfort / fortran-src

Fortran parsing and static analysis infrastructure
https://hackage.haskell.org/package/fortran-src
Other
44 stars 20 forks source link

Failed to parse this statement: `write(6,'(10(e12.5,a))') ((array(i),' '), i=1,nb)` #281

Open uNouss opened 5 months ago

uNouss commented 5 months ago

I have provided this code as an example.

      program main
      implicit none

      integer i
      integer nb
      parameter(nb=3)
      real array(nb)

*     -- initialize 'array'
      do i=1, nb
        array(i) = sin(real(i))
      enddo

*     -- print 'array' with '--' as separator
      write(6,'(10(f7.5,a))') ((array(i),'--'), i=1,nb)

      end

It's a Fortran77 code that I have retrieved and am working on. I'd like to parse it with fortran-src and get the corresponding AST.

But I have an error on line $15$.

As far as I know, this statement is valid in fortran77 (see https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnc5/index.html ).

If so, is it possible to take this type of expression into account in the parser as part of read, write and print?

asciicast