Re: Hand written or tool generated lexical analyzers for FORTRAN

glen herrmannsfeldt <gah@ugcs.caltech.edu>
15 Sep 2005 01:53:01 -0400

          From comp.compilers

Related articles
Hand written or tool generated lexical analyzers for FORTRAN pankaj.jangid@gmail.com (Pankaj) (2005-09-14)
Re: Hand written or tool generated lexical analyzers for FORTRAN gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-09-15)
Re: Hand written or tool generated lexical analyzers for FORTRAN fjscipio@rochester.rr.com (Fred J. Scipione) (2005-09-17)
Re: Hand written or tool generated lexical analyzers for FORTRAN gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-09-18)
Re: Hand written or tool generated lexical analyzers for FORTRAN pankaj.jangid@gmail.com (Pankaj) (2005-09-27)
Re: C scanners, was Hand written or tool generated lexical analyzers f rsc@swtch.com (Russ Cox) (2005-09-30)
| List of all articles for this month |

From: glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers
Date: 15 Sep 2005 01:53:01 -0400
Organization: Compilers Central
References: 05-09-054
Keywords: Fortran, lex

Pankaj wrote:


(snip)


> But I still feel that a tool to generate a lexical analyzer for
> FORTRAN would be a good idea. It will enable us to maintain the code
> in the long run.


(snip)


> [I don't see the point. The only language with a lexical structure
> like Fortran is Fortran, so once you have a Fortran lexer, you're
> done. Having written a Fortran lexer, I can report that it's not
> particularly hard, but it's quite context sensitive, particularly
> if you want to handle old programs where blanks don't matter, so
> you need some way to feed back info from the parser. -John]


Well, it could at least be useful for new versions of Fortran.


As I understand it now, there are two forms of Fortran code, fixed
form and free form. In fixed form blanks are not significant,
which requires the special Fortran lexer. As long as fixed form
is allowed one will still have to write lexers for newer versions
of Fortran as they appear. In free format blanks are significant,
so more usual lexers might work fine.


I presume there is someone, somewhere, to make sure that changes
to Fortran don't cause ambiguity in fixed or free form parsing.


-- glen
[Since Fortran 90, the standard has permitted either the traditional
card format with blanks ignored, or a more conventional free format
with blanks between the tokens, but not a mixture of both in the same
program. The someone, somewhere are the members of the Fortran
standards committee which among many other things makes sure that
the standard is correct.


New versions of Fortran don't make the lexer any harder, since they
just add new keywords and new syntax that don't change the lexical
structure. Really, a Fortran-specific lexer generator would be
complete overkill. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.