guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PEG Patches


From: Noah Lavine
Subject: Re: PEG Patches
Date: Tue, 29 Mar 2011 08:47:53 -0400

> This last is the best.  What if we define a module that serves as a
> registry of PEG match behaviors, like `(ice-9 peg matchers)'.  Then we
> define `define-peg-matcher' or something, so that we can:
>
> (define-peg-matcher and cg-and)
>
> where define-peg-matcher is
>
> (define-syntax define-peg-matcher
>  (syntax-rules ()
>    ((_ name binding)
>     (module-define! (resolve-module '(ice-9 peg matchers))
>                      'name
>                      binding))))
>
> Then instead of defining separate cases for ignore, range, etc the
> peg-sexp-compile macro does:
>
>  ((matcher arg ...) (identifier? #'matcher)
>   ((module-ref (resolve-module '(ice-9 peg matchers))
>                (syntax->datum #'matcher))
>    #'(arg ...)
>    mode))
>
> Then the peg-string module registers a matcher for `peg'.
>
> Dunno.  WDYT?

That's doable. But if we're going to choose what to do entirely based
on the first element of the list, then we could also just not define
peg-sexp-compile at all and make each of the code generation functions
into macros.

How does that sound?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]