unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Defining Functions With Syntax
@ 2011-09-20 19:00 Noah Lavine
  2011-09-21  8:08 ` Andy Wingo
  0 siblings, 1 reply; 9+ messages in thread
From: Noah Lavine @ 2011-09-20 19:00 UTC (permalink / raw)
  To: guile-devel

Hello all,

I was just going through updating the PEG documentation when I
encountered a very weird situation, and I don't know how to solve it.
As you probably know, the PEG system can take an s-expression
representation of a PEG grammar (a "peg s-exp") and turn it into a
function that can parse strings of this grammar. A macro called
'define-nonterm' does this at compile-time, but what if you build up a
PEG grammar at runtime and want to parse something with it?

The PEG documentation recommends doing '(eval `(define-nonterm as body
,exp) (interaction-environment))', where 'exp' is whatever your
s-expression is. This seems like a bad idea to me, because a) it also
defines a variable 'as', which is not needed and maybe not what you
want and b) it seems unnecessarily complicated. This recommendation is
especially strange because part of the PEG API is the function
'peg-sexp-compile', which actually turns a peg s-exp into a parsing
function. Unfortunately, peg-sexp-compile returns syntax, because that
is what is convenient for define-nonterm.

So at long last, my question is this: is there a way to take some
syntax and turn it directly into a function, without putting it inside
a macro and calling 'eval'? I think there should be, but I don't see
it in the manual. If there is not, I'd like to figure out an API and
add it.

Thanks,
Noah



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-09-21 19:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-20 19:00 Defining Functions With Syntax Noah Lavine
2011-09-21  8:08 ` Andy Wingo
2011-09-21 16:12   ` Mark H Weaver
2011-09-21 18:12     ` Noah Lavine
2011-09-21 18:03   ` Noah Lavine
2011-09-21 18:40     ` Andy Wingo
2011-09-21 18:44       ` Noah Lavine
2011-09-21 19:22         ` Andy Wingo
2011-09-21 19:37           ` Noah Lavine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).