Re: Fortran 77 parser



Tobias Burnus wrote:
On Apr 4, 2:46 pm, Jon Harrop <j...@xxxxxxxxxxxxxxxxx> wrote:
Steven G. Kargl wrote:
If all you really care about is Fortran 77, then grab f2c
from netlib. Otherwise, I think you severely under estimate
the difficult involved with one person writing a Fortran 77
compiler.

Actually I have now completed the compiler and it was fiddly but really
not that difficult (~1 week full-time work using OCaml). I processed the
code in several stages:

I think both statements are true. Writing a full parser of Fortran 77
which supports all syntax is extremely demanding.

Yes. Fortunately, the code I am translating is almost very cleanly
written. :-)

Writing a parser
which converts a "typical" Fortran code or even better a Fortran code
following a special style much less demanding.

Does it parse the following?

integerinteger,end

No. This could be fixed by lexing keywords directly rather than via
identifiers.

realprint

No. Same solution.

logicalif

No.

end=5

Yes.

if=.true.

Yes.

if(if)read(*,*)print,integer

Yes.

end

Yes.

Having said that, the generated code would be broken anyway. :-)

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
.



Relevant Pages

  • Re: Reading MS-FORTRAN unformatted binary files *efficiently*
    ... > Jeff Godfrey wrote: ... >>>consider writing a small FORTRAN program to read the files and write ... >>>long time since I used that particular FORTRAN compiler), ... The format rings all kinds of bells. ...
    (comp.lang.tcl)
  • Re: Bit Concatenation
    ... use a current compiler, it's generally a F95 compiler, But that really is ... I try to write "standard" Fortran. ... you mention below have nothing to do with F90 versus F77. ... Only about writing new interfaces for nearly two hundred modules. ...
    (comp.lang.fortran)
  • Re: what kind on programming is lisp?
    ... Having programmed for many years in Fortran, with a little C, ... The problem in Forth I gather are not so much related to writing a spot ... In Scheme it is often so much easier to change a pre-defined program ... My supervisor of my PhD assigned me a new Master student of him. ...
    (comp.lang.lisp)
  • Re: Fortran 77 parser
    ... the difficult involved with one person writing a Fortran 77 ... Actually I have now completed the compiler and it was fiddly but really not ... yielding a kind of AST for each line. ... If anyone is interested in a Fortran 77 to anything compiler then I could ...
    (comp.lang.fortran)
  • Re: why C?
    ... Because, with the exception of basic, none of those languages are suitable ... for writing an operating system. ... Fortran and Cobol were written to tackle ... C and its offshoots have become the standard for writing ...
    (comp.unix.misc)