On Mon 28 Mar 2011 22:44, Noah Lavine <noah.b.lav...@gmail.com> writes:

>  - say that string PEGs can only occur at the top level of a PEG
> expression. The peg module has never been released, so no one uses
> this feature now anyway.
>  - instead of defining a new function peg-extended-compile, redefine
> peg-sexp-compile via set! once we have string pegs.
>  - write peg-extended-compile as its own big case statement, basically
> duplicating peg-sexp-compile.
>  - adopt some interface that allows people to extend the cases in
> peg-sexp-compile. We would start with just s-expression PEGs, then use
> this interface to add string PEGs later in the load sequence.

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?

Andy
-- 
http://wingolog.org/

Reply via email to