diff options
| author | Stefan Monnier | 2015-10-29 10:35:08 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2015-10-29 10:35:08 -0400 |
| commit | be81cc2707e1f7c6ae6e86c4df548356c44ff06c (patch) | |
| tree | 14cc3d371f360b735339d11078b6baf0c758cad3 | |
| parent | aa1c4ae271733cf7dc64918b570bab4034488fa1 (diff) | |
| download | emacs-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.el | 8 |
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. |
| 175 | PRECS should be a list, sorted by precedence (e.g. \"+\" will | 174 | PRECS should be a list, sorted by precedence (e.g. \"+\" will |
| 176 | come before \"*\"), of elements of the form \(left OP ...) | 175 | come before \"*\"), of elements of the form \(left OP ...) |
| 177 | or (right OP ...) or (nonassoc OP ...) or (assoc OP ...). All operators in | 176 | or (right OP ...) or (nonassoc OP ...) or (assoc OP ...). All operators in |
| 178 | one of those elements share the same precedence level and associativity." | 177 | one 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. |
| 215 | BNF is a list of nonterminal definitions of the form: | 214 | BNF 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 | |||
| 232 | be either: | 231 | be 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. |
| 509 | PREC2 is a table as returned by `smie-precs->prec2' or | 508 | PREC2 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 |