From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Re: PEG Patches Date: Tue, 29 Mar 2011 08:47:53 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1301402891 1620 80.91.229.12 (29 Mar 2011 12:48:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 29 Mar 2011 12:48:11 +0000 (UTC) Cc: guile-devel To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Mar 29 14:48:07 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q4YL5-0000ta-14 for guile-devel@m.gmane.org; Tue, 29 Mar 2011 14:48:03 +0200 Original-Received: from localhost ([127.0.0.1]:51471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4YL4-0004LQ-Gj for guile-devel@m.gmane.org; Tue, 29 Mar 2011 08:48:02 -0400 Original-Received: from [140.186.70.92] (port=58611 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4YKy-0004Jz-4w for guile-devel@gnu.org; Tue, 29 Mar 2011 08:47:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4YKw-0007ED-De for guile-devel@gnu.org; Tue, 29 Mar 2011 08:47:55 -0400 Original-Received: from mail-vw0-f41.google.com ([209.85.212.41]:42423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4YKw-0007Dy-BP for guile-devel@gnu.org; Tue, 29 Mar 2011 08:47:54 -0400 Original-Received: by vws4 with SMTP id 4so114956vws.0 for ; Tue, 29 Mar 2011 05:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=c+63nPvwT9Xe0GIrum8Bg17yQu0sZMMmG0l/oCGARdk=; b=JjYcPmU9GcyPF9ngAs58vVDA2WJ5vTSqP53hcxpYIcxfXbczqcscLepV2V1dqaWtjO E74YCZs7yqz4uHjyq2msmGOIdrU8Yy51f6tXTlYlSs8XoTDZOiKIPtpZ+rESk5hOe2zb 511H6BDTtrdY3tdC9o90mKF5BCRFdUOHOUCjk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=ogK98VVNwZgomkRN4HCCvQbuiecvXVBo15nHg7Zg1daJpdHcWVGnexGIh/x+AWuAzC ZdfxEh+naT6TymbuUf1ds2Fty4rqJReGNEYwYsC8qxuYaBww4dQqkvW9RbBDY4itDF+c PJ75n2zh0mqFry2OWZEPNFNeYa2Vo94sIUh6o= Original-Received: by 10.52.70.116 with SMTP id l20mr7717866vdu.13.1301402873708; Tue, 29 Mar 2011 05:47:53 -0700 (PDT) Original-Received: by 10.52.163.194 with HTTP; Tue, 29 Mar 2011 05:47:53 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: NKgHPud5X9fibSmYmbcHZU2VOLg X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.212.41 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:12053 Archived-At: > This last is the best. =A0What if we define a module that serves as a > registry of PEG match behaviors, like `(ice-9 peg matchers)'. =A0Then we > define `define-peg-matcher' or something, so that we can: > > (define-peg-matcher and cg-and) > > where define-peg-matcher is > > (define-syntax define-peg-matcher > =A0(syntax-rules () > =A0 =A0((_ name binding) > =A0 =A0 (module-define! (resolve-module '(ice-9 peg matchers)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'name > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0binding)))) > > Then instead of defining separate cases for ignore, range, etc the > peg-sexp-compile macro does: > > =A0((matcher arg ...) (identifier? #'matcher) > =A0 ((module-ref (resolve-module '(ice-9 peg matchers)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(syntax->datum #'matcher)) > =A0 =A0#'(arg ...) > =A0 =A0mode)) > > Then the peg-string module registers a matcher for `peg'. > > Dunno. =A0WDYT? That's doable. But if we're going to choose what to do entirely based on the first element of the list, then we could also just not define peg-sexp-compile at all and make each of the code generation functions into macros. How does that sound?