O'KeefeHPS@sri-unix.UUCP (04/04/84)
From: O'Keefe HPS (on ERCC DEC-10)
Someone here today wanted to write a grammar rule which
could detect the end of a word. It isn't always possible
to check the next character, becuase the word might be
at the end of the string. What was needed was something
like
end_of_word --> ( end_of_string | [C], {not_in_word(C)} ).
It finally dawned on me that I could write
end_of_string(X, X).
This dodge may be useful to other hackers. REAL hackers
will doubtless prefer to write
end_of_word --> ( = | [C], {not_in_word(C)} ).
If one prefers not to eat the character following the word,
one can write
end_of_word --> = . % space needed for tokeniser!
end_of_word, [C] --> [C], {not_in_word(C)}.
Of course the clean way would have been to match the longest
possible string of letters, digits, and underscores, but we
were after a quick patch.
I'm not at all sure that I care for any of this...
Possibly we could start a Prolog Joke Book ?