The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* Re: [TUHS] v7 K&R C [really lexers]
@ 2020-05-17  2:07 Nelson H. F. Beebe
  0 siblings, 0 replies; 16+ messages in thread
From: Nelson H. F. Beebe @ 2020-05-17  2:07 UTC (permalink / raw)
  To: tuhs

Brantley Coile <brantley@coraid.com> wrote on Sun, 17 May 2020 01:36:16 +0000:

>> It looks like only grap and pic have mkfiles that invoke lex.

Both of those are Brian Kernighan's work, and from the FIXES file
in his nawk, I can offer this quote:

>> ...
>> Aug 9, 1997:
>> 	somewhat regretfully, replaced the ancient lex-based lexical
>> 	analyzer with one written in C.  it's longer, generates less code,
>> 	and more portable; the old one depended too much on mysterious
>> 	properties of lex that were not preserved in other environments.
>> 	in theory these recognize the same language.
>> ...

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- University of Utah                    FAX: +1 801 581 4148                  -
- Department of Mathematics, 110 LCB    Internet e-mail: beebe@math.utah.edu  -
- 155 S 1400 E RM 233                       beebe@acm.org  beebe@computer.org -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [TUHS] v7 K&R C [really lexers]
@ 2020-06-14 13:55 Doug McIlroy
  0 siblings, 0 replies; 16+ messages in thread
From: Doug McIlroy @ 2020-06-14 13:55 UTC (permalink / raw)
  To: tuhs

Interesting. My "speak" program had a trivial lexer that
recognized literal tokens, many of which were prefixes
of others, by maximum-munch binary search in a list of
1600 entries. Entries gave token+translation+rewrite.
The whole thing fit in 15K.

Many years later I wrote a regex recognizer that special-cased
alternations of lots of literals. I believe Gnu's regex.c does
that, too. (My regex also supported conjunction and negation--
legitimate regular-language operations--implemented by
continuation-passing to avoid huge finite-state machines.)

We have here a case of imperfect communication in 1127. Had I
been conscious of the lex-explosion problem, I might have
thought of speak and put support for speak-like tables
into lex. As it happened, I only used yacc/lex once, quite
successfully, for a small domain-specific language. 

Doug

Steve Johnson wrote:

I also gave up on lex for parsing fairly early.   The problem was
reserved words.  These looked like identifiers, but the state machine to
pick out a couple of dozen reserved words out of all identifiers was too
big for the PDP-11.   When I wrote spell, I ran into the same problem.
I had some rules that wanted to convert plurals to singular forms that
would be found in the dictionary.   Writing a rule to recognize .*ies
and convert the "ies" to "y" blew out the memory after only a handful of
patterns.   My solution was to pick up words and reverse them before
passing them through lex, so I looked for the pattern "sei.*", converted
it to "y" and then reversed the word again.  As it turned out, I only
owned spell for a few weeks because Doug and others grabbed it and ran
with it.

