| Store | Cart

Fortran Parser Question

From: Tim Roberts <t...@probo.com>
Fri, 13 Apr 2001 22:58:01 -0700
"Hassan Aurag" <aurag at geocities.com> wrote:
>> I am trying to write a Fortran parser in python.>> What I need is really simple. Given a fortran file, get all variables>with their type and decompose arthmetic operations. Stuff like a = b+c>.... and check their types to see if those ops can be dangerous when>ported on various platforms.

Mark is correct; this is a huge problem.  You basically need a full-fledged
compiler.  For example, to do a complete job, you're going to have to parse
statement functions and expand them when encountered.  IMPLICIT statements
are another interesting twist.  Most of the simple parsers you can download
are for Pascal-type languages.  Fortran's "rules" are quite different.

Now that we've discouraged you, can you give me a concrete example of the
kind of situation you want to detect?

> So, I won't need a full fledged compiler, but really something simple. I>am new to regular exps and friends, so if anyone can help with something>simple I can start with, please drop me a note!

Fortran is likely to defy analysis with regular expressions.  You're going
to need a state-driven lexical analyzer.

Have you done a web search for Fortran parsers?
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.

Recent Messages in this Thread
Hassan Aurag Apr 13, 2001 08:28 pm
Mark Jackson Apr 13, 2001 08:40 pm
Clive Page Apr 17, 2001 09:37 am
Tim Roberts Apr 14, 2001 05:58 am
Hassan Aurag Apr 15, 2001 05:17 am
Tim Roberts Apr 16, 2001 04:05 am
Paul Hughett Apr 16, 2001 02:39 pm
Messages in this thread