The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] Recreation of the PDP-7 UNIX TMG compiler compiler
@ 2021-10-13 20:53 Phil Budne
  2021-10-14 15:38 ` Lars Brinkhoff
  2021-10-14 22:42 ` Robert Swierczek
  0 siblings, 2 replies; 8+ messages in thread
From: Phil Budne @ 2021-10-13 20:53 UTC (permalink / raw)
  To: tuhs

I was a member of the team that typed in scans of PDP-7 UNIX (the
first batch of scans done didn't include the shell, so I cobbled one
together in March of 2016).

Scans of a second batch of listings turned up and were entered two
years ago (October 2019), including the original shell, and appeared
to be part of Doug McIlroy's implementation of TMG (TransMoGrifier),
the compiler compiler first used to implement B.

In January 2020 we got confirmation that the files t1.s thru t8.s
were, in fact, for TMG, but that we were missing the compiler for the
TMGL language, written in TMGL and the generated code.

In what is perhaps best described as a crazed act, over the past two
months I've worked to recreate a working TMG environment on PDP-7
UNIX, including a B compiler in TMGL, currently available at:

https://github.com/philbudne/pdp7-unix/tree/tmg

A good starting place is
https://github.com/philbudne/pdp7-unix/blob/tmg/misc/tmg-notes.txt
which started as my collected notes, questions and findings, and I've
expanded it with prose, observations and thoughts that could, at least
conceivably, be of interest to those not as oriented towards
self-punishment as I am.

(and on that topic, if you're looking for someone to expand, contract,
or otherwise deal with some seemingly intractable legacy code, let me
know: http://www.regressive.org/phil/resume.html)

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [TUHS] Recreation of the PDP-7 UNIX TMG compiler compiler
@ 2021-11-20 15:02 Douglas McIlroy
  0 siblings, 0 replies; 8+ messages in thread
From: Douglas McIlroy @ 2021-11-20 15:02 UTC (permalink / raw)
  To: TUHS main list

> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-20 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 20:53 [TUHS] Recreation of the PDP-7 UNIX TMG compiler compiler 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
2021-11-20 15:02 Douglas McIlroy

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).