* [TUHS] > there is no way that FORTRAN can be described in any syntax
@ 2018-12-03 3:36 Doug McIlroy
2018-12-03 5:31 ` Ron Young
0 siblings, 1 reply; 4+ messages in thread
From: Doug McIlroy @ 2018-12-03 3:36 UTC (permalink / raw)
To: tuhs
I did just that. The National Bureau of Standards picked it up
in NBS Handbook 131, "Using ANS FORTRAN" (1980). It is expressed
in the same formalism that Burroughs used for Algol.
Doug
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [TUHS] > there is no way that FORTRAN can be described in any syntax
2018-12-03 3:36 [TUHS] > there is no way that FORTRAN can be described in any syntax Doug McIlroy
@ 2018-12-03 5:31 ` Ron Young
2018-12-03 20:10 ` Paul Winalski
0 siblings, 1 reply; 4+ messages in thread
From: Ron Young @ 2018-12-03 5:31 UTC (permalink / raw)
To: tuhs
Your message dated: Sun, 02 Dec 2018 22:36:59 -0500
--------
>
> I did just that. The National Bureau of Standards picked it up
> in NBS Handbook 131, "Using ANS FORTRAN" (1980). It is expressed
> in the same formalism that Burroughs used for Algol.
>
> Doug
a couple of more data points:
Arthur Sale wrote an article on classifying fortran statements,
Volume 14 Number 1 of the Computer Journal that describes how to
classify fortran statements into 1 of 36 types.
URL:https://www.researchgate.net/profile/Arthur_Sale/publication/220459829_The_classification_of_FORTRAN_statements/links/02e7e5181a234c6545000000/The-classification-of-FORTRAN-statements.pdf).
by using the above, you can do some preprocessing to correct spacing,
line continuations, remove sequence numbers (cols 73-80) and other
formatting to make parsing easier.
John Levine wrote a ftn77 subset parser using lex and yacc (the shar
file that I have is dated Nov 1988).
-ron
===============================================================================
Ron Young rly1@embarqmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [TUHS] > there is no way that FORTRAN can be described in any syntax
2018-12-03 5:31 ` Ron Young
@ 2018-12-03 20:10 ` Paul Winalski
2018-12-03 20:55 ` Ron Young
0 siblings, 1 reply; 4+ messages in thread
From: Paul Winalski @ 2018-12-03 20:10 UTC (permalink / raw)
To: Ron Young; +Cc: tuhs
On 12/3/18, Ron Young <rly1@embarqmail.com> wrote:
>
> John Levine wrote a ftn77 subset parser using lex and yacc (the shar
> file that I have is dated Nov 1988).
>
Just curious--what parts of Fortran 77 did he leave out?
Unfortunately the Fortran language was being developed at the same
time that Chomsky was first doing his research on formal grammars.
Languages such as Algol, C, PL/I, and Pascal were designed to be
easily split into a lexical regular grammar and a context-free grammar
(the lex/yacc paradigm). Fortran has some nasty grammatical quirks
that make it a bear to parse--context-sensitive lexical analysis, for
example. Given the string:
DO10I=1,10
you don't know whether to lex it as:
<identifier> DO10I
<operator> =
<integer constant> 1
or:
<keyword> DO
<integer constant> 10
<identifier> I
<operator> =
<integer constant> 1
until you see the comma.
Yes, full Fortran can be expressed in BNF and other formal syntax
mechanisms. But I don't think you can use lex and yacc to generate a
compiler for it.
-Paul W.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [TUHS] > there is no way that FORTRAN can be described in any syntax
2018-12-03 20:10 ` Paul Winalski
@ 2018-12-03 20:55 ` Ron Young
0 siblings, 0 replies; 4+ messages in thread
From: Ron Young @ 2018-12-03 20:55 UTC (permalink / raw)
To: Paul Winalski; +Cc: tuhs
Your message dated: Mon, 03 Dec 2018 15:10:32 -0500
--------
> On 12/3/18, Ron Young <rly1@embarqmail.com> wrote:
> >
> > John Levine wrote a ftn77 subset parser using lex and yacc (the shar
> > file that I have is dated Nov 1988).
> >
> Just curious--what parts of Fortran 77 did he leave out?
>
not sure... I'll check when I get home.
>
> Yes, full Fortran can be expressed in BNF and other formal syntax
> mechanisms. But I don't think you can use lex and yacc to generate a
> compiler for it.
>
agreed... but if you use Sale's classifier, you can insert
whitespace to convert the input to something that lex/yacc can
handle. Although in practice, using a hand-written lexer or
a state machine (like open-watcom IIRC) would probably be the
way to go.
-ron
> -Paul W.
===============================================================================
Ron Young rly1@embarqmail.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-03 20:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-03 3:36 [TUHS] > there is no way that FORTRAN can be described in any syntax Doug McIlroy
2018-12-03 5:31 ` Ron Young
2018-12-03 20:10 ` Paul Winalski
2018-12-03 20:55 ` Ron Young
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).