emacs-devel
[Top][All Lists]
Advanced

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

Re: Make peg.el a built-in library?


From: Michael Heerdegen
Subject: Re: Make peg.el a built-in library?
Date: Tue, 16 Nov 2021 00:16:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Michael Heerdegen <michael_heerdegen@web.de> writes:

> > The LPEG people wrote a paper[*] about this problem.

The converter is more or less done - see below.  Feedback welcome!

Nearly everything regexps support is implemented.  I tried to make
everything so that the resulting peg is really equivalent to the given
regexp - please tell me if you find a translation where this is not
respected.

Remaining problems:

(1) Group numbering currently has to be explicit - unnumbered groups are
silently treated as shy.  That's because getting the numbering right is
not trivial.

I implemented groups and backrefs using an uninterned global variable
owned by the peg.  It would be better to add built-in support to peg.el
if we want that feature.

(2) Transforming character ranges to the vector representation that
peg.el uses is not trivial.  I would welcome help to get it done
correctly.  A possible (slow) fallback solution is a guard calling
`looking-at' followed by an (any).

Oh - why I think this conversion code is useful?  It's nice for learning
but also for cases were a regexp would almost suffice but you need some
Elisp guard somewhere in the middle of matching the regexp to
examine the buffer at that position.

Attachment: rx-to-peg.el
Description: application/emacs-lisp


Michael.

reply via email to

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