[toronto-lisp] help deciphering Scheme macro(s)
Vish Singh
vishvajitsingh at gmail.com
Sat Feb 23 10:40:15 UTC 2013
Hello Paul,
Getting Racket running on Ubuntu couldn't possibly be more difficult
than "sudo apt-get install racket", could it? I'm running Ubuntu and
"apt-cache show racket" gives me a package in the Universe repository.
In that pattern, "alternative ..." matches whatever is found after the
forward slash in that subexpression; i.e. all the alternatives. Scheme
is able to "multiply out" the "..." such that
(#t alternative) ...
expands out to
(#t alternative0) (#t alternative1) (#t alternative2) etc.
where alternative0 is the first item after the forward slash,
alternative1 is the second, etc.
Vish
On Tue, Feb 19, 2013 at 9:56 AM, Paul Tarvydas <paultarvydas at gmail.com> wrote:
> I'm converting this PEG parser from R5RS scheme to CL:
>
> http://dev.lshift.net/tonyg/json-scheme/
>
> I'm having trouble (I think) deciphering how the following macro is expanded
> (esp. the 2nd line "(#t alternative) ...")
>
> ...
>
> ((_ #f "alt" nt body ((/ alternative ...) rest ...))
> (packrat-check (packrat-parser #f "alts" nt (#t alternative) ...)
> (lambda (result) (packrat-parser #f "alt" nt body (rest
> ...)))))
>
> ...
>
> Let's say the input is something simple, such as "...((x <- #\y (/ #\a #\b))
> x) ... " (i.e. parse a 'y' followed by an 'a' or a 'b', assign 'y' to the
> variable x, then return that variable x).
>
> Does someone know how to "read" this macro?
>
> Or, can someone tell me the exact steps in getting any working
> implementation of R5RS scheme up on linux (mint/ubuntu/debian) or Win7 and
> display the expanded macro? (I seem to hit confusing roadblocks with
> racket, chicken, cpscm+scm2lisp).
>
> Thanks
> pt
>
> _______________________________________________
> toronto-lisp mailing list
> toronto-lisp at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/toronto-lisp
More information about the toronto-lisp
mailing list