[TUHS] v7 K&R C [really lexers]
Brantley Coile
brantley at coraid.com
Sun May 17 11:36:16 AEST 2020
It looks like only grap and pic have mkfiles that invoke lex.
> On May 16, 2020, at 9:23 PM, Warner Losh <imp at bsdimp.com> wrote:
>
>
>
> On Sat, May 16, 2020, 6:05 PM Brantley Coile <brantley at coraid.com> wrote:
> “The asteroid to kill this dinosaur is still in orbit.“
> —- Plan 9 lex man page
>
> I always hand craft my lexers and use yacc to parse. Most code on plan 9 does that as well.
>
> Wow! That is the most awesome thing I've seen in a while....
>
> Warner
>
>
> Brantley
>
>
>> On May 16, 2020, at 8:00 PM, Jon Steinhart <jon at fourwinds.com> wrote:
>>
>> Steffen Nurpmeso writes:
>>> Tony Finch wrote in
>>> <alpine.DEB.2.20.2005142316170.3374 at grey.csi.cam.ac.uk>:
>>> |Larry McVoy <lm at mcvoy.com> wrote:
>>> |>
>>> |> It's got some perl goodness, regexps are part of the syntax, ....
>>> |
>>> |I got into Unix after perl and I've used it a lot. Back in the 1990s I saw
>>> |Henry Spencer's joke that perl was the Swiss Army Chainsaw of Unix, as a
>>> |riff on lex being its Swiss Army Knife. I came to appreciate lex
>>> |regrettably late: lex makes it remarkably easy to chew through a huge pile
>>> |of text and feed the pieces to some library code written in C. I've been
>>> |using re2c recently (http://re2c.org/), which is differently weird than
>>> |lex, though it still uses YY in all its variable names. It's remarkable
>>> |how much newer lexer/parser generators can't escape from the user
>>> |interface of lex/yacc. Another YY example: http://www.hwaci.com/sw/lemon/
>>>
>>> P.S.: i really hate automated lexers. I never ever got used to
>>> use them. For learning i once tried to use flex/bison, but
>>> i failed really hard. I like that blood, sweat and tears thing,
>>> and using a lexer seems so shattered, all the pieces. And i find
>>> them really hard to read.
>>>
>>> If you can deal with them they are surely a relief, especially in
>>> rapidly moving syntax situations. But if i look at settled source
>>> code which uses it, for example usr.sbin/ospfd/parse.y, or
>>> usr.sbin/smtpd/parse.y, both of OpenBSD, then i feel lost and am
>>> happy that i do not need to maintain that code.
>>>
>>> --steffen
>>
>> Wow, I've had the opposite experience. I find lex/yacc/flex/bison really
>> easy to use. The issue, which I believe was covered in the early docs,
>> is that some languages are not designed with regularity in mind which makes
>> for ugly code. But to be fair, that code is at least as ugly with hand-crafted
>> code.
>>
>> I believe that the original wisecrack was directed towards FORTRAN. My ancient
>> experience was that it was using lex/yacc for HSPICE was not going to work so I
>> had to hand-craft code for that.
>>
>> Jon
More information about the TUHS
mailing list