The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: "Steve Johnson" <scj@yaccman.com>
To: "Bakul Shah" <bakul@bitblocks.com>, "Steve Johnson" <scj@yaccman.com>
Cc: tuhs@tuhs.org
Subject: Re: [TUHS] Knuth and Unix
Date: Fri, 18 Jan 2019 13:57:04 -0800	[thread overview]
Message-ID: <30735aec554140bc4c98c14fe18be5b7ac1fff66@webmail.yaccman.com> (raw)
In-Reply-To: <20190116205043.21C22156E410@mail.bitblocks.com>

[-- Attachment #1: Type: text/plain, Size: 2834 bytes --]


The paper  was called "The Competence/Performance Dichotomy" by
Pratt.  He borrowed an idea from Chompsky and distinguished between
being able to understand something and being able to produce it.  The
idea I took from it was to recognize grammar rules even if the parse
was ambiguous and then use other mechanisms (e.g., Shift/Reduce,
precedence) to decide what to do.

About empty productions: one of the most useful versions of this was
in handling scopes in programming languages, especially in C where xyz
could be a variable in one scope and a typedef in an inner one, or
vice versa.  The empty production could get called at the right
moment to make the appropriate symbol table fixes, where otherwise we
would have had a syntax error. 

Steve

----- Original Message -----
From: "Bakul Shah" <bakul@bitblocks.com>
To:"Steve Johnson" <scj@yaccman.com>
Cc:<arnold@skeeve.com>, <ecashin@noserose.net>, <dave@horsfall.org>,
<tuhs@tuhs.org>
Sent:Wed, 16 Jan 2019 12:50:35 -0800
Subject:Re: [TUHS] Knuth and Unix

 On Tue, 15 Jan 2019 14:32:16 -0800 "Steve Johnson" <scj@yaccman.com>
wrote:
 > I remember reading Knuth's paper, and certainly heard
 > DeRemer's name, but it didn't affect much of what I did.
 > There was a paper out of Stanford about that time that
 > influenced me greatly -- it was about pattern matching
 > languages, and proposed separating two ideas: 1. "Here are
 > the patterns that match this tree". And 2. "If more than one
 > pattern matches, here's how to decide which one to use."
 > Given the constraints of size on the PDP 11, anything but
 > LR(1) was infeasable. But using ambiguous grammars and
 > broadening the shift/reduce test to trest operator precedence
 > fit right into that pattern. Another thing that I think was
 > unique to Yacc at the time was introducing symbols that
 > matched the empty string whose reduction caused program
 > actions. Many similar parser systems at the time could not
 > deal with these "empty" symbols.

 Good to know all this. The Stanford paper you refer, would
 that be "fast pattern matching" by Knuth, Morris & Pratt?

 I remember struggling with empty strings and I also missed
 other yacc tricks. In my formulation I had two kinds of
 rules: set rules and sequence rules. Set rules avoided
 unnecessary reductions in rules such as foo: bar|...

 For example:

 // sets
 expr = relexpr | expr1
 expr1 = addexpr | expr2
 expr2 = mulexpr | expr3
 ...

 // sequences
 relexpr: expr1 RELOP expr1
 addexpr: expr1 ('+'|'-') expr2
 mulexpr: expr2 ('*'|'/') expr3
 ...

 Basically I completely avoided empty symbols -- even an empty
 file has an EOF! [I didn't try it on anything more complicated
 than (extended) Pascal so no idea how it would have fared on
 complexificated lanuages]



[-- Attachment #2: Type: text/html, Size: 3730 bytes --]

  reply	other threads:[~2019-01-18 21:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10  0:19 Dave Horsfall
2019-01-10  0:54 ` Ed Cashin
2019-01-10  7:39   ` arnold
2019-01-13  3:41     ` Steve Johnson
2019-01-13  4:40       ` Bakul Shah
2019-01-15 22:32         ` Steve Johnson
2019-01-16  2:53           ` Rob Pike
2019-01-16 18:22             ` arnold
2019-01-16 20:10               ` Rob Pike
2019-01-17  6:58                 ` arnold
2019-01-18  0:55                 ` Steve Johnson
2019-01-16 20:50           ` Bakul Shah
2019-01-18 21:57             ` Steve Johnson [this message]
2019-01-10  3:14 ` Jim Capp
2019-01-16 15:57 Doug McIlroy

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=30735aec554140bc4c98c14fe18be5b7ac1fff66@webmail.yaccman.com \
    --to=scj@yaccman.com \
    --cc=bakul@bitblocks.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).