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: Make peg.el a built-in library? Date: Fri, 27 Aug 2021 09:57:21 -0700 Message-ID: <871r6eq0zy.fsf@ericabrahamsen.net> References: <875yvtbbn3.fsf@ericabrahamsen.net> <87bl5k87hq.fsf@alphapapa.net> <87fsuvpod4.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23594"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Aug 27 18:58:19 2021 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 1mJfBL-0005q7-DK for ged-emacs-devel@m.gmane-mx.org; Fri, 27 Aug 2021 18:58:19 +0200 Original-Received: from localhost ([::1]:34048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJfBJ-00008L-Fo for ged-emacs-devel@m.gmane-mx.org; Fri, 27 Aug 2021 12:58:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJfAV-0007Wb-Vk for emacs-devel@gnu.org; Fri, 27 Aug 2021 12:57:28 -0400 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]:53832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJfAS-0002GV-Ta for emacs-devel@gnu.org; Fri, 27 Aug 2021 12:57:27 -0400 Original-Received: from localhost (c-73-109-4-106.hsd1.wa.comcast.net [73.109.4.106]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id AEF51FA07F; Fri, 27 Aug 2021 16:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1630083443; bh=uAv832gqFJl0CarFvJC53uiEV9A3JQ1EmCk3osGdX+Y=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=GVLvtUZRn9InOQVAF7+HeLgjOzlU/Ch0AE+Fw8qhk5mugjTmv/AJexY1/g+do6jB4 U9LkgmbxCKRSKPKr6+nfpwFBxEiiQjuKbvskXBWxPLclwv6y9LZNw8BlTkGhsf0l7t L+rtSqKvKfZA2gdkTBIU+sIGHtQzLyNd+gerGqQY= In-Reply-To: (Helmut Eller's message of "Fri, 27 Aug 2021 08:41:19 +0200") Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@ericabrahamsen.net; helo=mail.ericabrahamsen.net X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, 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.23 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" Xref: news.gmane.io gmane.emacs.devel:273170 Archived-At: Helmut Eller writes: Thanks for jumping in (and thanks for the package)! > On Thu, Aug 26 2021, Eric Abrahamsen wrote: > >> Whoo, I've been trying to get enough of a handle on the parsing actions >> to write a documentation patch for them -- now I'm seeing what Helmut >> meant by "semantically unintuitive". > > What I actually meant with "semantically unintuitive" are issues > described in Roman Redziejowski's "Trying to understand PEG" paper[*]. > He writes: > > The problem with limited backtracking is that by not trying hard it > may miss some inputs that it should accept. A notorious example is > the rule A =3D aAa | aa that defines the set of strings of a=E2=80=99s= of even > length. Implemented with limited backtracking, this rule accepts only > strings of length 2^n. Oh... well personally I haven't got to the stage where this is an issue... >> The sum total of docs regarding >> actions is: >> >> A "stack action" takes VARs from the "value stack" and pushes the result >> of evaluating FORMs to that stack. > > Using an "open stack" for actions was my rather idiosyncratic choice and > I'm sure that many people will not like it. The syntax ( a b -- b a ) > should be familiar to Forth programmers, where it's used to describe the > stack-effect of commands. The example would be the SWAP operator. If > you have never, or not recently, written some Forth or Postscript, then > mentally keeping track of the stack state can be challenging. The stack itself isn't that hard to handle, but I do think the documentation could be fleshed out with a little hand-holding. The examples are good, _after_ you understand the basics. I've never written Forth, and we probably shouldn't expect anyone else to have, either. I originally assumed the `(a b -- b a) bits could just be replaced with lambda forms, but I suppose the problem there is that a lambda has a single return value, and we'd have to do something ugly if we wanted to push multiple values back onto the stack. Eric