The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] v7 K&R C
@ 2020-04-25  1:59 Adam Thornton
  2020-04-25  2:37 ` Charles Anthony
  0 siblings, 1 reply; 65+ messages in thread
From: Adam Thornton @ 2020-04-25  1:59 UTC (permalink / raw)
  To: The Eunuchs Hysterical Society

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

The C in v7 is, canonically, the language described in K&R, right?

I must be doing something dumb.

I am getting Webb Miller’s “s” editor built there, and I am down to one function.

/* chop_arg - chop a function's argument to a maximum length */
static chop_arg(fcn, arg, maxlen)
int (*fcn)();
int maxlen;
char *arg;
{
    char save;

    save = arg[maxlen];
    arg[maxlen] = '\0';
    fcn(arg);
    arg[maxlen] = save;
}

This doesn’t like the function pointer.

$ cc -c choparg.c
choparg.c:11: Call of non-function

So, uh, what is the obvious thing I am missing?  How am I supposed to be passing function pointers in the C compiler that comes with v7?

Adam

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

^ permalink raw reply	[flat|nested] 65+ messages in thread
* Re: [TUHS] v7 K&R C [really lexers]
@ 2020-05-17  2:07 Nelson H. F. Beebe
  0 siblings, 0 replies; 65+ 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] 65+ messages in thread
* Re: [TUHS] v7 K&R C [really lexers]
@ 2020-06-14 13:55 Doug McIlroy
  0 siblings, 0 replies; 65+ 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] 65+ messages in thread

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

Thread overview: 65+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-25  1:59 [TUHS] v7 K&R C Adam Thornton
2020-04-25  2:37 ` Charles Anthony
2020-04-25  2:47   ` Adam Thornton
2020-04-25  2:51     ` Rob Pike
2020-04-25  2:54       ` Rob Pike
2020-04-25  3:04         ` Larry McVoy
2020-04-25  3:30           ` Clem Cole
2020-04-25  3:43             ` Larry McVoy
2020-04-25  3:54               ` Jon Steinhart
2020-04-25 11:44                 ` Michael Kjörling
2020-04-25 13:17             ` Dan Cross
2020-05-11  0:28         ` scj
2020-05-11  0:32           ` 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-12 17:35                             ` ron
2020-05-12 17:42                               ` Larry McVoy
2020-05-12 18:36                               ` Paul Winalski
2020-05-13 23:36                             ` Dave Horsfall
2020-05-14  0:42                               ` John P. Linderman
2020-05-14  2:44                                 ` Rich Morin
2020-05-14  3:09                                   ` Charles Anthony
2020-05-14 12:27                                     ` ron
2020-05-14 12:27                                     ` ron
2020-05-14 12:27                                     ` ron
2020-05-14  7:38                                   ` Dave Horsfall
2020-05-14 12:25                                     ` ron
2020-05-14 17:13                                   ` Paul Winalski
2020-05-14 17:21                                 ` Larry McVoy
2020-05-17 16:34                                   ` Derek Fawcus
2020-05-14  4:21                               ` Greg A. Woods
2020-05-14  4:40                                 ` Warner Losh
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
2020-05-17  0:35                                     ` [TUHS] v7 K&R C Larry McVoy
2020-05-11 18:37                   ` Larry McVoy
2020-05-11  2:08           ` Lawrence Stewart
2020-05-11 11:36           ` Michael Kjörling
2020-04-25  3:37       ` Dave Horsfall
2020-04-27 13:19       ` Tony Finch
2020-04-25  2:50   ` Adam Thornton
2020-04-25  5:59     ` Lars Brinkhoff
2020-05-17  2:07 [TUHS] v7 K&R C [really lexers] Nelson H. F. Beebe
2020-06-14 13:55 Doug 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).