emacs-devel
[Top][All Lists]
Advanced

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

Re: master 8bee4060ea4 2/2: Add peg.el as a built-in library


From: Eric Abrahamsen
Subject: Re: master 8bee4060ea4 2/2: Add peg.el as a built-in library
Date: Tue, 02 Apr 2024 20:03:05 -0700
User-agent: Gnus/5.13 (Gnus v5.13)

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> branch: master
>>> commit 8bee4060ea42c61e52ebe6487ff97bc095261050
>>> Author: Eric Abrahamsen <eric@ericabrahamsen.net>
>>> Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
>>> 
>>>     Add peg.el as a built-in library
>>>     
>>>     * lisp/progmodes/peg.el: New file, taken from ELPA package.
>>>     * test/lisp/peg-tests.el: Package tests.
>>>     * doc/lispref/peg.texi: Documentation.
>>
>> Thanks.  A few comments about this:
>
> Thanks for the all the notes. I should have this sorted out later today.

Hi Stefan, I'm still working on integrating peg.el in to Emacs, and am
not having any luck getting peg-tests.el to compile. Actually, any use
of `peg-parse', compiled or interactive, seems to fail. Say you've got
this simple example from the manual:

(peg-parse
  (number sign digit (* digit))
  (sign   (or "+" "-" ""))
  (digit  [0-9]))

Inside `peg-parse', the only way this code is going to work correctly is
if it takes the `with-peg-rules' branch, because these pexs aren't
defined as rules yet. But the call to `peg-normalize' always succeeds,
so we always take the `peg-run' branch, and the code fails on undefined
rules.

(defmacro peg-parse (&rest pexs)
  (if (and (consp (car pexs))
           (symbolp (caar pexs))
           (not (ignore-errors (peg-normalize (car pexs)))))
      ;; `pexs' is a list of rules: use the first rule as entry point.
      `(with-peg-rules ,pexs (peg-run (peg ,(caar pexs)) #'peg-signal-failure))
    `(peg-run (peg ,@pexs) #'peg-signal-failure)))

`peg-normalize' called on a cons applies `peg--macroexpand' to the list,
which calls its "head" implementation, and we end up with

(call number sign digit (* digit))

`peg' sees that and assumes this has been defined as a rule.

So `peg-normalize' should be failing on a list like this, but I don't
know how, exactly.

I'm hoping you have some pointers!

Thanks,
Eric




reply via email to

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