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

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

[elpa] externals/peg f94bb98: * peg.el (define-peg-rule): Add arg and fi


From: Stefan Monnier
Subject: [elpa] externals/peg f94bb98: * peg.el (define-peg-rule): Add arg and fix definition
Date: Tue, 12 Mar 2019 15:03:07 -0400 (EDT)

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

    * peg.el (define-peg-rule): Add arg and fix definition
    
    * peg-tests.el (peg-test-natural): New PEG rule.
    (peg-test): Use it.
---
 peg-tests.el |  4 ++++
 peg.el       | 10 +++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/peg-tests.el b/peg-tests.el
index 0a19115..a48dc9e 100644
--- a/peg-tests.el
+++ b/peg-tests.el
@@ -26,7 +26,11 @@
 
 ;;; Tests:
 
+(define-peg-rule peg-test-natural ()
+  [0-9] (* [0-9]))
+
 (ert-deftest peg-test ()
+  (should (peg-parse-string peg-test-natural "99 bottles" t))
   (should (peg-parse-string ((s "a")) "a" t))
   (should (not (peg-parse-string ((s "a")) "b" t)))
   (should (peg-parse-string ((s (not "a"))) "b" t))
diff --git a/peg.el b/peg.el
index 378eb12..e920a50 100644
--- a/peg.el
+++ b/peg.el
@@ -5,7 +5,7 @@
 ;; Author: Helmut Eller <address@hidden>
 ;; Maintainer: Stefan Monnier <address@hidden>
 ;; Package-Requires: ((emacs "25"))
-;; Version: 0.9
+;; Version: 0.9.1
 ;;
 ;; This program is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -160,8 +160,8 @@
 (defmacro peg-parse (&rest pexs)
   "Match PEXS at point.
 PEXS is a sequence of PEG expressions, implicitly combined with `and'.
-Return (T STACK) if the match succeed and nil on failure, moving point
-along the way."
+Return STACK if the match succeed and signals an error on failure,
+moving point along the way."
   (if (and (consp (car pexs))
            (symbolp (caar pexs))
            (not (ignore-errors (peg-normalize (car pexs)))))
@@ -170,7 +170,7 @@ along the way."
       `(with-peg-rules ,pexs (peg-parse-at-point (peg-rule-ref ,(caar pexs))))
     `(peg-parse-at-point (peg-rule-ref ,@pexs))))
 
-(defmacro define-peg-rule (name &rest pexs)
+(defmacro define-peg-rule (name args &rest pexs)
   "Define PEG rule NAME as equivalent to PEXS.
 The PEG expressions in PEXS are implicitly combined with the
 sequencing `and' operator of PEG grammars."
@@ -178,7 +178,7 @@ sequencing `and' operator of PEG grammars."
   (let ((id (peg--rule-id name))
         (exp (peg-normalize `(and . ,pexs))))
     `(progn
-       (defun ',id ()
+       (defun ,id ,args
          ,(peg--translate-rule-body name exp))
        (put ',id 'peg--rule-definition ',exp))))
 



reply via email to

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