The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Paul Winalski <paul.winalski@gmail.com>
To: Ron Young <rly1@embarqmail.com>
Cc: tuhs@tuhs.org
Subject: Re: [TUHS] > there is no way that FORTRAN can be described in any syntax
Date: Mon, 3 Dec 2018 15:10:32 -0500	[thread overview]
Message-ID: <CABH=_VSWf+2Z2O0yNOu=EBi3jYOXDk-bdEwzYSD+KSMcu9pfJg@mail.gmail.com> (raw)
In-Reply-To: <7E.F0.08702.4CFB40C5@smtp04.onyx.dfw.sync.lan>

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.

  reply	other threads:[~2018-12-03 20:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03  3:36 Doug McIlroy
2018-12-03  5:31 ` Ron Young
2018-12-03 20:10   ` Paul Winalski [this message]
2018-12-03 20:55     ` Ron Young

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABH=_VSWf+2Z2O0yNOu=EBi3jYOXDk-bdEwzYSD+KSMcu9pfJg@mail.gmail.com' \
    --to=paul.winalski@gmail.com \
    --cc=rly1@embarqmail.com \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).