From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master 8bee4060ea4 2/2: Add peg.el as a built-in library Date: Sat, 13 Apr 2024 11:04:29 +0300 Message-ID: <868r1hr8mq.fsf@gnu.org> References: <86plvac0u0.fsf@gnu.org> <8734s55f98.fsf@ericabrahamsen.net> <87le5v407q.fsf@ericabrahamsen.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36200"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca To: Eric Abrahamsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Apr 13 10:05:18 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rvYNx-0009B4-OS for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Apr 2024 10:05:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvYNG-00066T-IL; Sat, 13 Apr 2024 04:04:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvYND-00066K-NN for emacs-devel@gnu.org; Sat, 13 Apr 2024 04:04:31 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvYND-0007XK-Eb; Sat, 13 Apr 2024 04:04:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ydaid8HbrB3zu4o0NMjj/46bLbPLo367M7wXmIgXGGY=; b=sMhEXAgou0Sy 9sB9HXtQlPgcvRBXpzgQum8YXhKBIY2MzJEzbe6Fk7GNg40/S3ZQMEqQwrPNlfG4LFpPh2Rc7nNFW MsmLE9QbuBancHfxDFPheVh0c4EwU2I5BbItU8V6i/S9kspIGUALcvdl4gpO02mHVpH88tvnDtrUj U3OxKzrMWHUM1TgVdIPAYn/c8OL1cQ59FOgE0fTFNdUk/fDMgGHJo8+oRF91GWXSYxamnT+4PvARJ 8SvhbrJ5g4DXpQR4yvQKnUSsc5lqfu9FE9AO+GGBnZavYDHNksAnbYuCjTg+aJTeexUe69kbJNNAY t5Iy6kzNOp1/ZEKQolzgZA==; In-Reply-To: <87le5v407q.fsf@ericabrahamsen.net> (message from Eric Abrahamsen on Tue, 02 Apr 2024 20:03:05 -0700) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317701 Archived-At: Ping! Eric, any progress with this? > From: Eric Abrahamsen > Date: Tue, 02 Apr 2024 20:03:05 -0700 > Cc: Stefan Monnier > > Eric Abrahamsen writes: > > > Eli Zaretskii writes: > > > >>> branch: master > >>> commit 8bee4060ea42c61e52ebe6487ff97bc095261050 > >>> Author: Eric Abrahamsen > >>> Commit: Eric Abrahamsen > >>> > >>> Add peg.el as a built-in library > >>> > >>> * lisp/progmodes/peg.el: New file, taken from ELPA package. > >>> * test/lisp/peg-tests.el: Package tests. > >>> * doc/lispref/peg.texi: Documentation. > >> > >> Thanks. A few comments about this: > > > > Thanks for the all the notes. I should have this sorted out later today. > > Hi Stefan, I'm still working on integrating peg.el in to Emacs, and am > not having any luck getting peg-tests.el to compile. Actually, any use > of `peg-parse', compiled or interactive, seems to fail. Say you've got > this simple example from the manual: > > (peg-parse > (number sign digit (* digit)) > (sign (or "+" "-" "")) > (digit [0-9])) > > Inside `peg-parse', the only way this code is going to work correctly is > if it takes the `with-peg-rules' branch, because these pexs aren't > defined as rules yet. But the call to `peg-normalize' always succeeds, > so we always take the `peg-run' branch, and the code fails on undefined > rules. > > (defmacro peg-parse (&rest pexs) > (if (and (consp (car pexs)) > (symbolp (caar pexs)) > (not (ignore-errors (peg-normalize (car pexs))))) > ;; `pexs' is a list of rules: use the first rule as entry point. > `(with-peg-rules ,pexs (peg-run (peg ,(caar pexs)) #'peg-signal-failure)) > `(peg-run (peg ,@pexs) #'peg-signal-failure))) > > `peg-normalize' called on a cons applies `peg--macroexpand' to the list, > which calls its "head" implementation, and we end up with > > (call number sign digit (* digit)) > > `peg' sees that and assumes this has been defined as a rule. > > So `peg-normalize' should be failing on a list like this, but I don't > know how, exactly. > > I'm hoping you have some pointers! > > Thanks, > Eric > > >