The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Douglas McIlroy <douglas.mcilroy@dartmouth.edu>
To: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] Recreation of the PDP-7 UNIX TMG compiler compiler
Date: Sat, 20 Nov 2021 10:02:56 -0500	[thread overview]
Message-ID: <CAKH6PiUnxgGAQHEY=LZKUcsGEi1Vyj9VFAvOjr2auoRiza1HHg@mail.gmail.com> (raw)

> I was deeply motivated by TMG.  The good news is that you could say what
> you wanted and it just did it.  The bad news was the error handling.
> Because it was recursive if you made a syntax error the program
> backtracked and tried again.  And again.  And again.  And eventually was
> back at the first character of the input with nowhere to go.  So it
> issued one of its two messages -- "Syntax Error".

This is somewhat of a caricature. If one's compilation strategy were
to build an abstract syntax tree of the whole source program before
emitting any object code, then things would go as Steve describes.
In reality, TMG wasn't used this way. For one thing, ASTs needed
too much memory.

In TMG one could emit code while parsing. Typically code
was generated on a statement-by-statement basis. This limited
the backtracking, so even a naive "syntax error" diagnostic could
be localized to the statement level. Long-distance connections, such
as the branch labels in a nest of if statements, could nevertheless
be realized recursively.

Thus, in actual use,  a TMG "grammar" was partly a parsing  program
and partly abstract specification.  The balance of viewpoints was
left to the discretion of  the grammar's author. Yacc swung the
pendulum  toward the abstract.

Doug

             reply	other threads:[~2021-11-20 15:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-20 15:02 Douglas McIlroy [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-13 20:53 Phil Budne
2021-10-14 15:38 ` Lars Brinkhoff
2021-10-14 16:53   ` Douglas McIlroy
2021-10-14 17:06     ` Will Senn
2021-11-18 19:01     ` scj
2021-10-14 22:42 ` Robert Swierczek
2021-10-15  1:21   ` Ken Thompson

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='CAKH6PiUnxgGAQHEY=LZKUcsGEi1Vyj9VFAvOjr2auoRiza1HHg@mail.gmail.com' \
    --to=douglas.mcilroy@dartmouth.edu \
    --cc=tuhs@minnie.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).