comparison admin/unidata/unidata-gen.el @ 94071:03be13c38b12

(unidata-prop-alist): Fix typo in description of `numeric-value'. (unidata-put-character): Fix typo in error message.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 14 Apr 2008 10:43:06 +0000
parents 948b9fc771f9
children aeac1d771ae4
comparison
equal deleted inserted replaced
94070:df7b21ec7a29 94071:03be13c38b12
38 ;; (char-code-property-register PROP FILE) 38 ;; (char-code-property-register PROP FILE)
39 ;; where PROP is a symbol representing a character property 39 ;; where PROP is a symbol representing a character property
40 ;; (name, generic-category, etc), and FILE is a name of one of 40 ;; (name, generic-category, etc), and FILE is a name of one of
41 ;; the following files. 41 ;; the following files.
42 ;; 42 ;;
43 ;; uni-name.el, uni-cat.el, uni-comb.el, uni-bidi.el 43 ;; uni-name.el, uni-category.el, uni-combining.el, uni-bidi.el,
44 ;; It contains a single form of this format: 44 ;; uni-decomposition.el, uni-decimal.el, uni-digit.el, uni-numeric.el,
45 ;; uni-mirrored.el, uni-old-name.el, uni-comment.el, uni-uppercase.el,
46 ;; uni-lowercase.el, uni-titlecase.el
47 ;; They each contain a single form of this format:
45 ;; (char-code-property-register PROP CHAR-TABLE) 48 ;; (char-code-property-register PROP CHAR-TABLE)
46 ;; where PROP is the same as above, and CHAR-TABLE is a 49 ;; where PROP is the same as above, and CHAR-TABLE is a
47 ;; char-table containing property values in a compressed format. 50 ;; char-table containing property values in a compressed format.
48 ;; 51 ;;
49 ;; When they are installed in .../lisp/international/, the file 52 ;; When they are installed in .../lisp/international/, the file
178 "Unicode numeric value (digit). 181 "Unicode numeric value (digit).
179 Property value is an integer.") 182 Property value is an integer.")
180 (numeric-value 183 (numeric-value
181 8 unidata-gen-table-symbol "uni-numeric.el" 184 8 unidata-gen-table-symbol "uni-numeric.el"
182 "Unicode numeric value (numeric). 185 "Unicode numeric value (numeric).
183 Property value is an symbol.") 186 Property value is a symbol.")
184 (mirrored 187 (mirrored
185 9 unidata-gen-table-symbol "uni-mirrored.el" 188 9 unidata-gen-table-symbol "uni-mirrored.el"
186 "Unicode bidi mirrored flag. 189 "Unicode bidi mirrored flag.
187 Property value is a symbol `Y' or `N'.") 190 Property value is a symbol `Y' or `N'.")
188 (old-name 191 (old-name
253 (aref vec (- char block-head)))))) 256 (aref vec (- char block-head))))))
254 257
255 (defun unidata-put-character (char val table) 258 (defun unidata-put-character (char val table)
256 (or (characterp val) 259 (or (characterp val)
257 (not val) 260 (not val)
258 (error "Not an character nor nil: %S" val)) 261 (error "Not a character nor nil: %S" val))
259 (let ((current-val (aref table char))) 262 (let ((current-val (aref table char)))
260 (unless (eq current-val val) 263 (unless (eq current-val val)
261 (if (stringp current-val) 264 (if (stringp current-val)
262 (funcall (char-table-extra-slot table 1) char current-val table)) 265 (funcall (char-table-extra-slot table 1) char current-val table))
263 (aset table char val)))) 266 (aset table char val))))
362 (setq this-val val)) 365 (setq this-val val))
363 (setq first-char (1+ first-char)))) 366 (setq first-char (1+ first-char))))
364 this-val)) 367 this-val))
365 ((> val 0) 368 ((> val 0)
366 (aref val-table (1- val)))))) 369 (aref val-table (1- val))))))
367 370
368 ;; Return a integer-type character property value of CHAR. VAL is the 371 ;; Return a integer-type character property value of CHAR. VAL is the
369 ;; current value of (aref TABLE CHAR). 372 ;; current value of (aref TABLE CHAR).
370 373
371 (defun unidata-get-integer (char val table) 374 (defun unidata-get-integer (char val table)
372 (let ((val-table (char-table-extra-slot table 4))) 375 (let ((val-table (char-table-extra-slot table 4)))
490 (setq str (concat str (string val-code val-code))) 493 (setq str (concat str (string val-code val-code)))
491 (setq str (concat str (string val-code))))) 494 (setq str (concat str (string val-code)))))
492 (set-char-table-range table (cons start limit) str)))))) 495 (set-char-table-range table (cons start limit) str))))))
493 496
494 (setq val-list (nreverse (cdr val-list))) 497 (setq val-list (nreverse (cdr val-list)))
495 (set-char-table-extra-slot table 0 prop) 498 (set-char-table-extra-slot table 0 prop)
496 (set-char-table-extra-slot table 4 (vconcat (mapcar 'car val-list))) 499 (set-char-table-extra-slot table 4 (vconcat (mapcar 'car val-list)))
497 table)) 500 table))
498 501
499 (defun unidata-gen-table-symbol (prop) 502 (defun unidata-gen-table-symbol (prop)
500 (let ((table (unidata-gen-table prop 503 (let ((table (unidata-gen-table prop
554 result) 557 result)
555 (when (< len1 16) 558 (when (< len1 16)
556 (while (and l1 (eq (car l1) (car l2))) 559 (while (and l1 (eq (car l1) (car l2)))
557 (setq beg (1+ beg) 560 (setq beg (1+ beg)
558 l1 (cdr l1) len1 (1- len1) l2 (cdr l2) len2 (1- len2))) 561 l1 (cdr l1) len1 (1- len1) l2 (cdr l2) len2 (1- len2)))
559 (while (and (< end len1) (< end len2) 562 (while (and (< end len1) (< end len2)
560 (eq (nth (- len1 end 1) l1) (nth (- len2 end 1) l2))) 563 (eq (nth (- len1 end 1) l1) (nth (- len2 end 1) l2)))
561 (setq end (1+ end)))) 564 (setq end (1+ end))))
562 (if (= (+ beg end) 0) 565 (if (= (+ beg end) 0)
563 (setq result (list -1)) 566 (setq result (list -1))
564 (setq result (list (+ (* beg 16) (+ beg (- len1 end)))))) 567 (setq result (list (+ (* beg 16) (+ beg (- len1 end))))))
626 629
627 ;; Return a name of CHAR. VAL is the current value of (aref TABLE 630 ;; Return a name of CHAR. VAL is the current value of (aref TABLE
628 ;; CHAR). 631 ;; CHAR).
629 632
630 (defun unidata-get-name (char val table) 633 (defun unidata-get-name (char val table)
631 (cond 634 (cond
632 ((stringp val) 635 ((stringp val)
633 (if (> (aref val 0) 0) 636 (if (> (aref val 0) 0)
634 val 637 val
635 (let* ((first-char (lsh (lsh char -7) 7)) 638 (let* ((first-char (lsh (lsh char -7) 7))
636 (word-table (aref (char-table-extra-slot table 4) 0)) 639 (word-table (aref (char-table-extra-slot table 4) 0))
657 (setq tail-list (nthcdr (% diff-head 16) last-list)) 660 (setq tail-list (nthcdr (% diff-head 16) last-list))
658 (dotimes (i (/ diff-head 16)) 661 (dotimes (i (/ diff-head 16))
659 (setq word-list (nconc word-list (list (car l))) 662 (setq word-list (nconc word-list (list (car l)))
660 l (cdr l)))))) 663 l (cdr l))))))
661 (setq word-list 664 (setq word-list
662 (nconc word-list 665 (nconc word-list
663 (list (symbol-name 666 (list (symbol-name
664 (unidata-decode-word c word-table)))) 667 (unidata-decode-word c word-table))))
665 i (1+ i)))) 668 i (1+ i))))
666 (if (or word-list tail-list) 669 (if (or word-list tail-list)
667 (aset vec idx (nconc word-list tail-list))) 670 (aset vec idx (nconc word-list tail-list)))
696 (L (/ char 588)) 699 (L (/ char 588))
697 ;; VIndex = (SIndex % NCount) * TCount 700 ;; VIndex = (SIndex % NCount) * TCount
698 (V (/ (% char 588) 28)) 701 (V (/ (% char 588) 28))
699 ;; TIndex = SIndex % TCount 702 ;; TIndex = SIndex % TCount
700 (T (% char 28))) 703 (T (% char 28)))
701 (format "HANGUL SYLLABLE %s%s%s" 704 (format "HANGUL SYLLABLE %s%s%s"
702 ;; U+110B is nil in this table. 705 ;; U+110B is nil in this table.
703 (or (aref (aref jamo-name-table 0) L) "") 706 (or (aref (aref jamo-name-table 0) L) "")
704 (aref (aref jamo-name-table 1) V) 707 (aref (aref jamo-name-table 1) V)
705 (if (= T 0) "" 708 (if (= T 0) ""
706 (aref (aref jamo-name-table 2) (1- T))))))) 709 (aref (aref jamo-name-table 2) (1- T)))))))
752 (setq tail-list (nthcdr (% diff-head 16) last-list)) 755 (setq tail-list (nthcdr (% diff-head 16) last-list))
753 (dotimes (i (/ diff-head 16)) 756 (dotimes (i (/ diff-head 16))
754 (setq word-list (nconc word-list (list (car l))) 757 (setq word-list (nconc word-list (list (car l)))
755 l (cdr l)))))) 758 l (cdr l))))))
756 (setq word-list 759 (setq word-list
757 (nconc word-list 760 (nconc word-list
758 (list (or (unidata-decode-word c word-table) c))) 761 (list (or (unidata-decode-word c word-table) c)))
759 i (1+ i)))) 762 i (1+ i))))
760 (if (or word-list tail-list) 763 (if (or word-list tail-list)
761 (aset vec idx (nconc word-list tail-list))) 764 (aset vec idx (nconc word-list tail-list)))
762 (dotimes (i 128) 765 (dotimes (i 128)
931 (dotimes (i len) 934 (dotimes (i len)
932 (setq c (aref str i)) 935 (setq c (aref str i))
933 (if (= c 32) 936 (if (= c 32)
934 (setq l (cons (intern (substring str idx i)) l) 937 (setq l (cons (intern (substring str idx i)) l)
935 idx (1+ i)) 938 idx (1+ i))
936 (if (and (= c ?-) (< idx i) 939 (if (and (= c ?-) (< idx i)
937 (< (1+ i) len) (/= (aref str (1+ i)) 32)) 940 (< (1+ i) len) (/= (aref str (1+ i)) 32))
938 (setq l (cons '- (cons (intern (substring str idx i)) l)) 941 (setq l (cons '- (cons (intern (substring str idx i)) l))
939 idx (1+ i))))) 942 idx (1+ i)))))
940 (nreverse (cons (intern (substring str idx)) l)))))) 943 (nreverse (cons (intern (substring str idx)) l))))))
941 944
983 (word-tables (char-table-extra-slot table 4))) 986 (word-tables (char-table-extra-slot table 4)))
984 (byte-compile 'unidata-get-decomposition) 987 (byte-compile 'unidata-get-decomposition)
985 (byte-compile 'unidata-put-decomposition) 988 (byte-compile 'unidata-put-decomposition)
986 (set-char-table-extra-slot table 1 989 (set-char-table-extra-slot table 1
987 (symbol-function 'unidata-get-decomposition)) 990 (symbol-function 'unidata-get-decomposition))
988 (set-char-table-extra-slot table 2 991 (set-char-table-extra-slot table 2
989 (symbol-function 'unidata-put-decomposition)) 992 (symbol-function 'unidata-put-decomposition))
990 (set-char-table-extra-slot table 4 (car word-tables)) 993 (set-char-table-extra-slot table 4 (car word-tables))
991 table)) 994 table))
992 995
993 996
1086 (defun unidata-check () 1089 (defun unidata-check ()
1087 (dolist (elt unidata-prop-alist) 1090 (dolist (elt unidata-prop-alist)
1088 (let* ((prop (car elt)) 1091 (let* ((prop (car elt))
1089 (index (unidata-prop-index prop)) 1092 (index (unidata-prop-index prop))
1090 (generator (unidata-prop-generator prop)) 1093 (generator (unidata-prop-generator prop))
1091 (table (progn 1094 (table (progn
1092 (message "Generating %S table..." prop) 1095 (message "Generating %S table..." prop)
1093 (funcall generator prop))) 1096 (funcall generator prop)))
1094 (decoder (char-table-extra-slot table 1)) 1097 (decoder (char-table-extra-slot table 1))
1095 (check #x400)) 1098 (check #x400))
1096 (dolist (e unidata-list) 1099 (dolist (e unidata-list)
1112 (setq val1 (unidata-split-decomposition val1))))) 1115 (setq val1 (unidata-split-decomposition val1)))))
1113 (when (>= char check) 1116 (when (>= char check)
1114 (message "%S %04X" prop check) 1117 (message "%S %04X" prop check)
1115 (setq check (+ check #x400))) 1118 (setq check (+ check #x400)))
1116 (or (equal val1 val2) 1119 (or (equal val1 val2)
1117 (insert (format "> %04X %S\n< %04X %S\n" 1120 (insert (format "> %04X %S\n< %04X %S\n"
1118 char val1 char val2))) 1121 char val1 char val2)))
1119 (sit-for 0))))))) 1122 (sit-for 0)))))))
1120 1123
1121 ;; The entry function. It generates files described in the header 1124 ;; The entry function. It generates files described in the header
1122 ;; comment of this file. 1125 ;; comment of this file.