🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #130

Re: Comment delimiters

#130
From: Anton Ertl
Date: Thu, 15 Oct 2026 06:17
66 lines
4546 bytes
EricP <ThatWouldBeTelling@thevillage.com> writes:
>Old FORTRAN is difficult to parse because
>a) it did not separate the language into lexical and syntax levels
>b) it was white space oblivious except in quoted strings
>c) there were no reserved words - keywords were statement
>    position and sometimes semantic context dependent.
>d) statements were based on punch cards BUT because
>    continuation cards used the absence of a C in column 6
>    to indicate the start of a new statement, parsers have to
>    always look ahead to see in the next card has a C and
>    then "unget" the card if not.

Given that the original FORTRAN worked on an IBM 704, I think that the
designers made it as easy (and with as little memory) to parse as they
could, given the state of the art at the time.  Concerning the points:

a) I guess that the division into lexical and syntax levels had not
   been developed at the time; and even later, e.g., Wirth does not
   make this distinction in his language definitions, using EBNF down
   to the lexical level (although he does define reserved words).

b) Without this distinction, if you ignore white space at all, you
   either ignore it everywhere, or give it a special role in your
   syntax.  Ignoring is probably simpler.

c) The programming language community took quite a while until it
   arrived at reserved words.  E.g., while Algol 60 was specified in
   BNF, being modern in that regard, it does not have reserved words,
   just symbols that are distinct from all identifiers; i.e., you
   could have an identifier like IF in Algol 60, distinct from the
   symbol 'IF', and it's up to the implementation how to distinguish
   them.  Anyway, without a) reserved words make no sense.

d) Does the original FORTRAN support continuation cards?

>The classic ambiguous parsing example being
>
>   DO I = 1,100
>   DOI = 1.100
>
>depends on the presence or absence of a "naked comma" later in the
>statement to decide whether there is a keyword DO and a variable I,
>or a variable DOI. A "naked comma" is a comma not enclosed inside
>a quoted character or string, or inside a possibly nested parenthesis.

My guess as to how this stuff was parsed:

Deal with the first columns as appropriate.  For the rest: Remove any
white space.  Use a backtracking parser that tries to match a rule at
a time; for the DO statement, simply compare the start with "DO".  If
a rule does not match, look at the next rule.

The result is messy, especially when you want to extend the language.

>People learned a lot of what not to do in language design
>from old FORTRAN.

And probably also what to do.  Backus was on the Algol-60 committee,
and the B in BNF stands for his name.  I would not be surprised if the
structure of the parser in the FORTRAN compiler gave him ideas for
BNF.

- anton
-- 
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID: <2026Oct15.081750@mips.complang.tuwien.ac.at>
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!.POSTED!not-for-mail
References: <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> <11aiqc0$3kr94$3@dont-email.me> <179190779286.25645.14465927900754526737@media.vsta.org> <179190779286.25645.14465927900754526737@media.vsta.org> <vandys@vsta.org> <jwvjynl2cg0.fsf-monnier+comp.arch@gnu.org> <808vclt9i2mso89n1itvnvos5j88g1mopl@4ax.com> <6acfc2b2.1547984@news.eternal-september.org> <HZQzS.6$TYg.3@fx21.iad>

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!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Comment delimiters
Date: Thu, 15 Oct 2026 06:17:50 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 66
Message-ID: <2026Oct15.081750@mips.complang.tuwien.ac.at>
References: <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me> <11aig3c$3hdcn$1@dont-email.me> <11aiqc0$3kr94$3@dont-email.me> <179190779286.25645.14465927900754526737@media.vsta.org> <179190779286.25645.14465927900754526737@media.vsta.org> <vandys@vsta.org> <jwvjynl2cg0.fsf-monnier+comp.arch@gnu.org> <808vclt9i2mso89n1itvnvos5j88g1mopl@4ax.com> <6acfc2b2.1547984@news.eternal-september.org> <HZQzS.6$TYg.3@fx21.iad>
Injection-Date: Thu, 15 Oct 2026 06:48:41 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2280118"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19olbMuHXHWrSKnRWc/yWOk"; posting-host="597db5ff5fb8d21fc1309deab4e71b28"
Cancel-Lock: sha1:CnHpWngrGfdRMbg09DYBhZPLzYA= sha256:GGpUAacOt01U3aD/GInpzs9sKLVJ3G7gTT0vxU4uLDI=
	sha1:SCjvZ6xkML7TYHpZh4B3E976yFA= sha256:ZjRMPhjiAaUH3plrtWAzbqABO1CsB1QZMa8V3RzlSzs=
X-newsreader: xrn 10.11