emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r100427: * emacs-lisp/smie.el (smie-s


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100427: * emacs-lisp/smie.el (smie-set-prec2tab): Check override before use.
Date: Mon, 24 May 2010 22:32:40 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100427
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2010-05-24 22:32:40 -0400
message:
  * emacs-lisp/smie.el (smie-set-prec2tab): Check override before use.
  (smie-merge-prec2s): Pass the tables as separate args.
  (smie-bnf-precedence-table): Adjust call accordingly.
  (smie-prec2-levels): Set levels at the end.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/smie.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-05-25 02:11:08 +0000
+++ b/lisp/ChangeLog    2010-05-25 02:32:40 +0000
@@ -1,5 +1,10 @@
 2010-05-25  Stefan Monnier  <address@hidden>
 
+       * emacs-lisp/smie.el (smie-set-prec2tab): Check override before use.
+       (smie-merge-prec2s): Pass the tables as separate args.
+       (smie-bnf-precedence-table): Adjust call accordingly.
+       (smie-prec2-levels): Set levels at the end.
+
        Replace Lisp calls to delete-backward-char by delete-char.
        * bs.el, expand.el, ido.el, image-dired.el, lpr.el, pcomplete.el,
        skeleton.el, term.el, time.el, wid-edit.el, woman.el,

=== modified file 'lisp/emacs-lisp/smie.el'
--- a/lisp/emacs-lisp/smie.el   2010-05-18 19:24:24 +0000
+++ b/lisp/emacs-lisp/smie.el   2010-05-25 02:32:40 +0000
@@ -72,7 +72,7 @@
   (let* ((key (cons x y))
          (old (gethash key table)))
     (if (and old (not (eq old val)))
-        (if (gethash key override)
+        (if (and override (gethash key override))
             ;; FIXME: The override is meant to resolve ambiguities,
             ;; but it also hides real conflicts.  It would be great to
             ;; be able to distinguish the two cases so that overrides
@@ -104,7 +104,7 @@
                 (smie-set-prec2tab prec2-table other-op op op1)))))))
     prec2-table))
 
-(defun smie-merge-prec2s (tables)
+(defun smie-merge-prec2s (&rest tables)
   (if (null (cdr tables))
       (car tables)
     (let ((prec2 (make-hash-table :test 'equal)))
@@ -121,8 +121,8 @@
         (first-nts-table ())
         (last-nts-table ())
         (prec2 (make-hash-table :test 'equal))
-        (override (smie-merge-prec2s
-                   (mapcar 'smie-precs-precedence-table precs)))
+        (override (apply 'smie-merge-prec2s
+                         (mapcar 'smie-precs-precedence-table precs)))
         again)
     (dolist (rules bnf)
       (let ((nt (car rules))
@@ -234,7 +234,7 @@
               (to (cdar eqs)))
           (setq eqs (cdr eqs))
           (if (eq to from)
-              (debug)                   ;Can it happen?
+              nil                   ;Nothing to do.
             (dolist (other-eq eqs)
               (if (eq from (cdr other-eq)) (setcdr other-eq to))
               (when (eq from (car other-eq))
@@ -271,16 +271,20 @@
         (incf i 10))
       ;; Propagate equalities back to their source.
       (dolist (eq (nreverse eqs))
-        (assert (null (caar eq)))
+        (assert (or (null (caar eq)) (eq (car eq) (cdr eq))))
         (setcar (car eq) (cadr eq)))
       ;; Finally, fill in the remaining vars (which only appeared on the
       ;; right side of the < constraints).
-      ;; Tho leaving them at nil is not a bad choice, since it makes
-      ;; it clear that these don't bind at all.
-      ;; (dolist (x table)
-      ;;   (unless (nth 1 x) (setf (nth 1 x) i))
-      ;;   (unless (nth 2 x) (setf (nth 2 x) i)))
-      )
+      (dolist (x table)
+        ;; When both sides are nil, it means this operator binds very
+        ;; very tight, but it's still just an operator, so we give it
+        ;; the highest precedence.
+        ;; OTOH if only one side is nil, it usually means it's like an
+        ;; open-paren, which is very important for indentation purposes,
+        ;; so we keep it nil, to make it easier to recognize.
+        (unless (or (nth 1 x) (nth 2 x))
+          (setf (nth 1 x) i)
+          (setf (nth 2 x) i))))
     table))
 
 ;;; Parsing using a precedence level table.


reply via email to

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