guile-devel
[Top][All Lists]
Advanced

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

Re: PEG Patches


From: Andy Wingo
Subject: Re: PEG Patches
Date: Tue, 29 Mar 2011 10:00:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

On Mon 28 Mar 2011 22:44, Noah Lavine <address@hidden> 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

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