^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: [TUHS] v7 K&R C
@ 2020-05-11  0:32 Rob Pike
  2020-05-11  0:57 ` Larry McVoy
  0 siblings, 1 reply; 16+ messages in thread
From: Rob Pike @ 2020-05-11  0:32 UTC (permalink / raw)
  To: Steve Johnson; +Cc: The Eunuchs Hysterical Society, ak

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

Interesting that Go had only what you call "typed typdefs" until we needed
to add "untyped typedefs" so we could provide aliasing for forwarding
declarations. And that necessity made me unhappy. But the short version: Go
went the other way with what "typedef" means.

-rob


On Mon, May 11, 2020 at 10:28 AM <scj@yaccman.com> wrote:

> Following up on Rob's comment, I always took the point of view that Dennis
> owned the C description, and what he said goes.  Not that I didn't make
> suggestions that he accepted.  One of the better ones (actually in B) was ^
> for exclusive OR.  One of the worse ones was the syntax for casts.  We
> looked at about 5 different ideas and hated all of them.   And most of them
> couldn't be easily compiled with Yacc.  So I took the grammar for
> declarations, removed the variable name, and voila, it expressed everything
> we wanted in the way of semantics, had a simple rule of construction, and
> we badly needed the functionality for the Interdata port.   I quickly came
> to hate it, though -- the casts we were using looked like a teletype threw
> up in the middle of the code.
>
> With respect to enums, there is a feature I've wanted for years: a typed
> typedef.  Saying typetdef int foo would make foo an integer, but if you
> passed an ordinary int to something declared as foo it would be an error.
> Even if it was an integer constant unless cast.
>
> The amount of mechanism required to get that behavior from both C and C++
> is horrible, so far as I know, although C++ has accreted so much stuff
> maybe it's there now...
>
> Steve
> ---
>
>
>
> On 2020-04-24 19:54, Rob Pike wrote:
>
> Another debate at the time was caused by a disagreement between pcc and cc
> regarding enums: are they a type or just a way to declare constant? I
> remember getting annoyed by pcc not letting me declare a constant with an
> enum and use it as an int. I protested to scj and dmr and after some to-ing
> and fro-ing Steve changed pcc to treat them as constants.
>
> Not sure it was the right decision, but C desperately wanted a non-macro
> way to define a constant. I'd probably argue the same way today. The real
> lesson is how propinquity affects progress.
>
> -rbo
>
>
> On Sat, Apr 25, 2020 at 12:51 PM Rob Pike <robpike@gmail.com> wrote:
>
> The ability to call a function pointer fp with the syntax fp() rather than
> (*fp)() came rather late, I think at Bjarne's suggestion or example. Pretty
> sure it was not in v7 C, as you observe.
>
> Convenient though the shorthand may be, it always bothered me as
> inconsistent and misleading. (I am pretty sure I used it sometimes
> regardless.)
>
> -rob
>
>
> On Sat, Apr 25, 2020 at 12:48 PM Adam Thornton <athornton@gmail.com>
> wrote:
>
>
>
> On Apr 24, 2020, at 7:37 PM, Charles Anthony <charles.unix.pro@gmail.com>
> wrote:
>
>
>
> On Fri, Apr 24, 2020 at 7:00 PM Adam Thornton <athornton@gmail.com> wrote:
>
> This doesn't like the function pointer.
>
>
> $ cc -c choparg.c
> choparg.c:11: Call of non-function
>
>
> Perhaps:
>
>     (*fcn)(arg);
>
>
> We have a winner!
>
> Also, Kartik, dunno where it is on the net, but if you install a v7
> system, /usr/src/cmd/c
>
> Adam
>
>

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

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

end of thread, other threads:[~2020-06-15  6:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17  2:07 [TUHS] v7 K&R C [really lexers] Nelson H. F. Beebe
  -- strict thread matches above, loose matches on Subject: below --
2020-06-14 13:55 Doug McIlroy
2020-05-11  0:32 [TUHS] v7 K&R C Rob Pike
2020-05-11  0:57 ` Larry McVoy
2020-05-11 17:32   ` Greg A. Woods
2020-05-11 18:25     ` Paul Winalski
2020-05-11 18:37       ` Clem Cole
2020-05-11 19:12         ` Paul Winalski
2020-05-11 19:57           ` joe mcguckin
2020-05-11 20:25             ` Larry McVoy
2020-05-12 17:23               ` Paul Winalski
2020-05-13 23:36                 ` Dave Horsfall
2020-05-14 17:32                   ` Larry McVoy
2020-05-14 22:32                     ` Tony Finch
2020-05-16 23:53                       ` Steffen Nurpmeso
2020-05-16 23:59                         ` [TUHS] v7 K&R C [really lexers] Jon Steinhart
2020-05-17  0:04                           ` Brantley Coile
2020-05-17  1:23                             ` Warner Losh
2020-05-17  1:36                               ` Brantley Coile
2020-06-13 21:24                               ` scj
2020-06-14  8:47                                 ` arnold
2020-06-14 12:52                                 ` Richard Salz
2020-06-14 14:03                                   ` Ralph Corderoy
2020-06-14 14:26                                     ` arnold
2020-06-14 14:48                                       ` Ralph Corderoy
2020-06-15  1:12                                         ` Warren Toomey
2020-06-15  1:29                                           ` Warren Toomey
2020-06-15  6:06                                             ` arnold
2020-05-17 16:31                           ` Paul Winalski

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