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

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

[elpa] master dc957e9 5/5: Merge commit '1e10278c3201f55c339a81e33b2ba8e


From: Ian Dunn
Subject: [elpa] master dc957e9 5/5: Merge commit '1e10278c3201f55c339a81e33b2ba8e8adf989b6'
Date: Wed, 7 Feb 2018 20:43:27 -0500 (EST)

branch: master
commit dc957e9225c0b0ad9456f9fa1be7d9976c6a7eee
Merge: 9a41c53 1e10278
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>

    Merge commit '1e10278c3201f55c339a81e33b2ba8e8adf989b6'
---
 packages/org-edna/.bzrignore        |   3 +-
 packages/org-edna/Project.ede       |   4 +-
 packages/org-edna/org-edna-tests.el |  94 ++++++++++++++++++++---
 packages/org-edna/org-edna.el       |  87 +++++++++++++--------
 packages/org-edna/org-edna.info     | 149 ++++++++++++++++++++----------------
 packages/org-edna/org-edna.org      |   8 ++
 packages/org-edna/test.mk           |   4 +-
 7 files changed, 234 insertions(+), 115 deletions(-)

diff --git a/packages/org-edna/.bzrignore b/packages/org-edna/.bzrignore
index bbb6def..05318df 100644
--- a/packages/org-edna/.bzrignore
+++ b/packages/org-edna/.bzrignore
@@ -3,4 +3,5 @@ local.mk
 org-edna-autoloads.el
 org-edna.texi
 org-edna.html
-.deps
\ No newline at end of file
+.deps
+Makefile
\ No newline at end of file
diff --git a/packages/org-edna/Project.ede b/packages/org-edna/Project.ede
index decef82..65176dc 100644
--- a/packages/org-edna/Project.ede
+++ b/packages/org-edna/Project.ede
@@ -11,9 +11,9 @@
       :source '("org-edna.el")
       :aux-packages '("org"))
     (ede-proj-target-makefile-miscelaneous 
"ede-proj-target-makefile-miscelaneous"
-      :name "check"
+      :name #("check" 0 1 (idx 2))
       :path ""
-      :source '("org-edna-tests.el" "org-edna-tests.org")
+      :source '("org-edna-tests.el" "org-edna-tests.org" "test.mk")
       :partofall nil
       :submakefile "test.mk")
     (ede-proj-target-aux "ede-proj-target-aux"
diff --git a/packages/org-edna/org-edna-tests.el 
b/packages/org-edna/org-edna-tests.el
index 6ce4f64..0a9ddca 100644
--- a/packages/org-edna/org-edna-tests.el
+++ b/packages/org-edna/org-edna-tests.el
@@ -154,6 +154,14 @@
              '(((self)
                 (!done?)))))))
 
