From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: master 8bee4060ea4 2/2: Add peg.el as a built-in library Date: Tue, 02 Apr 2024 20:03:05 -0700 Message-ID: <87le5v407q.fsf@ericabrahamsen.net> References: <86plvac0u0.fsf@gnu.org> <8734s55f98.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25749"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Monnier To: emacs-devel@gnu.org Cancel-Lock: sha1:k+lSxagtTUOytdCNa7v3xASD5ic= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Apr 03 13:02:42 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 1rryOA-0006SB-6V for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Apr 2024 13:02:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rryN7-0004m8-Sr; Wed, 03 Apr 2024 07:01:37 -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 1rrquJ-00065L-El for emacs-devel@gnu.org; Tue, 02 Apr 2024 23:03:24 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rrquG-0000a0-Ay for emacs-devel@gnu.org; Tue, 02 Apr 2024 23:03:23 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1rrquD-0001Dc-2N for emacs-devel@gnu.org; Wed, 03 Apr 2024 05:03:17 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 03 Apr 2024 07:01:36 -0400 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:317480 Archived-At: 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