emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/peg 48731f7: * peg.el (peg-parse-at-point): Keep point


From: Stefan Monnier
Subject: [elpa] externals/peg 48731f7: * peg.el (peg-parse-at-point): Keep point at end of parse
Date: Thu, 14 Mar 2019 11:18:29 -0400 (EDT)

branch: externals/peg
commit 48731f7197ad826ba5f2b9e0617c4fb4a6d72904
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * peg.el (peg-parse-at-point): Keep point at end of parse
    
    (peg-parse-exp): Bind peg--errors.
---
 peg.el | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/peg.el b/peg.el
index 0b38f6d..48479b6 100644
--- a/peg.el
+++ b/peg.el
@@ -230,7 +230,7 @@ of PEG expressions, implicitly combined with `and'."
   "Match the parsing expression EXP at point.
 Note: a PE can't \"call\" rules by name."
   (declare (obsolete peg-parse "peg-0.9"))
-  `(let ((peg--actions nil))
+  `(let ((peg--actions nil) (peg--errors nil))
      (when ,(peg-translate-exp (peg-normalize exp))
        (peg-postprocess peg--actions))))
 
@@ -242,10 +242,10 @@ Used at runtime for backtracking.  It's a list ((POS . 
THUNK)...).
 Each THUNK is executed at the corresponding POS.  Thunks are
 executed in a postprocessing step, not during parsing.")
 
-;; used at runtime to track the right-most error location.  It's a
-;; pair (POSITION . EXPS ...).  POSITION is the buffer position and
-;; EXPS is a list of rules/expressions that failed.
-(defvar peg--errors)
+(defvar peg--errors nil
+  "Data keeping track of the rightmost parse failure location.
+It's a pair (POSITION . EXPS ...).  POSITION is the buffer position and
+EXPS is a list of rules/expressions that failed.")
 
 (defun peg--lookup-rule (name)
   (or (cdr (assq name (cdr (assq :peg-rules macroexpand-all-environment))))
@@ -267,7 +267,8 @@ executed in a postprocessing step, not during parsing.")
   (let ((peg--actions '()) (peg--errors '(-1)))
     (if (funcall rule-ref)
         ;; Found a parse: run the actions collected along the way.
-        (peg-postprocess peg--actions)
+        (save-excursion
+          (peg-postprocess peg--actions))
       (goto-char (car peg--errors))
       (signal 'peg-search-failed
               (list (car peg--errors)



reply via email to

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