From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.devel Subject: Re: Make peg.el a built-in library? Date: Thu, 10 Nov 2022 09:29:32 +0100 Message-ID: References: <875yvtbbn3.fsf@ericabrahamsen.net> <877d07a16u.fsf@localhost> <87tu3asg2r.fsf@ericabrahamsen.net> <83pmdvrzs4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wL9Cl88ztp6zzXE5" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37737"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 10 09:30:06 2022 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 1ot2wm-0009cA-Qo for ged-emacs-devel@m.gmane-mx.org; Thu, 10 Nov 2022 09:30:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ot2wQ-0001Ir-Ru; Thu, 10 Nov 2022 03:29:42 -0500 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 1ot2wO-0001FR-6T for emacs-devel@gnu.org; Thu, 10 Nov 2022 03:29:40 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ot2wM-0001oA-5l; Thu, 10 Nov 2022 03:29:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject :Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BzcWMdOzjOPCRiCa41dPShKjm9Nh1I1XJLt2Cqp2HIk=; b=SVmRIm+PzUsubmo8z5HB+pyLps Bc1FYhQJf2Z3agW29qkEhXH9CANE65ymj3cGNsvmOMRrjIgsnmr5hP560ocnXsuYCSoLtuxApCGRH /o7S6sTcLVLTqOsMpgSTs9yTMvMWupVkss3OQYCkCgXLacOf04vTyaFIelKyJ6MgBCKdEiD7D72Vj z6t8Nve2A1zWijlosRpRQ0/ccVkaTCWHZWTKlbB7WAGNzsPy2UMW3XuNTAiyld38OyEGkZDRfY1l2 uYK/i0CV2igcHLV27kEJCW0nqJomuCAP1GsPFpqDQv566ahwudRRRD5gxGKIEjZcqCJ8/mmMlUNxN DCDdVvQg==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1ot2wG-0007D6-UK; Thu, 10 Nov 2022 09:29:32 +0100 Content-Disposition: inline In-Reply-To: <83pmdvrzs4.fsf@gnu.org> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:299467 Archived-At: --wL9Cl88ztp6zzXE5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 10, 2022 at 10:15:23AM +0200, Eli Zaretskii wrote: > > Date: Thu, 10 Nov 2022 06:25:55 +0100 > > From: > >=20 > > > Would someone like to tell me in 10 lines what job peg.el does? > >=20 > > PEG (Parsing Expression Grammars [1]) is a grammar notation which can > > be automatically translated into a parser (think regular expressions). >=20 > The reference [1] was probably meant to be >=20 > https://en.wikipedia.org/wiki/Parsing_expression_grammar Thanks. -ENOCOFFEE, possibly :) > or somesuch >=20 > > The notation is actually similar to that of regexps. >=20 > I believe you meant "similar to regular expressions in rx form"? I wasn't particularly thinking of rx. PEGs in general also have a "classical" spelling which looks deceivingly similar to "classic" regular expressions. [...] > I think an example from peg.el will clarify the issue: >=20 > ;; This file implements the macros `define-peg-rule', `with-peg-rules',= and > ;; `peg-parse' which parses the current buffer according to a PEG. > ;; E.g. we can match integers with: > ;; > ;; (with-peg-rules > ;; ((number sign digit (* digit)) > ;; (sign (or "+" "-" "")) > ;; (digit [0-9])) > ;; (peg-run (peg number))) > ;; or > ;; (define-peg-rule digit () > ;; [0-9]) > ;; (peg-parse (number sign digit (* digit)) > ;; (sign (or "+" "-" ""))) Thanks for the example. This one stresses tha main "selling point" of PEGs, that they can "do" a grown up parser without separating lex and "parse" into two "floors". The downside is that they aren't as "tall" (as the customary LALR/regexp combo). Cheers --=20 t --wL9Cl88ztp6zzXE5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCY2y2ZQAKCRAFyCz1etHa Rj2VAJ9kmTKrCf3s/C86OjkZHCZnTIlKdgCcCAfbNHeFfA+fapchQw0JEFxH0qA= =sqUf -----END PGP SIGNATURE----- --wL9Cl88ztp6zzXE5--