From: Doug McIlroy <doug@cs.dartmouth.edu>
To: tuhs@tuhs.org
Subject: Re: [TUHS] v7 K&R C [really lexers]
Date: Sun, 14 Jun 2020 09:55:05 -0400 [thread overview]
Message-ID: <202006141355.05EDt5YM067818@tahoe.cs.Dartmouth.EDU> (raw)
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.
next reply other threads:[~2020-06-14 13:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-14 13:55 Doug McIlroy [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-05-17 2:07 Nelson H. F. Beebe
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
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=202006141355.05EDt5YM067818@tahoe.cs.Dartmouth.EDU \
--to=doug@cs.dartmouth.edu \
--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).