aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2015-10-29 10:35:08 -0400
committerStefan Monnier2015-10-29 10:35:08 -0400
commitbe81cc2707e1f7c6ae6e86c4df548356c44ff06c (patch)
tree14cc3d371f360b735339d11078b6baf0c758cad3
parentaa1c4ae271733cf7dc64918b570bab4034488fa1 (diff)
downloademacs-be81cc2707e1f7c6ae6e86c4df548356c44ff06c.tar.gz
emacs-be81cc2707e1f7c6ae6e86c4df548356c44ff06c.zip
* lisp/emacs-lisp/smie.el: Use `declare' for `pure'
(smie-precs->prec2, smie-merge-prec2s, smie-bnf->prec2, smie-prec2->grammar): Use `declare'.
-rw-r--r--lisp/emacs-lisp/smie.el8
1 files changed, 4 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index f305025f215..738bdddcddf 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -169,13 +169,13 @@
169 (cl-incf smie-warning-count)) 169 (cl-incf smie-warning-count))
170 (puthash key val table)))) 170 (puthash key val table))))
171 171
172(put 'smie-precs->prec2 'pure t)
173(defun smie-precs->prec2 (precs) 172(defun smie-precs->prec2 (precs)
174 "Compute a 2D precedence table from a list of precedences. 173 "Compute a 2D precedence table from a list of precedences.
175PRECS should be a list, sorted by precedence (e.g. \"+\" will 174PRECS should be a list, sorted by precedence (e.g. \"+\" will
176come before \"*\"), of elements of the form \(left OP ...) 175come before \"*\"), of elements of the form \(left OP ...)
177or (right OP ...) or (nonassoc OP ...) or (assoc OP ...). All operators in 176or (right OP ...) or (nonassoc OP ...) or (assoc OP ...). All operators in
178one of those elements share the same precedence level and associativity." 177one of those elements share the same precedence level and associativity."
178 (declare (pure t))
179 (let ((prec2-table (make-hash-table :test 'equal))) 179 (let ((prec2-table (make-hash-table :test 'equal)))
180 (dolist (prec precs) 180 (dolist (prec precs)
181 (dolist (op (cdr prec)) 181 (dolist (op (cdr prec))
@@ -193,8 +193,8 @@ one of those elements share the same precedence level and associativity."
193 (smie-set-prec2tab prec2-table other-op op op1))))))) 193 (smie-set-prec2tab prec2-table other-op op op1)))))))
194 prec2-table)) 194 prec2-table))
195 195
196(put 'smie-merge-prec2s 'pure t)
197(defun smie-merge-prec2s (&rest tables) 196(defun smie-merge-prec2s (&rest tables)
197 (declare (pure t))
198 (if (null (cdr tables)) 198 (if (null (cdr tables))
199 (car tables) 199 (car tables)
200 (let ((prec2 (make-hash-table :test 'equal))) 200 (let ((prec2 (make-hash-table :test 'equal)))
@@ -209,7 +209,6 @@ one of those elements share the same precedence level and associativity."
209 table)) 209 table))
210 prec2))) 210 prec2)))
211 211
212(put 'smie-bnf->prec2 'pure t)
213(defun smie-bnf->prec2 (bnf &rest resolvers) 212(defun smie-bnf->prec2 (bnf &rest resolvers)
214 "Convert the BNF grammar into a prec2 table. 213 "Convert the BNF grammar into a prec2 table.
215BNF is a list of nonterminal definitions of the form: 214BNF is a list of nonterminal definitions of the form:
@@ -232,6 +231,7 @@ Conflicts can be resolved via RESOLVERS, which is a list of elements that can
232be either: 231be either:
233- a precs table (see `smie-precs->prec2') to resolve conflicting constraints, 232- a precs table (see `smie-precs->prec2') to resolve conflicting constraints,
234- a constraint (T1 REL T2) where REL is one of = < or >." 233- a constraint (T1 REL T2) where REL is one of = < or >."
234 (declare (pure t))
235 ;; FIXME: Add repetition operator like (repeat <separator> <elems>). 235 ;; FIXME: Add repetition operator like (repeat <separator> <elems>).
236 ;; Maybe also add (or <elem1> <elem2>...) for things like 236 ;; Maybe also add (or <elem1> <elem2>...) for things like
237 ;; (exp (exp (or "+" "*" "=" ..) exp)). 237 ;; (exp (exp (or "+" "*" "=" ..) exp)).
@@ -503,11 +503,11 @@ CSTS is a list of pairs representing arcs in a graph."
503;; (t (cl-assert (eq v '=)))))))) 503;; (t (cl-assert (eq v '=))))))))
504;; prec2)) 504;; prec2))
505 505
506(put 'smie-prec2->grammar 'pure t)
507(defun smie-prec2->grammar (prec2) 506(defun smie-prec2->grammar (prec2)
508 "Take a 2D precedence table and turn it into an alist of precedence levels. 507 "Take a 2D precedence table and turn it into an alist of precedence levels.
509PREC2 is a table as returned by `smie-precs->prec2' or 508PREC2 is a table as returned by `smie-precs->prec2' or
510`smie-bnf->prec2'." 509`smie-bnf->prec2'."
510 (declare (pure t))
511 ;; For each operator, we create two "variables" (corresponding to 511 ;; For each operator, we create two "variables" (corresponding to
512 ;; the left and right precedence level), which are represented by 512 ;; the left and right precedence level), which are represented by
513 ;; cons cells. Those are the very cons cells that appear in the 513 ;; cons cells. Those are the very cons cells that appear in the