macro returning more than one form

Paul Tarvydas paultarvydas at gmail.com
Tue Mar 18 19:54:48 UTC 2014


@All, thanks for the interesting discussion.  Certainly gives me 
something to chew on.

Re-reading the responses, I see that, while I did sort-of say it, I 
didn't emphasize the point of this:

I have a PEG-syntax parser written in esrap.

I am binding at least two such parsers as reader-macros (not the normal 
kind of macro).

The first parser parses PEG syntax and creates an esrap program.

That esrap program, bound as a reader-macro, reads Prolog syntax and 
returns a bunch of lisp forms to the reader.

I have a file of code that contains both, lisp and Prolog syntax 
(cl-heredoc to switch between the syntaxes), e.g.

https://github.com/guitarvydas/paraphrase/blob/master/prolog.lisp

The parsers read characters, not forms.

(lisp)
#{ prolog(A,B,c) :- p1(A), p2(B,c). }
(morelisp)

I am making at least 2 assumptions:

1. That using different name spaces for the various parsers will help me 
preserve my sanity, (regression testing the PEG parser using itself 
brings me to the limits of my comprehension :-),

2. That a reader macro must return a single form.  I actually want to 
return a separate 'defun' for every prolog rule in the file. (Writing 
this, just now, makes me ask myself why I don't just put #{ ... } around 
every separate rule...)

(I even started fooling around with a Python syntax).

This line of thinking was inspired by the Gambit Scheme talk at ILC2010, 
where they showed inline infix mathematical expressions.

Thanks for your suggestions.

pt



More information about the pro mailing list