aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-04-20 02:11:52 +0000
committerKenichi Handa1998-04-20 02:11:52 +0000
commit080bb33ede7b8d885d83ef09231956f00b0dfe0b (patch)
treea48b315ae2f72a34be316f98955482cafb963614
parent3bb1accb4fa10686cabcae1c090bd0042cd56547 (diff)
downloademacs-080bb33ede7b8d885d83ef09231956f00b0dfe0b.tar.gz
emacs-080bb33ede7b8d885d83ef09231956f00b0dfe0b.zip
(ccl-compile-unify-character): Inhibit
unification tables specified by integer value. (ccl-compile-translate-single-map): Likewise. (ccl-compile-multiple-map-function): Likewise. (ccl-compile-translate-multiple-map): Modified for nested tables. (ccl-dump-iterate-multiple-map): Handle the case that ID is not integer. (ccl-dump-translate-multiple-map): Likewise. (ccl-dump-translate-single-map): Likewise. (declare-ccl-program): New optional arg VECTOR. (check-ccl-program): New macro.
-rw-r--r--lisp/international/ccl.el115
1 files changed, 73 insertions, 42 deletions
diff --git a/lisp/international/ccl.el b/lisp/international/ccl.el
index 6d481f54b0d..d3514408c44 100644
--- a/lisp/international/ccl.el
+++ b/lisp/international/ccl.el
@@ -81,11 +81,15 @@
81;; | (write-multibyte-character REG(charset) REG(codepoint)) 81;; | (write-multibyte-character REG(charset) REG(codepoint))
82;; UNIFY := 82;; UNIFY :=
83;; (unify-char REG(table) REG(charset) REG(codepoint)) 83;; (unify-char REG(table) REG(charset) REG(codepoint))
84;; | (unify-char integer REG(charset) REG(codepoint))
85;; | (unify-char SYMBOL REG(charset) REG(codepoint)) 84;; | (unify-char SYMBOL REG(charset) REG(codepoint))
86;; TRANSLATE := 85;; TRANSLATE :=
87;; (iterate-multiple-map REG REG TABLE-ID TABLE-ID...) 86;; (iterate-multiple-map REG REG TABLE-IDs)
88;; | (translate-multiple-map REG REG (TABLE-ID TABLE-ID ...)(TABLE-ID TABLE-ID ...)...) 87;; | (translate-multiple-map REG REG (TABLE-SET))
88;; | (translate-single-map REG REG TABLE-ID)
89;; TABLE-IDs := TABLE-ID ...
90;; TABLE-SET := TABLE-IDs | (TABLE-IDs) TABLE-SET
91;; TABLE-ID := integer
92;;
89;; CALL := (call ccl-program-name) 93;; CALL := (call ccl-program-name)
90;; END := (end) 94;; END := (end)
91;; 95;;
@@ -884,36 +888,45 @@
884(defun ccl-compile-unify-character (cmd) 888(defun ccl-compile-unify-character (cmd)
885 (if (/= (length cmd) 4) 889 (if (/= (length cmd) 4)
886 (error "CCL: Invalid number of arguments: %s" cmd)) 890 (error "CCL: Invalid number of arguments: %s" cmd))
887 (let ((Rrr(nth 1 cmd)) 891 (let ((Rrr (nth 1 cmd))
888 (RRR (nth 2 cmd)) 892 (RRR (nth 2 cmd))
889 (rrr (nth 3 cmd))) 893 (rrr (nth 3 cmd)))
890 (ccl-check-register rrr cmd) 894 (ccl-check-register rrr cmd)
891 (ccl-check-register RRR cmd) 895 (ccl-check-register RRR cmd)
892 (cond ((integerp Rrr) 896 (cond ((symbolp Rrr)
897 (if (not (get Rrr 'unification-table))
898 (error "CCL: Invalid unification-table %s in %s" Rrr cmd))
893 (ccl-embed-extended-command 'unify-character-const-tbl rrr RRR 0) 899 (ccl-embed-extended-command 'unify-character-const-tbl rrr RRR 0)
894 (ccl-embed-data Rrr)) 900 (ccl-embed-data Rrr))
895 ((symbolp Rrr)
896 (ccl-embed-extended-command 'unify-character-const-tbl rrr RRR 0)
897 (ccl-embed-data (get Rrr 'unification-table-id)))
898 (t 901 (t
899 (ccl-check-register Rrr cmd) 902 (ccl-check-register Rrr cmd)
900 (ccl-embed-extended-command 'unify-character rrr RRR 0))))) 903 (ccl-embed-extended-command 'unify-character rrr RRR Rrr)))))
901 904
902(defun ccl-compile-iterate-multiple-map (cmd) 905(defun ccl-compile-iterate-multiple-map (cmd)
903 (ccl-compile-multiple-map-function 'iterate-multiple-map cmd)) 906 (ccl-compile-multiple-map-function 'iterate-multiple-map cmd))
904 907
905(defun ccl-compile-translate-multiple-map (cmd) 908(defun ccl-compile-translate-multiple-map (cmd)
906 (if (< (length cmd) 4) 909 (if (/= (length cmd) 4)
907 (error "CCL: Invalid number of arguments: %s" cmd)) 910 (error "CCL: Invalid number of arguments: %s" cmd))
908 (let ((itables (nthcdr 3 cmd)) 911 (let ((func '(lambda (arg mp)
909 itable arg) 912 (let ((len 0) result add)
910 (while (setq itable (car itables)) 913 (while arg
911 (setq arg (append arg '(-1))) 914 (if (consp (car arg))
912 (if (not (consp itable)) 915 (setq add (funcall func (car arg) t)
913 (error "CCL: Invalid argument: %s" itable)) 916 result (append result add)
914 (setq arg (append arg itable)) 917 add (+ (-(car add)) 1))
915 (setq itables (cdr itables))) 918 (setq result
916 (setq arg (append (list (nth 0 cmd) (nth 1 cmd) (nth 2 cmd)) (cdr arg))) 919 (append result
920 (list (car arg)))
921 add 1))
922 (setq arg (cdr arg)
923 len (+ len add)))
924 (if mp
925 (cons (- len) result)
926 result))))
927 arg)
928 (setq arg (append (list (nth 0 cmd) (nth 1 cmd) (nth 2 cmd))
929 (funcall func (nth 3 cmd) nil)))
917 (ccl-compile-multiple-map-function 'translate-multiple-map arg))) 930 (ccl-compile-multiple-map-function 'translate-multiple-map arg)))
918 931
919(defun ccl-compile-translate-single-map (cmd) 932(defun ccl-compile-translate-single-map (cmd)
@@ -926,15 +939,12 @@
926 (ccl-check-register rrr cmd) 939 (ccl-check-register rrr cmd)
927 (ccl-check-register RRR cmd) 940 (ccl-check-register RRR cmd)
928 (ccl-embed-extended-command 'translate-single-map rrr RRR 0) 941 (ccl-embed-extended-command 'translate-single-map rrr RRR 0)
929 (cond ((integerp table) 942 (cond ((symbolp table)
930 (ccl-embed-data table)) 943 (if (get table 'ccl-translation-table)
931 ((symbolp table) 944 (ccl-embed-data table)
932 (setq id (get table 'ccl-translation-table-id)) 945 (error "CCL: Invalid table: %s" table)))
933 (if (numberp id) 946 (t
934 (ccl-embed-data (get id 'ccl-translation-table-id)) 947 (error "CCL: Invalid type of arguments: %s" cmd)))))
935 (error "CCL: Invalid table: %s" table)))
936 (t
937 (error "CCL: Invalid type of arguments: %s" cmd)))))
938 948
939(defun ccl-compile-multiple-map-function (command cmd) 949(defun ccl-compile-multiple-map-function (command cmd)
940 (if (< (length cmd) 4) 950 (if (< (length cmd) 4)
@@ -942,24 +952,24 @@
942 (let ((RRR (nth 1 cmd)) 952 (let ((RRR (nth 1 cmd))
943 (rrr (nth 2 cmd)) 953 (rrr (nth 2 cmd))
944 (args (nthcdr 3 cmd)) 954 (args (nthcdr 3 cmd))
945 table id) 955 table)
946 (ccl-check-register rrr cmd) 956 (ccl-check-register rrr cmd)
947 (ccl-check-register RRR cmd) 957 (ccl-check-register RRR cmd)
948 (ccl-embed-extended-command command rrr RRR 0) 958 (ccl-embed-extended-command command rrr RRR 0)
949 (ccl-embed-data (length args)) 959 (ccl-embed-data (length args))
950 (while args 960 (while args
951 (setq table (car args)) 961 (setq table (car args))
952 (cond ((integerp table) 962 (cond ((symbolp table)
953 (ccl-embed-data table)) 963 (if (get table 'ccl-translation-table)
954 ((symbolp table) 964 (ccl-embed-data table)
955 (setq id (get table 'ccl-translation-table-id))
956 (if (numberp id)
957 (ccl-embed-data id)
958 (error "CCL: Invalid table: %s" table))) 965 (error "CCL: Invalid table: %s" table)))
966 ((numberp table)
967 (ccl-embed-data table))
959 (t 968 (t
960 (error "CCL: Invalid type of arguments: %s" cmd))) 969 (error "CCL: Invalid type of arguments: %s" cmd)))
961 (setq args (cdr args))))) 970 (setq args (cdr args)))))
962 971
972
963;;; CCL dump staffs 973;;; CCL dump staffs
964 974
965;; To avoid byte-compiler warning. 975;; To avoid byte-compiler warning.
@@ -1254,7 +1264,7 @@
1254 (insert (format "\tnumber of tables is %d .\n\t [" notbl)) 1264 (insert (format "\tnumber of tables is %d .\n\t [" notbl))
1255 (while (< i notbl) 1265 (while (< i notbl)
1256 (setq id (ccl-get-next-code)) 1266 (setq id (ccl-get-next-code))
1257 (insert (format "%d " id)) 1267 (insert (format "%S" id))
1258 (setq i (1+ i))) 1268 (setq i (1+ i)))
1259 (insert "]\n"))) 1269 (insert "]\n")))
1260 1270
@@ -1267,26 +1277,29 @@
1267 (setq id (ccl-get-next-code)) 1277 (setq id (ccl-get-next-code))
1268 (if (= id -1) 1278 (if (= id -1)
1269 (insert "]\n\t [") 1279 (insert "]\n\t [")
1270 (insert (format "%d " id))) 1280 (insert (format "%S " id)))
1271 (setq i (1+ i))) 1281 (setq i (1+ i)))
1272 (insert "]\n"))) 1282 (insert "]\n")))
1273 1283
1274(defun ccl-dump-translate-single-map (rrr RRR Rrr) 1284(defun ccl-dump-translate-single-map (rrr RRR Rrr)
1275 (let ((id (ccl-get-next-code))) 1285 (let ((id (ccl-get-next-code)))
1276 (insert (format "translate-single-map r%d r%d table(%d)\n" RRR rrr id)))) 1286 (insert (format "translate-single-map r%d r%d table(%S)\n" RRR rrr id))))
1277
1278 1287
1288
1279;; CCL emulation staffs 1289;; CCL emulation staffs
1280 1290
1281;; Not yet implemented. 1291;; Not yet implemented.
1282 1292
1293;; Auto-loaded functions.
1294
1283;;;###autoload 1295;;;###autoload
1284(defmacro declare-ccl-program (name) 1296(defmacro declare-ccl-program (name &optional vector)
1285 "Declare NAME as a name of CCL program. 1297 "Declare NAME as a name of CCL program.
1286 1298
1287To compile a CCL program which calls another CCL program not yet 1299To compile a CCL program which calls another CCL program not yet
1288defined, it must be declared as a CCL program in advance." 1300defined, it must be declared as a CCL program in advance.
1289 `(put ',name 'ccl-program-idx (register-ccl-program ',name nil))) 1301Optional arg VECTOR is a compiled CCL code of the CCL program."
1302 `(put ',name 'ccl-program-idx (register-ccl-program ',name ,vector)))
1290 1303
1291;;;###autoload 1304;;;###autoload
1292(defmacro define-ccl-program (name ccl-program &optional doc) 1305(defmacro define-ccl-program (name ccl-program &optional doc)
@@ -1299,6 +1312,24 @@ The compiled code is a vector of integers."
1299 nil)) 1312 nil))
1300 1313
1301;;;###autoload 1314;;;###autoload
1315(defmacro check-ccl-program (ccl-program &optional name)
1316 "Check validity of CCL-PROGRAM.
1317If CCL-PROGRAM is a symbol denoting a valid CCL program, return
1318CCL-PROGRAM, else return nil.
1319If CCL-PROGRAM is a vector and optional arg NAME (symbol) is supplied,
1320register CCL-PROGRAM by name NAME, and return NAME."
1321 `(let ((result ,ccl-program))
1322 (cond ((symbolp ,ccl-program)
1323 (or (numberp (get ,ccl-program 'ccl-program-idx))
1324 (setq result nil)))
1325 ((vectorp ,ccl-program)
1326 (setq result ,name)
1327 (register-ccl-program result ,ccl-program))
1328 (t
1329 (setq result nil)))
1330 result))
1331
1332;;;###autoload
1302(defun ccl-execute-with-args (ccl-prog &rest args) 1333(defun ccl-execute-with-args (ccl-prog &rest args)
1303 "Execute CCL-PROGRAM with registers initialized by the remaining args. 1334 "Execute CCL-PROGRAM with registers initialized by the remaining args.
1304The return value is a vector of resulting CCL registeres." 1335The return value is a vector of resulting CCL registeres."