[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lex d5f1594 3/7: * lex.el: Compatibility fix
From: |
Stefan Monnier |
Subject: |
[elpa] externals/lex d5f1594 3/7: * lex.el: Compatibility fix |
Date: |
Tue, 1 Dec 2020 16:18:10 -0500 (EST) |
branch: externals/lex
commit d5f159472f2e08f3d39d8cff6a91842d4caf8469
Author: Leo Liu <sdl.web@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>
* lex.el: Compatibility fix
---
lex.el | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/lex.el b/lex.el
index e4b3409..494cefa 100644
--- a/lex.el
+++ b/lex.el
@@ -183,6 +183,23 @@
(eval-when-compile (require 'cl-lib))
+(eval-and-compile
+ (unless (fboundp 'case-table-get-table)
+ ;; Copied from 24.4
+ (defun case-table-get-table (case-table table)
+ "Return the TABLE of CASE-TABLE.
+TABLE can be `down', `up', `eqv' or `canon'."
+ (let ((slot-nb (cdr (assq table '((up . 0) (canon . 1) (eqv . 2))))))
+ (or (if (eq table 'down) case-table)
+ (char-table-extra-slot case-table slot-nb)
+ (let ((old (standard-case-table)))
+ (unwind-protect
+ (progn
+ (set-standard-case-table case-table)
+ (char-table-extra-slot case-table slot-nb))
+ (or (eq case-table old)
+ (set-standard-case-table old)))))))))
+
(defun copy-char-table (ct1)
(let* ((subtype (char-table-subtype ct1))
(ct2 (make-char-table subtype)))
@@ -269,7 +286,7 @@
(if (memq x l) (progn (debug) nil)
(setq hash (+ hash (sxhash x))))))
hash)))
-
+
(defun lex--flatten-state (state)
(cl-assert (memq (car state) '(and or orelse)))
@@ -446,7 +463,7 @@
(defun lex--merge-and-join (lex)
(lex--merge-2 'and lex lex))
-
+
(defun lex--merge (&rest state)
(cl-assert (memq (car state) '(and or orelse)))
@@ -545,7 +562,7 @@ or (check (not (PREDICATE . ARG))).")
(not (eq tmp char)))
(push tmp chars))
(if chars (cons char chars)))))
-
+
;; For convenience we use lex itself to tokenize charset strings, so we
;; define it in another file.
(autoload 'lex--parse-charset "lex-parse-re")
@@ -666,7 +683,7 @@ or (check (not (PREDICATE . ARG))).")
(setcar newstate (if (memq (car re) '(*\?)) 'orelse 'or))
(push newstate lex--states)
newstate))
-
+
((or `string-end `eos `eot `buffer-end `eob)
`(check (lex--match-eobp) ,state))
((or `string-start `bos `bot `buffer-start `bob)
@@ -691,7 +708,7 @@ or (check (not (PREDICATE . ARG))).")
(`not-category `(check (lex--match-category
. ,(lex--compile-category (cadr re)))
nil . ,(lex--nfa 'anything state)))
-
+
;; `rx' accepts char-classes directly as regexps. Let's reluctantly
;; do the same.
((or `digit `numeric `num `control `cntrl `hex-digit `hex `xdigit `blank
@@ -756,7 +773,7 @@ or (check (not (PREDICATE . ARG))).")
;; `rx' defined `and' as `sequence', but we may want to define it
;; as intersection instead.
(error "`and' is deprecated, use `seq', `:', or `sequence' instead"))
-
+
((or `1+ `one-or-more `+ `+\?)
(lex--nfa `(seq (seq ,@(cdr re))
(,(if (memq (car re) '(+\?)) '*\? '0+) ,@(cdr re)))
@@ -856,7 +873,7 @@ or (check (not (PREDICATE . ARG))).")
(setcar newstate (car res))
(setcdr newstate (cdr res))
newstate)))))
-
+
(defun lex-negate (nfa state)
"Concatenate the negation of NFA with STATE.
Returns a new NFA."
@@ -919,7 +936,7 @@ Returns a new NFA."
(lex--dfa-wrapper
(lambda ()
(lex--nfa '(*\? (char not)) match-dfa))))
-
+
(defun lex--terminate-if (new old)
(cond
@@ -1163,7 +1180,7 @@ state of the engine at STOP, which can be passed back to
;; so it can be correctly used to continue the match with a different
;; content than what's after `stop'.
(nconc match lastlex)))
-
+
(defun lex-match-string-first (lex string &optional start stop)
"Match LEX against STRING between START and STOP.
Return a triplet (VALUE ENDPOS . LEXER) where VALUE is the
- [elpa] branch externals/lex created (now a25aef6), Stefan Monnier, 2020/12/01
- [elpa] externals/lex 02a8843 1/7: New package lex.el., Stefan Monnier, 2020/12/01
- [elpa] externals/lex d5f1594 3/7: * lex.el: Compatibility fix,
Stefan Monnier <=
- [elpa] externals/lex e9faad4 4/7: Only keep the strictly necessary *-pkg.el files, Stefan Monnier, 2020/12/01
- [elpa] externals/lex 5483ed3 5/7: * packages/lex/lex.el: Use lexical-binding., Stefan Monnier, 2020/12/01
- [elpa] externals/lex fe3a98b 2/7: * packages/lex/lex-parse-re.el: New file, extracted from lex.el., Stefan Monnier, 2020/12/01
- [elpa] externals/lex cd89324 6/7: * packages/gnome-c-style/gnome-c-tests.el: Add copyright blurb, Stefan Monnier, 2020/12/01
- [elpa] externals/lex a25aef6 7/7: * .gitignore: New file, Stefan Monnier, 2020/12/01