> 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?