From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: a Q on syntax-rules vs syntax-case Date: Sun, 08 Feb 2015 18:36:46 -0800 Message-ID: References: <87386fua6p.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1423449437 23014 80.91.229.3 (9 Feb 2015 02:37:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Feb 2015 02:37:17 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Feb 09 03:37:16 2015 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YKeDs-0001GI-9j for guile-user@m.gmane.org; Mon, 09 Feb 2015 03:37:16 +0100 Original-Received: from localhost ([::1]:58527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKeDr-0006im-7x for guile-user@m.gmane.org; Sun, 08 Feb 2015 21:37:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKeDj-0006hp-A3 for guile-user@gnu.org; Sun, 08 Feb 2015 21:37:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKeDg-0000aJ-3A for guile-user@gnu.org; Sun, 08 Feb 2015 21:37:07 -0500 Original-Received: from vms173023pub.verizon.net ([206.46.173.23]:60185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKeDf-0000Vu-VM for guile-user@gnu.org; Sun, 08 Feb 2015 21:37:04 -0500 Original-Received: from [192.168.2.127] ([71.108.234.224]) by vms173023.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0NJH0096UGLAST40@vms173023.mailsrvcs.net> for guile-user@gnu.org; Sun, 08 Feb 2015 20:36:47 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=PYxIXZlY c=1 sm=1 tr=0 a=4GYO7MqD+LEvu06q0FvZQA==:117 a=kj9zAlcOel0A:10 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=0HtSIViG9nkA:10 a=f5uqsoALvVVBv4S7ImUA:9 a=CjuIK1q_8ugA:10 In-reply-to: <87386fua6p.fsf@netris.org> X-Mailer: Apple Mail (2.1878.6) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.46.173.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11756 Archived-At: Thanks Mark. =20 I did make progress on this. I also discovered that I need to use the = optional specification of ellipses (i..e, :::) in the top-level macro to = avoid clash with ellipses in the letrec-syntax part. For information, the project is an LALR parser generator which has a = Scheme flavor for specifying grammars. There is no need to declare = tokens: the macro uses a fender to differentiate non-terminals (e.g., = expr) from terminals (e.g., 'float, #\+). The code turns out to be = pretty clean and compact, I believe. I plan to use the local bindings = to provide macros for common patterns (e.g., ($opt 'const) int =3D> = opt-1 'int , (opt-1 () ('const)).=20 Matt (define spec0 (lalr2-spec (start expr) (grammar (expr (expr #\+ term ($action (+ $1 $3))) (expr #\- term ($action (- $1 $3))) (term)) (term (term #\* factor ($action (* $1 $3))) (term #\/ factor ($action (/ $1 $3))) (factor)) (factor ('integer) ('float)) )))