diff options
| author | Dave Love | 2002-07-17 10:32:38 +0000 |
|---|---|---|
| committer | Dave Love | 2002-07-17 10:32:38 +0000 |
| commit | acb694258f097ebec7d92d26010b811a77f85228 (patch) | |
| tree | 6430660e108531e7db4951f3a2943ffbe5de9758 | |
| parent | 9f13685affe139da852d8efad5a1ccc0b76b1afe (diff) | |
| download | emacs-acb694258f097ebec7d92d26010b811a77f85228.tar.gz emacs-acb694258f097ebec7d92d26010b811a77f85228.zip | |
(ccl-command-table): Add lookup-integer,
lookup-character.
(ccl-extended-code-table): Add lookup-int-const-tbl,
lookup-char-const-tbl.
(ccl-compile-lookup-integer, ccl-compile-lookup-character)
(ccl-dump-lookup-int-const-tbl, ccl-dump-lookup-char-const-tbl):
New functions.
(define-ccl-program): Doc update.
| -rw-r--r-- | lisp/international/ccl.el | 80 |
1 files changed, 68 insertions, 12 deletions
diff --git a/lisp/international/ccl.el b/lisp/international/ccl.el index 2053b6364cb..4e8594685c3 100644 --- a/lisp/international/ccl.el +++ b/lisp/international/ccl.el | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | 3 | ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. |
| 4 | ;; Licensed to the Free Software Foundation. | 4 | ;; Licensed to the Free Software Foundation. |
| 5 | ;; Copyright (C) 2002 Free Software Foundation, Inc. | ||
| 5 | 6 | ||
| 6 | ;; Keywords: CCL, mule, multilingual, character set, coding-system | 7 | ;; Keywords: CCL, mule, multilingual, character set, coding-system |
| 7 | 8 | ||
| @@ -25,19 +26,19 @@ | |||
| 25 | ;;; Commentary: | 26 | ;;; Commentary: |
| 26 | 27 | ||
| 27 | ;; CCL (Code Conversion Language) is a simple programming language to | 28 | ;; CCL (Code Conversion Language) is a simple programming language to |
| 28 | ;; be used for various kind of code conversion. CCL program is | 29 | ;; be used for various kind of code conversion. A CCL program is |
| 29 | ;; compiled to CCL code (vector of integers) and executed by CCL | 30 | ;; compiled to CCL code (vector of integers) and executed by the CCL |
| 30 | ;; interpreter of Emacs. | 31 | ;; interpreter in Emacs. |
| 31 | ;; | 32 | ;; |
| 32 | ;; CCL is used for code conversion at process I/O and file I/O for | 33 | ;; CCL is used for code conversion at process I/O and file I/O for |
| 33 | ;; non-standard coding-system. In addition, it is used for | 34 | ;; non-standard coding-systems. In addition, it is used for |
| 34 | ;; calculating a code point of X's font from a character code. | 35 | ;; calculating code points of X fonts from character codes. |
| 35 | ;; However, since CCL is designed as a powerful programming language, | 36 | ;; However, since CCL is designed as a powerful programming language, |
| 36 | ;; it can be used for more generic calculation. For instance, | 37 | ;; it can be used for more generic calculation. For instance, |
| 37 | ;; combination of three or more arithmetic operations can be | 38 | ;; combination of three or more arithmetic operations can be |
| 38 | ;; calculated faster than Emacs Lisp. | 39 | ;; calculated faster than in Emacs Lisp. |
| 39 | ;; | 40 | ;; |
| 40 | ;; Syntax and semantics of CCL program is described in the | 41 | ;; The syntax and semantics of CCL programs are described in the |
| 41 | ;; documentation of `define-ccl-program'. | 42 | ;; documentation of `define-ccl-program'. |
| 42 | 43 | ||
| 43 | ;;; Code: | 44 | ;;; Code: |
| @@ -52,7 +53,8 @@ | |||
| 52 | read read-if read-branch write call end | 53 | read read-if read-branch write call end |
| 53 | read-multibyte-character write-multibyte-character | 54 | read-multibyte-character write-multibyte-character |
| 54 | translate-character | 55 | translate-character |
| 55 | iterate-multiple-map map-multiple map-single] | 56 | iterate-multiple-map map-multiple map-single lookup-integer |
| 57 | lookup-character] | ||
| 56 | "Vector of CCL commands (symbols).") | 58 | "Vector of CCL commands (symbols).") |
| 57 | 59 | ||
| 58 | ;; Put a property to each symbol of CCL commands for the compiler. | 60 | ;; Put a property to each symbol of CCL commands for the compiler. |
| @@ -107,6 +109,8 @@ | |||
| 107 | iterate-multiple-map | 109 | iterate-multiple-map |
| 108 | map-multiple | 110 | map-multiple |
| 109 | map-single | 111 | map-single |
| 112 | lookup-int-const-tbl | ||
| 113 | lookup-char-const-tbl | ||
| 110 | ] | 114 | ] |
| 111 | "Vector of CCL extended compiled codes (symbols).") | 115 | "Vector of CCL extended compiled codes (symbols).") |
| 112 | 116 | ||
| @@ -196,8 +200,8 @@ | |||
| 196 | 200 | ||
| 197 | ;; Embed pair of SYMBOL and PROP where (get SYMBOL PROP) should give | 201 | ;; Embed pair of SYMBOL and PROP where (get SYMBOL PROP) should give |
| 198 | ;; proper index number for SYMBOL. PROP should be | 202 | ;; proper index number for SYMBOL. PROP should be |
| 199 | ;; `translation-table-id', `code-conversion-map-id', or | 203 | ;; `translation-table-id', `translation-hash-table-id' |
| 200 | ;; `ccl-program-idx'. | 204 | ;; `code-conversion-map-id', or `ccl-program-idx'. |
| 201 | (defun ccl-embed-symbol (symbol prop) | 205 | (defun ccl-embed-symbol (symbol prop) |
| 202 | (ccl-embed-data (cons symbol prop))) | 206 | (ccl-embed-data (cons symbol prop))) |
| 203 | 207 | ||
| @@ -833,6 +837,46 @@ | |||
| 833 | (ccl-embed-extended-command 'translate-character rrr RRR Rrr)))) | 837 | (ccl-embed-extended-command 'translate-character rrr RRR Rrr)))) |
| 834 | nil) | 838 | nil) |
| 835 | 839 | ||
| 840 | ;; Compile lookup-integer | ||
| 841 | (defun ccl-compile-lookup-integer (cmd) | ||
| 842 | (if (/= (length cmd) 4) | ||
| 843 | (error "CCL: Invalid number of arguments: %s" cmd)) | ||
| 844 | (let ((Rrr (nth 1 cmd)) | ||
| 845 | (RRR (nth 2 cmd)) | ||
| 846 | (rrr (nth 3 cmd))) | ||
| 847 | (ccl-check-register RRR cmd) | ||
| 848 | (ccl-check-register rrr cmd) | ||
| 849 | (cond ((and (symbolp Rrr) (not (get Rrr 'ccl-register-number))) | ||
| 850 | (ccl-embed-extended-command 'lookup-int-const-tbl | ||
| 851 | rrr RRR 0) | ||
| 852 | (ccl-embed-symbol Rrr 'translation-hash-table-id)) | ||
| 853 | (t | ||
| 854 | (error "CCL: non-constant table: %s" cmd) | ||
| 855 | ;; not implemented: | ||
| 856 | (ccl-check-register Rrr cmd) | ||
| 857 | (ccl-embed-extended-command 'lookup-int rrr RRR 0)))) | ||
| 858 | nil) | ||
| 859 | |||
| 860 | ;; Compile lookup-character | ||
| 861 | (defun ccl-compile-lookup-character (cmd) | ||
| 862 | (if (/= (length cmd) 4) | ||
| 863 | (error "CCL: Invalid number of arguments: %s" cmd)) | ||
| 864 | (let ((Rrr (nth 1 cmd)) | ||
| 865 | (RRR (nth 2 cmd)) | ||
| 866 | (rrr (nth 3 cmd))) | ||
| 867 | (ccl-check-register RRR cmd) | ||
| 868 | (ccl-check-register rrr cmd) | ||
| 869 | (cond ((and (symbolp Rrr) (not (get Rrr 'ccl-register-number))) | ||
| 870 | (ccl-embed-extended-command 'lookup-char-const-tbl | ||
| 871 | rrr RRR 0) | ||
| 872 | (ccl-embed-symbol Rrr 'translation-hash-table-id)) | ||
| 873 | (t | ||
| 874 | (error "CCL: non-constant table: %s" cmd) | ||
| 875 | ;; not implemented: | ||
| 876 | (ccl-check-register Rrr cmd) | ||
| 877 | (ccl-embed-extended-command 'lookup-char rrr RRR 0)))) | ||
| 878 | nil) | ||
| 879 | |||
| 836 | (defun ccl-compile-iterate-multiple-map (cmd) | 880 | (defun ccl-compile-iterate-multiple-map (cmd) |
| 837 | (ccl-compile-multiple-map-function 'iterate-multiple-map cmd) | 881 | (ccl-compile-multiple-map-function 'iterate-multiple-map cmd) |
| 838 | nil) | 882 | nil) |
| @@ -905,7 +949,7 @@ | |||
| 905 | (setq args (cdr args))))) | 949 | (setq args (cdr args))))) |
| 906 | 950 | ||
| 907 | 951 | ||
| 908 | ;;; CCL dump staffs | 952 | ;;; CCL dump stuff |
| 909 | 953 | ||
| 910 | ;; To avoid byte-compiler warning. | 954 | ;; To avoid byte-compiler warning. |
| 911 | (defvar ccl-code) | 955 | (defvar ccl-code) |
| @@ -1192,6 +1236,14 @@ | |||
| 1192 | (let ((tbl (ccl-get-next-code))) | 1236 | (let ((tbl (ccl-get-next-code))) |
| 1193 | (insert (format "translation table(%S) r%d r%d\n" tbl RRR rrr)))) | 1237 | (insert (format "translation table(%S) r%d r%d\n" tbl RRR rrr)))) |
| 1194 | 1238 | ||
| 1239 | (defun ccl-dump-lookup-int-const-tbl (rrr RRR Rrr) | ||
| 1240 | (let ((tbl (ccl-get-next-code))) | ||
| 1241 | (insert (format "hash table(%S) r%d r%d\n" tbl RRR rrr)))) | ||
| 1242 | |||
| 1243 | (defun ccl-dump-lookup-char-const-tbl (rrr RRR Rrr) | ||
| 1244 | (let ((tbl (ccl-get-next-code))) | ||
| 1245 | (insert (format "hash table(%S) r%d r%d\n" tbl RRR rrr)))) | ||
| 1246 | |||
| 1195 | (defun ccl-dump-iterate-multiple-map (rrr RRR Rrr) | 1247 | (defun ccl-dump-iterate-multiple-map (rrr RRR Rrr) |
| 1196 | (let ((notbl (ccl-get-next-code)) | 1248 | (let ((notbl (ccl-get-next-code)) |
| 1197 | (i 0) id) | 1249 | (i 0) id) |
| @@ -1271,7 +1323,7 @@ CCL_BLOCK := STATEMENT | (STATEMENT [STATEMENT ...]) | |||
| 1271 | 1323 | ||
| 1272 | STATEMENT := | 1324 | STATEMENT := |
| 1273 | SET | IF | BRANCH | LOOP | REPEAT | BREAK | READ | WRITE | CALL | 1325 | SET | IF | BRANCH | LOOP | REPEAT | BREAK | READ | WRITE | CALL |
| 1274 | | TRANSLATE | END | 1326 | | TRANSLATE | MAP | LOOKUP | END |
| 1275 | 1327 | ||
| 1276 | SET := (REG = EXPRESSION) | 1328 | SET := (REG = EXPRESSION) |
| 1277 | | (REG ASSIGNMENT_OPERATOR EXPRESSION) | 1329 | | (REG ASSIGNMENT_OPERATOR EXPRESSION) |
| @@ -1438,6 +1490,10 @@ TRANSLATE := | |||
| 1438 | (translate-character REG(table) REG(charset) REG(codepoint)) | 1490 | (translate-character REG(table) REG(charset) REG(codepoint)) |
| 1439 | | (translate-character SYMBOL REG(charset) REG(codepoint)) | 1491 | | (translate-character SYMBOL REG(charset) REG(codepoint)) |
| 1440 | ;; SYMBOL must refer to a table defined by `define-translation-table'. | 1492 | ;; SYMBOL must refer to a table defined by `define-translation-table'. |
| 1493 | LOOKUP := | ||
| 1494 | (lookup-character SYMBOL REG(charset) REG(codepoint)) | ||
| 1495 | | (lookup-integer SYMBOL REG(integer)) | ||
| 1496 | ;; SYMBOL refers to a table defined by `define-hash-translation-table'. | ||
| 1441 | MAP := | 1497 | MAP := |
| 1442 | (iterate-multiple-map REG REG MAP-IDs) | 1498 | (iterate-multiple-map REG REG MAP-IDs) |
| 1443 | | (map-multiple REG REG (MAP-SET)) | 1499 | | (map-multiple REG REG (MAP-SET)) |