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