🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #172

Re: FORTRAN, was Comment delimiters

#172
From: MitchAlsup
Date: Sat, 17 Oct 2026 17:16
33 lines
2283 bytes
John Levine <johnl@taugh.com> posted:

> According to EricP  <ThatWouldBeTelling@thevillage.com>:
> >I am under the impression that many Fortran 77 compilers used
> >hand written lexer and a recursive decent parser.
> >The parser passes some local context to the lexer to let it know,
> >for example, which set of keywords are active at that point.
> >Anyway, that is how I would do it.
> 
> I wrote a production FORTRAN 77 compiler.  It had a hand written lexer
> and a yacc parser.
> 
> It made a prepass over each statement to combine continuation cards and to tell
> whether it's an assignment statement or statement function (they're
> syntactically the same) or something else. Once it knows that, the lexer is
> straightforward using feedback from the parser to know what tokens are allowed
> at each point.  As I recall there were about a dozen states, most of which were
> simple, e.g., after a DO keyword the next thing has to be a digit string
> which is a statement number.
> 
> The prepass was needed to disambiguate DO10I=1.10 and also to handle stuff like this:
> 
> 10    FORMAT(I10,A5)       // a format statement
> 
> 20    FORMAT(I10,A5) = 42  // an assignment statement

Which could be written::

20     FORMAT(I10,A5)
      -
c       comment getting in the way
      -
      - = 42
Technical Details
Message-ID: <1792257399-5857@newsgrouper.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
References: <1791742457-5857@newsgrouper.org> <HZQzS.6$TYg.3@fx21.iad> <2026Oct15.081750@mips.complang.tuwien.ac.at> <9ysAS.182538$QPx3.16043@fx17.iad> <11aur90$2b0g$1@gal.iecc.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!newsgrouper.org!.POSTED!not-for-mail
From: MitchAlsup <user5857@newsgrouper.org.invalid>
Newsgroups: comp.arch
Subject: Re: FORTRAN, was Comment delimiters
References: <1791742457-5857@newsgrouper.org> <HZQzS.6$TYg.3@fx21.iad> <2026Oct15.081750@mips.complang.tuwien.ac.at> <9ysAS.182538$QPx3.16043@fx17.iad> <11aur90$2b0g$1@gal.iecc.com>
Date: Sat, 17 Oct 2026 17:16:39 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-ID: <1792257399-5857@newsgrouper.org>
Injection-Info: newsgrouper.org; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user5857
Injection-Date: Sat, 17 Oct 2026 17:16:39 GMT
User-Agent: Newsgrouper/0.9.0