From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2074 invoked from network); 17 May 2020 00:36:26 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 17 May 2020 00:36:25 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id E30539C994; Sun, 17 May 2020 10:36:24 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 2EE3C9C5E4; Sun, 17 May 2020 10:36:03 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id CCE3C9C5E4; Sun, 17 May 2020 10:36:00 +1000 (AEST) Received: from mcvoy.com (mcvoy.com [192.169.23.250]) by minnie.tuhs.org (Postfix) with ESMTPS id 6B0C09C5E1 for ; Sun, 17 May 2020 10:36:00 +1000 (AEST) Received: by mcvoy.com (Postfix, from userid 3546) id D9A8835E149; Sat, 16 May 2020 17:35:59 -0700 (PDT) Date: Sat, 16 May 2020 17:35:59 -0700 From: Larry McVoy To: Tony Finch , Larry McVoy , The Eunuchs Hysterical Society Message-ID: <20200517003559.GC19945@mcvoy.com> References: <357EFE54-BD94-4C10-8C43-C6735BF7D317@via.net> <20200511202555.GU17035@mcvoy.com> <20200514173206.GJ20771@mcvoy.com> <20200516235308.icuQH%steffen@sdaoden.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200516235308.icuQH%steffen@sdaoden.eu> User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [TUHS] v7 K&R C X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On Sun, May 17, 2020 at 01:53:08AM +0200, Steffen Nurpmeso wrote: > Tony Finch wrote in > : > |Larry McVoy 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. They are not bad if you are good at it. One of my guys has a PhD in compilers and he's good at it. They are not good at performance. BitKeeper has an extensive printf like (sort of, different syntax) language that can be used to customize log output. Rob originally did all that in flex/bison but the performance started to hurt so he rewrote it all: /* * This is a recursive-descent parser that implements the following * grammar for dspecs (where [[...]] indicates an optional clause * and {{...}} indicates 0 or more repetitions of): * * -> {{ }} * -> $if(){}[[$else{}]] * -> $unless(){}[[$else{}]] * -> $each(:ID:){} * -> ${=} * -> * -> {{ }} * -> * -> * -> () * -> ! * -> {{ }} * -> char * -> escaped_char * -> :ID: * -> (:ID:) * -> $ * -> " && " | " || " * -> "=" | "!=" | "=~" * -> " -eq " | " -ne " | " -gt " | " -ge " | " -lt " | " -le " * * This grammar is ambiguous due to (:ID:) loooking like a * parenthesized sub-expression. The code tries to parse (:ID:) first * as an $each variable, then as a regular :ID:, then as regular text. * * Note that this is broken: $if((:MERGE:)){:REV:} * * The following procedures can be thought of as implementing an * attribute grammar where the output parameters are synthesized * attributes which hold the expression values and the next token * of lookahead in some cases. It has been written for speed. * * NOTE: out==0 means evaluate but throw away. * * Written by Rob Netzer with some hacking * by wscott & lm. */ That stuff screams perf wise.