+(ert-deftest org-edna-form-to-sexp-negation ()
+  (let* ((input-string "self !done?")
+         (sexp (org-edna-string-form-to-sexp-form input-string 'condition)))
+    (should (equal
+             sexp
+             '(((self)
+                (!done?)))))))
+
 (ert-deftest org-edna-form-to-sexp-arguments ()
   (let* ((input-string "match(\"checklist\") todo!(TODO)")
          (sexp (org-edna-string-form-to-sexp-form input-string 'action)))
@@ -167,10 +175,10 @@
          (sexp (org-edna-string-form-to-sexp-form input-string 'action)))
     (should (equal
              sexp
-             '(((if ((match "checklist")
-                     (done?))
-                    ((self)
-                     (todo! TODO))
+             '(((if (((match "checklist")
+                      (done?)))
+                    (((self)
+                      (todo! TODO)))
                   nil)))))))
 
 (ert-deftest org-edna-form-to-sexp-if-else ()
@@ -178,12 +186,78 @@
          (sexp (org-edna-string-form-to-sexp-form input-string 'action)))
     (should (equal
              sexp
-             '(((if ((match "checklist")
-                      (done?))
-                    ((self)
-                     (todo! TODO))
-                  ((siblings)
-                   (todo! DONE)))))))))
+             '(((if (((match "checklist")
+                      (done?)))
+                    (((self)
+                      (todo! TODO)))
+                  (((siblings)
+                    (todo! DONE))))))))))
+
+(ert-deftest org-edna-form-to-sexp-if-multiple-thens ()
+  (let* ((input-string "if match(\"checklist\") done? then self next-sibling 
todo!(TODO) self set-property!(\"COUNTER\" \"0\") endif")
+         (sexp (org-edna-string-form-to-sexp-form input-string 'action)))
+    (should (equal
+             sexp
+             '(((if (((match "checklist")
+                      (done?)))
+                    (((self)
+                      (next-sibling)
+                      (todo! TODO))
+                     ((self)
+                      (set-property! "COUNTER" "0")))
+                  nil)))))))
+
+(ert-deftest org-edna-form-to-sexp-if-multiple-elses ()
+  (let* ((input-string "if match(\"checklist\") done? then self todo!(TODO) 
else siblings todo!(DONE) self todo!(TODO) endif")
+         (sexp (org-edna-string-form-to-sexp-form input-string 'action)))
+    (should (equal
+             sexp
+             '(((if (((match "checklist")
+                      (done?)))
+                    (((self)
+                      (todo! TODO)))
+                  (((siblings)
+                    (todo! DONE))
+                   ((self)
+                    (todo! TODO))))))))))
+
+(ert-deftest org-edna-form-to-sexp-failed-if ()
+  (pcase-let* ((input-string "if match(\"checklist\") done?")
+               (`(,error . ,data) (should-error 
(org-edna-string-form-to-sexp-form
+                                                input-string 'action)
+                                               :type 'invalid-read-syntax)))
+    (should (eq error 'invalid-read-syntax))
+    (should (listp data))
+    (should (eq (length data) 6))
+    (should (string-equal (plist-get data :msg) "Malformed if-construct; 
expected then terminator"))
+    ;; Error should point to the start of the if-statement
+    (should (eq (plist-get data :error-pos) 0))))
+
+(ert-deftest org-edna-form-to-sexp-failed-if-then ()
+  (pcase-let* ((input-string "if match(\"checklist\") done? then")
+               (`(,error . ,data) (should-error 
(org-edna-string-form-to-sexp-form
+                                                input-string 'action)
+                                               :type 'invalid-read-syntax)))
+    (should (eq error 'invalid-read-syntax))
+    (should (listp data))
+    (should (eq (length data) 6))
+    (should (string-equal (plist-get data :msg)
+                          "Malformed if-construct; expected else or endif 
terminator"))
+    ;; Error should point to the start of the if-statement
+    (should (eq (plist-get data :error-pos) 28))))
+
+(ert-deftest org-edna-form-to-sexp-failed-if-then-else ()
+  (pcase-let* ((input-string "if match(\"checklist\") done? then todo!(TODO) 
else todo!(TODO)")
+               (`(,error . ,data) (should-error 
(org-edna-string-form-to-sexp-form
+                                                 input-string 'action)
+                                                :type 'invalid-read-syntax)))
+    (should (eq error 'invalid-read-syntax))
+    (should (listp data))
+    (should (eq (length data) 6))
+    (should (string-equal (plist-get data :msg)
+                          "Malformed if-construct; expected endif terminator"))
+    ;; Error should point to the start of the if-statement
+    (should (eq (plist-get data :error-pos) 45))))
 
 (ert-deftest org-edna-expand-sexp-form ()
   ;; Override cl-gentemp so we have a repeatable test
diff --git a/packages/org-edna/org-edna.el b/packages/org-edna/org-edna.el
index cfd6d16..9974e3a 100644
--- a/packages/org-edna/org-edna.el
+++ b/packages/org-edna/org-edna.el
@@ -7,7 +7,7 @@
 ;; Keywords: convenience, text, org
 ;; URL: https://savannah.nongnu.org/projects/org-edna-el/
 ;; Package-Requires: ((emacs "25.1") (seq "2.19") (org "9.0.5"))
-;; Version: 1.0beta5
+;; Version: 1.0beta6
 
 ;; This file is part of GNU Emacs.
 
@@ -70,20 +70,19 @@ properties used during actions or conditions."
 ;; 2. Edna sexp form; this is the intermediary form, and form used in 
org-edna-form
 ;; 3. Lisp form; a form that can be evaluated by Emacs
 
-(defmacro org-edna--syntax-error (msg form error-form)
+(defmacro org-edna--syntax-error (msg form error-pos)
   "Signal an Edna syntax error.
 
 MSG will be reported to the user and should describe the error.
 FORM is the form that generated the error.
-ERROR-FORM is the sub-form in FORM at which the error occurred."
-  `(signal 'invalid-read-syntax (list :msg ,msg :form ,form :error-form 
,error-form)))
+ERROR-POS is the positiong in MSG at which the error occurred."
+  `(signal 'invalid-read-syntax (list :msg ,msg :form ,form :error-pos 
,error-pos)))
 
 (defun org-edna--print-syntax-error (error-plist)
   "Prints the syntax error from ERROR-PLIST."
   (let* ((msg (plist-get error-plist :msg))
          (form (plist-get error-plist :form))
-         (error-form (plist-get error-plist :error-form))
-         (pos (string-match-p (symbol-name (car error-form)) form)))
+         (pos (plist-get error-plist :error-pos)))
     (message
      "Org Edna Syntax Error: %s\n%s\n%s"
      msg form (concat (make-string pos ?\ ) "^"))))
@@ -192,7 +191,7 @@ siblings todo!(TODO) => ((siblings) (todo! TODO))"
         final-form)
     (while (< pos (length string))
       (pcase-let* ((`(,form ,new-pos) (org-edna-parse-string-form string pos)))
-        (setq final-form (append final-form (list form)))
+        (setq final-form (append final-form (list (cons form pos))))
         (setq pos new-pos)))
     (cons final-form pos)))
 
@@ -212,58 +211,65 @@ the remainder of FORM after the current scope was parsed."
          final-form
          need-break)
     (while (and remaining-form (not need-break))
-      (let ((current-form (pop remaining-form)))
+      (pcase-let* ((`(,current-form . ,error-pos) (pop remaining-form)))
         (pcase (car current-form)
           ('if
               ;; Check the car of each r*-form for the expected
               ;; ending.  If it doesn't match, throw an error.
               (let (cond-form then-form else-form have-else)
                 (pcase-let* ((`(,temp-form ,r-form)
-                              (org-edna--normalize-sexp-form
+                              (org-edna--normalize-forms
                                remaining-form
                                ;; Only allow conditions in cond forms
                                'condition
+                               '((then))
                                from-string)))
-                  ;; Use car-safe to catch r-form = nil
-                  (unless (equal (car-safe r-form) '(then))
+                  (unless r-form
                     (org-edna--syntax-error
                      "Malformed if-construct; expected then terminator"
-                     from-string current-form))
+                     from-string error-pos))
+                  ;; Skip the 'then' construct and move forward
                   (setq cond-form temp-form
+                        error-pos (cdar r-form)
                         remaining-form (cdr r-form)))
+
                 (pcase-let* ((`(,temp-form ,r-form)
-                              (org-edna--normalize-sexp-form remaining-form
-                                                             
action-or-condition
-                                                             from-string)))
-                  (unless (member (car-safe r-form) '((else) (endif)))
+                              (org-edna--normalize-forms remaining-form
+                                                         action-or-condition
+                                                         '((else) (endif))
+                                                         from-string)))
+                  (unless r-form
                     (org-edna--syntax-error
                      "Malformed if-construct; expected else or endif 
terminator"
-                     from-string current-form))
-                  (setq have-else (equal (car r-form) '(else))
+                     from-string error-pos))
+                  (setq have-else (equal (caar r-form) '(else))
                         then-form temp-form
+                        error-pos (cdar r-form)
                         remaining-form (cdr r-form)))
                 (when have-else
                   (pcase-let* ((`(,temp-form ,r-form)
-                                (org-edna--normalize-sexp-form remaining-form
-                                                               
action-or-condition
-                                                               from-string)))
-                    (unless (equal (car-safe r-form) '(endif))
+                                (org-edna--normalize-forms remaining-form
+                                                           action-or-condition
+                                                           '((endif))
+                                                           from-string)))
+                    (unless r-form
                       (org-edna--syntax-error "Malformed if-construct; 
expected endif terminator"
-                                              from-string current-form))
+                                              from-string error-pos))
                     (setq else-form temp-form
                           remaining-form (cdr r-form))))
                 (push `(if ,cond-form ,then-form ,else-form) final-form)))
           ((or 'then 'else 'endif)
            (setq need-break t)
            ;; Push the object back on remaining-form so the if knows where we 
are
-           (setq remaining-form (cons current-form remaining-form)))
+           (setq remaining-form (cons (cons current-form error-pos) 
remaining-form)))
           (_
            ;; Determine the type of the form
            ;; If we need to change state, return from this scope
-           (pcase-let* ((`(,type . ,func) (org-edna--function-for-key (car 
current-form))))
+           (pcase-let* ((`(_ . ,key)   (org-edna-break-modifier (car 
current-form)))
+                        (`(,type . ,func) (org-edna--function-for-key key)))
              (unless (and type func)
                (org-edna--syntax-error "Unrecognized Form"
-                                       from-string current-form))
+                                       from-string error-pos))
              (pcase type
                ('finder
                 (unless (memq state '(finder consideration))
@@ -272,17 +278,17 @@ the remainder of FORM after the current scope was parsed."
                ('action
                 (unless (eq action-or-condition 'action)
                   (org-edna--syntax-error "Actions aren't allowed in this 
context"
-                                          from-string current-form)))
+                                          from-string error-pos)))
                ('condition
                 (unless (eq action-or-condition 'condition)
                   (org-edna--syntax-error "Conditions aren't allowed in this 
context"
-                                          from-string current-form))))
+                                          from-string error-pos))))
              ;; Update state
              (setq state type)
              (if need-break ;; changing state
                  ;; Keep current-form on remaining-form so we have it for the
                  ;; next scope, since we didn't process it here.
-                 (setq remaining-form (cons current-form remaining-form))
+                 (setq remaining-form (cons (cons current-form error-pos) 
remaining-form))
                (push current-form final-form)))))))
     (when (and (eq state 'finder)
                (eq action-or-condition 'condition))
@@ -291,22 +297,35 @@ the remainder of FORM after the current scope was parsed."
       (push '(!done?) final-form))
     (list (nreverse final-form) remaining-form)))
 
-(defun org-edna--normalize-all-forms (form-list action-or-condition &optional 
from-string)
-  "Normalize all forms in flat form list FORM-LIST.
+(defun org-edna--normalize-forms (form-list action-or-condition end-forms 
&optional from-string)
+  "Normalize forms in flat form list FORM-LIST until one of END-FORMS is found.
 
 ACTION-OR-CONDITION is either 'action or 'condition, indicating
 which of the two types is allowed in FORM.
 
 FROM-STRING is used internally, and is non-nil if FORM was
-originally a string."
+originally a string.
+
+END-FORMS is a list of forms.  When one of them is found, stop parsing."
   (pcase-let* ((`(,final-form ,rem-form) (org-edna--normalize-sexp-form 
form-list action-or-condition from-string)))
     (setq final-form (list final-form))
-    (while rem-form
+    ;; Use car-safe to catch r-form = nil
+    (while (and rem-form (not (member (car (car-safe rem-form)) end-forms)))
       (pcase-let* ((`(,new-form ,r-form)
                     (org-edna--normalize-sexp-form rem-form 
action-or-condition from-string)))
         (setq final-form (append final-form (list new-form))
               rem-form r-form)))
-    final-form))
+    (list final-form rem-form)))
+
+(defun org-edna--normalize-all-forms (form-list action-or-condition &optional 
from-string)
+  "Normalize all forms in flat form list FORM-LIST.
+
+ACTION-OR-CONDITION is either 'action or 'condition, indicating
+which of the two types is allowed in FORM.
+
+FROM-STRING is used internally, and is non-nil if FORM was
+originally a string."
+  (car-safe (org-edna--normalize-forms form-list action-or-condition nil 
from-string)))
 
 (defun org-edna-string-form-to-sexp-form (string-form action-or-condition)
   "Parse string form STRING-FORM into an Edna sexp form.
diff --git a/packages/org-edna/org-edna.info b/packages/org-edna/org-edna.info
index 184755b..33b6708 100644
--- a/packages/org-edna/org-edna.info
+++ b/packages/org-edna/org-edna.info
@@ -107,6 +107,7 @@ Contributing
 
 Changelog
 
+* 1.0beta6: 10beta6.
 * 1.0beta5: 10beta5.
 * 1.0beta4: 10beta4.
 * 1.0beta3: 10beta3.
@@ -1510,13 +1511,28 @@ Changelog
 
 * Menu:
 
+* 1.0beta6: 10beta6.
 * 1.0beta5: 10beta5.
 * 1.0beta4: 10beta4.
 * 1.0beta3: 10beta3.
 * 1.0beta2: 10beta2.
 
 
-File: org-edna.info,  Node: 10beta5,  Next: 10beta4,  Up: Changelog
+File: org-edna.info,  Node: 10beta6,  Next: 10beta5,  Up: Changelog
+
+1.0beta6
+========
+
+Lots of parsing fixes.
+
+   • Fixed error reporting
+
+   • Fixed parsing of negations in conditions
+
+   • Fixed parsing of multiple forms inside if/then/else blocks
+
+
+File: org-edna.info,  Node: 10beta5,  Next: 10beta4,  Prev: 10beta6,  Up: 
Changelog
 
 1.0beta5
 ========
@@ -1594,71 +1610,72 @@ Big release here, with three new features.
 
 Tag Table:
 Node: Top225
-Node: Copying3672
-Node: Introduction4494
-Node: Installation and Setup5442
-Node: Basic Operation6235
-Node: Blockers8086
-Node: Triggers8372
-Node: Syntax8634
-Node: Basic Features9324
-Node: Finders9627
-Node: ancestors11392
-Node: children11986
-Node: descendants12396
-Node: file12918
-Node: first-child13667
-Node: ids13927
-Node: match14588
-Node: next-sibling15226
-Node: next-sibling-wrap15483
-Node: olp15797
-Node: org-file16209
-Node: parent16854
-Node: previous-sibling17052
-Node: previous-sibling-wrap17313
-Node: relatives17592
-Node: rest-of-siblings21213
-Node: rest-of-siblings-wrap21498
-Node: self21847
-Node: siblings22008
-Node: siblings-wrap22245
-Node: Actions22549
-Node: Scheduled/Deadline23291
-Node: TODO State26866
-Node: Archive27234
-Node: Chain Property27554
-Node: Clocking27837
-Node: Property28249
-Node: Priority30436
-Node: Tag31005
-Node: Effort31222
-Node: Advanced Features31611
-Node: Conditions31995
-Node: done32610
-Node: headings32774
-Node: todo-state33150
-Node: variable-set33406
-Node: has-property33835
-Node: re-search34104
-Node: Negating Conditions34464
-Node: Consideration34851
-Node: Conditional Forms36420
-Node: Setting the Properties39076
-Node: Extending Edna40160
-Node: Naming Conventions40650
-Node: Finders 141111
-Node: Actions 141473
-Node: Conditions 141932
-Node: Contributing42818
-Node: Bugs43369
-Node: Development43721
-Node: Documentation44874
-Node: Changelog45319
-Node: 10beta545506
-Node: 10beta445877
-Node: 10beta346130
-Node: 10beta246569
+Node: Copying3693
+Node: Introduction4515
+Node: Installation and Setup5463
+Node: Basic Operation6256
+Node: Blockers8107
+Node: Triggers8393
+Node: Syntax8655
+Node: Basic Features9345
+Node: Finders9648
+Node: ancestors11413
+Node: children12007
+Node: descendants12417
+Node: file12939
+Node: first-child13688
+Node: ids13948
+Node: match14609
+Node: next-sibling15247
+Node: next-sibling-wrap15504
+Node: olp15818
+Node: org-file16230
+Node: parent16875
+Node: previous-sibling17073
+Node: previous-sibling-wrap17334
+Node: relatives17613
+Node: rest-of-siblings21234
+Node: rest-of-siblings-wrap21519
+Node: self21868
+Node: siblings22029
+Node: siblings-wrap22266
+Node: Actions22570
+Node: Scheduled/Deadline23312
+Node: TODO State26887
+Node: Archive27255
+Node: Chain Property27575
+Node: Clocking27858
+Node: Property28270
+Node: Priority30457
+Node: Tag31026
+Node: Effort31243
+Node: Advanced Features31632
+Node: Conditions32016
+Node: done32631
+Node: headings32795
+Node: todo-state33171
+Node: variable-set33427
+Node: has-property33856
+Node: re-search34125
+Node: Negating Conditions34485
+Node: Consideration34872
+Node: Conditional Forms36441
+Node: Setting the Properties39097
+Node: Extending Edna40181
+Node: Naming Conventions40671
+Node: Finders 141132
+Node: Actions 141494
+Node: Conditions 141953
+Node: Contributing42839
+Node: Bugs43390
+Node: Development43742
+Node: Documentation44895
+Node: Changelog45340
+Node: 10beta645548
+Node: 10beta545808
+Node: 10beta446195
+Node: 10beta346448
+Node: 10beta246887
 
 End Tag Table
 
diff --git a/packages/org-edna/org-edna.org b/packages/org-edna/org-edna.org
index 936ce84..e3422de 100644
--- a/packages/org-edna/org-edna.org
+++ b/packages/org-edna/org-edna.org
@@ -1291,6 +1291,14 @@ making any changes:
 :PROPERTIES:
 :DESCRIPTION: List of changes by version
 :END:
+** 1.0beta6
+Lots of parsing fixes.
+
+- Fixed error reporting
+
+- Fixed parsing of negations in conditions
+
+- Fixed parsing of multiple forms inside if/then/else blocks
 ** 1.0beta5
 Some new forms and a new build system.
 
diff --git a/packages/org-edna/test.mk b/packages/org-edna/test.mk
index 87fe6ad..29e31e5 100644
--- a/packages/org-edna/test.mk
+++ b/packages/org-edna/test.mk
@@ -16,8 +16,8 @@
 # EDE only allows arbitrary code from an external makefile, so this is how 
we've
 # got to do testing.
 
-test:
-       $(EMACS) \
+test: compile
+       @$(EMACS) \
        $(EMACSFLAGS) \
        $(addprefix -L ,$(LOADPATH)) \
        -L "." \



reply via email to

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