Fortran Standards checking tool

I have been thinking for some time that it would be great to have a Fortran parsing tool that does precise syntax checking against standards. There are a few tools like this, but I think we need an Open Source tool so that it can be used by everyone as the common standards-checking tool.

In order to parse Fortran in such detail, the same tool could be used to generate and check argument INTENTs, accurately rename variables, etc. It could also be used as a style formatter (indentation, etc.), and produce code descriptions for things like Doxygen.

Parsing Fortran can be difficult, but I came up with a plan that makes it fairly easy. I am using Perl with Yapp (yacc for Perl), but avoid the LALR limitations by only doing an incomplete parse. An array section and a substring are not distinguished by the yacc grammar. They are simply "colon delimited lists". Once the code is tokenized, the remaining higher-level analysis needed to parse Fortran is fairly simple.

Is anyone here interested in collaborating on such a tool (and good at Perl)? Maybe there is already something like this that is still in development?

[1146 byte] By [Joe_Krahna] at [2007-11-27 10:38:14]
# 1

Parsing Fortran is not particularly difficult. There are a few

constructs that cause problems, such as complex constants

in output lists. Aside from those, parsing Fortran is a breeze.

Most of the complexity is in lexing. Fortran, unlike most

programming languages, requires the lexer to perform

effectively unbounded lookahead. Yes, the standard

restricts the maximum size fo a statement to 33,792

characters, but for practical purposes, that is effective

infinity.

Bob Corbett

rpcorbetta at 2007-7-28 18:53:11 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

Fortran parsing is difficult mainly because you cannot use all of the well-established parsing tools that assume LALR and reserved words. Fortran has no reserved words, so not only do you need look-ahead, but the context also matters.

Instead of trying to make a complicated lexer that does nearly all of the work, my idea is to use a very simple lexer, and use yacc to parse into incomplete abstract tokens. The look-ahead work can then be done very quickly by looking ahead into symbolic tokens rather than looking ahead into raw characters.

Joe_Krahna at 2007-7-28 18:53:11 > top of Java-index,Development Tools,Solaris and Linux Development Tools...