From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: No Itisnt Newsgroups: gmane.lisp.guile.devel Subject: Re: GSOC PEG project Date: Mon, 5 Jul 2010 20:41:23 -0500 Message-ID: References: <874ogdmu2m.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1278380494 17923 80.91.229.12 (6 Jul 2010 01:41:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 6 Jul 2010 01:41:34 +0000 (UTC) Cc: =?ISO-8859-1?Q?Ludovic_Court=E8s?= , guile-devel@gnu.org To: Michael Lucy Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jul 06 03:41:32 2010 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 1OVxAC-000570-Ca for guile-devel@m.gmane.org; Tue, 06 Jul 2010 03:41:32 +0200 Original-Received: from localhost ([127.0.0.1]:49320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVxAA-0008Vv-Sv for guile-devel@m.gmane.org; Mon, 05 Jul 2010 21:41:30 -0400 Original-Received: from [140.186.70.92] (port=50453 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OVxA6-0008Vg-Cy for guile-devel@gnu.org; Mon, 05 Jul 2010 21:41:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OVxA5-0001JZ-5Y for guile-devel@gnu.org; Mon, 05 Jul 2010 21:41:26 -0400 Original-Received: from mail-qy0-f176.google.com ([209.85.216.176]:50147) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OVxA5-0001JT-3P; Mon, 05 Jul 2010 21:41:25 -0400 Original-Received: by qyk12 with SMTP id 12so1970005qyk.0 for ; Mon, 05 Jul 2010 18:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=SRZuXiWzZ3sRsKWaLF6780pOv2LPUDX246E9tDcMNQM=; b=AV4XTnaHAsnmjzUtMFTrLbZrgi8FQ6J+fgLhEdFoEwgarQ+2JtY7Ie7gGJnXoiZV3K ncvkjS4B//0iKOGPYJuW+cQbNT1JtdFyAQ5yWeSwyQ6m9higjkkHNdbSgp1zafyQWskR xAf2YgaYhYgdo2Ecpmck5HS9N9mZ7LEn516XI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=QwTo7N0n10QDEKNj/UWgwBvYxBiAQ5n/lHKOpvzX3V21ux03iEialnAKQIn+4uJtei ypEXit6fsOCDLoe9BD01ULehv4l7rOyKivj/SWaKzs5Bj9M+4rfcAENMSx9Li0u+IgzV /UxwBe1ozuLtzMi/hKWpL4qvcmoztjWzQ6QHg= Original-Received: by 10.224.62.196 with SMTP id y4mr925947qah.171.1278380483738; Mon, 05 Jul 2010 18:41:23 -0700 (PDT) Original-Received: by 10.229.232.144 with HTTP; Mon, 5 Jul 2010 18:41:23 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:10618 Archived-At: On Mon, Jul 5, 2010 at 6:59 PM, Michael Lucy wrote= : > On Mon, Jul 5, 2010 at 5:40 PM, Ludovic Court=E8s wrote: >> Hi! >> >> Thanks for the status report! >> >> Michael Lucy writes: >> >>> Files I've added so far: >>> guile/modules/ice-9/peg.scm (I assume this is the right place to put th= is?) >> >> No, it should rather go under =91module/language/peg.scm=92, for the sak= e of >> consistency with other compiler front-ends. =A0But see below. > > I'm not quite sure how this qualifies as a compiler front-end. =A0The > functionality is mostly done (if unoptimized), so it shouldn't be too > hard to turn it into one if that's what you want, but the original > thought was just to build a compiling parser. =A0E.g.: > > (use-modules (ice-9 peg)) > (peg-find "'b'+" "aabbcc") > --> (2 4 "bb") > > It does this by compiling "'b'+" into a lambda expression that then > gets called on whatever the second argument is (the compilation is > done at read-time). =A0So after macro-expansion, you have something > like: > ((lambda (...) ...) "aabbcc" ...) > > I was thinking of this as a sort of alternative to regular expressions > that also does parsing, and I noticed the regular expressions module > was in ice-9, so I put it there. > > Are you saying that the functionality that compiles "'b'+" to a lambda > expression should be broken out into a language module that instead > compiles it to TREE-IL code? =A0Am I fundamentally misunderstanding > something? > >> >>> PEG compiler: Works for all the grammars I've tested, no known bugs. >>> Currently compiles to Scheme code rather than Tree-IL for debugging. >> >> It should rather compiler to tree-IL, like other front-ends, which is >> very close to Scheme anyway. I think you are both misunderstanding eachother: - The PEG functions, useful in their own right, would be exposed as (ice-9 = peg). - There is an additional syntax for expressing grammars, so it can be better used as a parser generator. That would go in as (language peg). That's just my take though. A personal whinge: I would like to be able to specify grammars in Scheme, using macros as the sugar instead of a different syntax. > > Alright, I'll fix that. > > Noob question: > The only way I can figure out to compile tree-il code is the rather ugly: > (compile (parse-tree-il '(code here)) #:from 'tree-il) > Is there a better way? I'm not sure if you mean generating tree-il code or just compiling the tree-il literals. If you want to generate it, use the record interface from (language tree-il), if you want to compile the literals, that's pretty much the way to do it. You can also do ,language tree-il at the REPL to experiment with it. Exciting stuff :) I can't wait to use this, maintaining my own hand-written recursive descent parser is like watching a trainwreck in slow motion.