Mercurial > emacs
annotate lisp/international/ccl.el @ 55469:df6db683f4f1
Fix last change.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Sun, 09 May 2004 15:39:00 +0000 |
parents | 74d57e5bfed4 |
children | f2f5948989a5 |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17297
diff
changeset
|
1 ;;; ccl.el --- CCL (Code Conversion Language) compiler |
17052 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
17315
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
5 ;; Copyright (C) 2002 Free Software Foundation, Inc. |
17052 | 6 |
7 ;; Keywords: CCL, mule, multilingual, character set, coding-system | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
17071 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
17052 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; CCL (Code Conversion Language) is a simple programming language to | |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
29 ;; be used for various kind of code conversion. A CCL program is |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
30 ;; compiled to CCL code (vector of integers) and executed by the CCL |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
31 ;; interpreter in Emacs. |
17052 | 32 ;; |
33 ;; CCL is used for code conversion at process I/O and file I/O for | |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
34 ;; non-standard coding-systems. In addition, it is used for |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
35 ;; calculating code points of X fonts from character codes. |
17052 | 36 ;; However, since CCL is designed as a powerful programming language, |
37 ;; it can be used for more generic calculation. For instance, | |
38 ;; combination of three or more arithmetic operations can be | |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
39 ;; calculated faster than in Emacs Lisp. |
17052 | 40 ;; |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
41 ;; The syntax and semantics of CCL programs are described in the |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
42 ;; documentation of `define-ccl-program'. |
17052 | 43 |
44 ;;; Code: | |
45 | |
21645 | 46 (defgroup ccl nil |
47 "CCL (Code Conversion Language) compiler." | |
48 :prefix "ccl-" | |
49 :group 'i18n) | |
50 | |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
51 (defconst ccl-command-table |
17052 | 52 [if branch loop break repeat write-repeat write-read-repeat |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
53 read read-if read-branch write call end |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
54 read-multibyte-character write-multibyte-character |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
55 translate-character |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
56 iterate-multiple-map map-multiple map-single lookup-integer |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
57 lookup-character] |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
58 "Vector of CCL commands (symbols).") |
17052 | 59 |
60 ;; Put a property to each symbol of CCL commands for the compiler. | |
61 (let (op (i 0) (len (length ccl-command-table))) | |
62 (while (< i len) | |
63 (setq op (aref ccl-command-table i)) | |
64 (put op 'ccl-compile-function (intern (format "ccl-compile-%s" op))) | |
65 (setq i (1+ i)))) | |
66 | |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
67 (defconst ccl-code-table |
17052 | 68 [set-register |
69 set-short-const | |
70 set-const | |
71 set-array | |
72 jump | |
73 jump-cond | |
74 write-register-jump | |
75 write-register-read-jump | |
76 write-const-jump | |
77 write-const-read-jump | |
78 write-string-jump | |
79 write-array-read-jump | |
80 read-jump | |
81 branch | |
82 read-register | |
83 write-expr-const | |
84 read-branch | |
85 write-register | |
86 write-expr-register | |
87 call | |
88 write-const-string | |
89 write-array | |
90 end | |
91 set-assign-expr-const | |
92 set-assign-expr-register | |
93 set-expr-const | |
94 set-expr-register | |
95 jump-cond-expr-const | |
96 jump-cond-expr-register | |
97 read-jump-cond-expr-const | |
98 read-jump-cond-expr-register | |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
99 ex-cmd |
17052 | 100 ] |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
101 "Vector of CCL compiled codes (symbols).") |
17052 | 102 |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
103 (defconst ccl-extended-code-table |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
104 [read-multibyte-character |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
105 write-multibyte-character |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
106 translate-character |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
107 translate-character-const-tbl |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
108 nil nil nil nil nil nil nil nil nil nil nil nil ; 0x04-0x0f |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
109 iterate-multiple-map |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
110 map-multiple |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
111 map-single |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
112 lookup-int-const-tbl |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
113 lookup-char-const-tbl |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
114 ] |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
115 "Vector of CCL extended compiled codes (symbols).") |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
116 |
17052 | 117 ;; Put a property to each symbol of CCL codes for the disassembler. |
118 (let (code (i 0) (len (length ccl-code-table))) | |
119 (while (< i len) | |
120 (setq code (aref ccl-code-table i)) | |
121 (put code 'ccl-code i) | |
122 (put code 'ccl-dump-function (intern (format "ccl-dump-%s" code))) | |
123 (setq i (1+ i)))) | |
124 | |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
125 (let (code (i 0) (len (length ccl-extended-code-table))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
126 (while (< i len) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
127 (setq code (aref ccl-extended-code-table i)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
128 (if code |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
129 (progn |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
130 (put code 'ccl-ex-code i) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
131 (put code 'ccl-dump-function (intern (format "ccl-dump-%s" code))))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
132 (setq i (1+ i)))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
133 |
17052 | 134 (defconst ccl-jump-code-list |
135 '(jump jump-cond write-register-jump write-register-read-jump | |
136 write-const-jump write-const-read-jump write-string-jump | |
137 write-array-read-jump read-jump)) | |
138 | |
139 ;; Put a property `jump-flag' to each CCL code which execute jump in | |
140 ;; some way. | |
141 (let ((l ccl-jump-code-list)) | |
142 (while l | |
143 (put (car l) 'jump-flag t) | |
144 (setq l (cdr l)))) | |
145 | |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
146 (defconst ccl-register-table |
17052 | 147 [r0 r1 r2 r3 r4 r5 r6 r7] |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
148 "Vector of CCL registers (symbols).") |
17052 | 149 |
150 ;; Put a property to indicate register number to each symbol of CCL. | |
151 ;; registers. | |
152 (let (reg (i 0) (len (length ccl-register-table))) | |
153 (while (< i len) | |
154 (setq reg (aref ccl-register-table i)) | |
155 (put reg 'ccl-register-number i) | |
156 (setq i (1+ i)))) | |
157 | |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
158 (defconst ccl-arith-table |
17052 | 159 [+ - * / % & | ^ << >> <8 >8 // nil nil nil |
160 < > == <= >= != de-sjis en-sjis] | |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
161 "Vector of CCL arithmetic/logical operators (symbols).") |
17052 | 162 |
163 ;; Put a property to each symbol of CCL operators for the compiler. | |
164 (let (arith (i 0) (len (length ccl-arith-table))) | |
165 (while (< i len) | |
166 (setq arith (aref ccl-arith-table i)) | |
167 (if arith (put arith 'ccl-arith-code i)) | |
168 (setq i (1+ i)))) | |
169 | |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
170 (defconst ccl-assign-arith-table |
17052 | 171 [+= -= *= /= %= &= |= ^= <<= >>= <8= >8= //=] |
21977
fe7ef7cd642a
Cancel the previous change for
Kenichi Handa <handa@m17n.org>
parents:
21669
diff
changeset
|
172 "Vector of CCL assignment operators (symbols).") |
17052 | 173 |
174 ;; Put a property to each symbol of CCL assignment operators for the compiler. | |
175 (let (arith (i 0) (len (length ccl-assign-arith-table))) | |
176 (while (< i len) | |
177 (setq arith (aref ccl-assign-arith-table i)) | |
178 (put arith 'ccl-self-arith-code i) | |
179 (setq i (1+ i)))) | |
180 | |
181 (defvar ccl-program-vector nil | |
182 "Working vector of CCL codes produced by CCL compiler.") | |
183 (defvar ccl-current-ic 0 | |
184 "The current index for `ccl-program-vector'.") | |
185 | |
186 ;; Embed integer DATA in `ccl-program-vector' at `ccl-current-ic' and | |
187 ;; increment it. If IC is specified, embed DATA at IC. | |
188 (defun ccl-embed-data (data &optional ic) | |
189 (if ic | |
190 (aset ccl-program-vector ic data) | |
30705
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
191 (let ((len (length ccl-program-vector))) |
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
192 (if (>= ccl-current-ic len) |
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
193 (let ((new (make-vector (* len 2) nil))) |
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
194 (while (> len 0) |
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
195 (setq len (1- len)) |
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
196 (aset new len (aref ccl-program-vector len))) |
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
197 (setq ccl-program-vector new)))) |
17052 | 198 (aset ccl-program-vector ccl-current-ic data) |
199 (setq ccl-current-ic (1+ ccl-current-ic)))) | |
200 | |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
201 ;; Embed pair of SYMBOL and PROP where (get SYMBOL PROP) should give |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
202 ;; proper index number for SYMBOL. PROP should be |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
203 ;; `translation-table-id', `translation-hash-table-id' |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
204 ;; `code-conversion-map-id', or `ccl-program-idx'. |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
205 (defun ccl-embed-symbol (symbol prop) |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
206 (ccl-embed-data (cons symbol prop))) |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
207 |
17052 | 208 ;; Embed string STR of length LEN in `ccl-program-vector' at |
209 ;; `ccl-current-ic'. | |
210 (defun ccl-embed-string (len str) | |
211 (let ((i 0)) | |
212 (while (< i len) | |
213 (ccl-embed-data (logior (ash (aref str i) 16) | |
214 (if (< (1+ i) len) | |
215 (ash (aref str (1+ i)) 8) | |
216 0) | |
217 (if (< (+ i 2) len) | |
218 (aref str (+ i 2)) | |
219 0))) | |
220 (setq i (+ i 3))))) | |
221 | |
222 ;; Embed a relative jump address to `ccl-current-ic' in | |
223 ;; `ccl-program-vector' at IC without altering the other bit field. | |
224 (defun ccl-embed-current-address (ic) | |
225 (let ((relative (- ccl-current-ic (1+ ic)))) | |
226 (aset ccl-program-vector ic | |
227 (logior (aref ccl-program-vector ic) (ash relative 8))))) | |
228 | |
229 ;; Embed CCL code for the operation OP and arguments REG and DATA in | |
230 ;; `ccl-program-vector' at `ccl-current-ic' in the following format. | |
231 ;; |----------------- integer (28-bit) ------------------| | |
232 ;; |------------ 20-bit ------------|- 3-bit --|- 5-bit -| | |
233 ;; |------------- DATA -------------|-- REG ---|-- OP ---| | |
234 ;; If REG2 is specified, embed a code in the following format. | |
235 ;; |------- 17-bit ------|- 3-bit --|- 3-bit --|- 5-bit -| | |
236 ;; |-------- DATA -------|-- REG2 --|-- REG ---|-- OP ---| | |
237 | |
238 ;; If REG is a CCL register symbol (e.g. r0, r1...), the register | |
239 ;; number is embedded. If OP is one of unconditional jumps, DATA is | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46493
diff
changeset
|
240 ;; changed to a relative jump address. |
17052 | 241 |
242 (defun ccl-embed-code (op reg data &optional reg2) | |
243 (if (and (> data 0) (get op 'jump-flag)) | |
244 ;; DATA is an absolute jump address. Make it relative to the | |
245 ;; next of jump code. | |
246 (setq data (- data (1+ ccl-current-ic)))) | |
247 (let ((code (logior (get op 'ccl-code) | |
248 (ash | |
249 (if (symbolp reg) (get reg 'ccl-register-number) reg) 5) | |
250 (if reg2 | |
251 (logior (ash (get reg2 'ccl-register-number) 8) | |
252 (ash data 11)) | |
253 (ash data 8))))) | |
30705
b37405134317
(ccl-embed-data): Make ccl-program-vector
Kenichi Handa <handa@m17n.org>
parents:
29429
diff
changeset
|
254 (ccl-embed-data code))) |
17052 | 255 |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
256 ;; extended ccl command format |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
257 ;; |- 14-bit -|- 3-bit --|- 3-bit --|- 3-bit --|- 5-bit -| |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
258 ;; |- EX-OP --|-- REG3 --|-- REG2 --|-- REG ---|-- OP ---| |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
259 (defun ccl-embed-extended-command (ex-op reg reg2 reg3) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
260 (let ((data (logior (ash (get ex-op 'ccl-ex-code) 3) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
261 (if (symbolp reg3) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
262 (get reg3 'ccl-register-number) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
263 0)))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
264 (ccl-embed-code 'ex-cmd reg data reg2))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
265 |
17052 | 266 ;; Just advance `ccl-current-ic' by INC. |
267 (defun ccl-increment-ic (inc) | |
268 (setq ccl-current-ic (+ ccl-current-ic inc))) | |
269 | |
270 ;; If non-nil, index of the start of the current loop. | |
271 (defvar ccl-loop-head nil) | |
272 ;; If non-nil, list of absolute addresses of the breaking points of | |
273 ;; the current loop. | |
274 (defvar ccl-breaks nil) | |
275 | |
276 ;;;###autoload | |
277 (defun ccl-compile (ccl-program) | |
36466 | 278 "Return the compiled code of CCL-PROGRAM as a vector of integers." |
17052 | 279 (if (or (null (consp ccl-program)) |
280 (null (integerp (car ccl-program))) | |
281 (null (listp (car (cdr ccl-program))))) | |
282 (error "CCL: Invalid CCL program: %s" ccl-program)) | |
283 (if (null (vectorp ccl-program-vector)) | |
284 (setq ccl-program-vector (make-vector 8192 0))) | |
285 (setq ccl-loop-head nil ccl-breaks nil) | |
286 (setq ccl-current-ic 0) | |
287 | |
288 ;; The first element is the buffer magnification. | |
289 (ccl-embed-data (car ccl-program)) | |
290 | |
291 ;; The second element is the address of the start CCL code for | |
292 ;; processing end of input buffer (we call it eof-processor). We | |
293 ;; set it later. | |
294 (ccl-increment-ic 1) | |
295 | |
296 ;; Compile the main body of the CCL program. | |
297 (ccl-compile-1 (car (cdr ccl-program))) | |
298 | |
299 ;; Embed the address of eof-processor. | |
300 (ccl-embed-data ccl-current-ic 1) | |
301 | |
302 ;; Then compile eof-processor. | |
303 (if (nth 2 ccl-program) | |
304 (ccl-compile-1 (nth 2 ccl-program))) | |
305 | |
306 ;; At last, embed termination code. | |
307 (ccl-embed-code 'end 0 0) | |
308 | |
309 (let ((vec (make-vector ccl-current-ic 0)) | |
310 (i 0)) | |
311 (while (< i ccl-current-ic) | |
312 (aset vec i (aref ccl-program-vector i)) | |
313 (setq i (1+ i))) | |
314 vec)) | |
315 | |
316 ;; Signal syntax error. | |
317 (defun ccl-syntax-error (cmd) | |
318 (error "CCL: Syntax error: %s" cmd)) | |
319 | |
320 ;; Check if ARG is a valid CCL register. | |
321 (defun ccl-check-register (arg cmd) | |
322 (if (get arg 'ccl-register-number) | |
323 arg | |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37827
diff
changeset
|
324 (error "CCL: Invalid register %s in %s" arg cmd))) |
17052 | 325 |
326 ;; Check if ARG is a valid CCL command. | |
327 (defun ccl-check-compile-function (arg cmd) | |
328 (or (get arg 'ccl-compile-function) | |
329 (error "CCL: Invalid command: %s" cmd))) | |
330 | |
331 ;; In the following code, most ccl-compile-XXXX functions return t if | |
332 ;; they end with unconditional jump, else return nil. | |
333 | |
334 ;; Compile CCL-BLOCK (see the syntax above). | |
335 (defun ccl-compile-1 (ccl-block) | |
336 (let (unconditional-jump | |
337 cmd) | |
338 (if (or (integerp ccl-block) | |
339 (stringp ccl-block) | |
340 (and ccl-block (symbolp (car ccl-block)))) | |
341 ;; This block consists of single statement. | |
342 (setq ccl-block (list ccl-block))) | |
343 | |
344 ;; Now CCL-BLOCK is a list of statements. Compile them one by | |
345 ;; one. | |
346 (while ccl-block | |
347 (setq cmd (car ccl-block)) | |
348 (setq unconditional-jump | |
349 (cond ((integerp cmd) | |
350 ;; SET statement for the register 0. | |
351 (ccl-compile-set (list 'r0 '= cmd))) | |
352 | |
353 ((stringp cmd) | |
354 ;; WRITE statement of string argument. | |
355 (ccl-compile-write-string cmd)) | |
356 | |
357 ((listp cmd) | |
358 ;; The other statements. | |
359 (cond ((eq (nth 1 cmd) '=) | |
360 ;; SET statement of the form `(REG = EXPRESSION)'. | |
361 (ccl-compile-set cmd)) | |
362 | |
363 ((and (symbolp (nth 1 cmd)) | |
364 (get (nth 1 cmd) 'ccl-self-arith-code)) | |
365 ;; SET statement with an assignment operation. | |
366 (ccl-compile-self-set cmd)) | |
367 | |
368 (t | |
369 (funcall (ccl-check-compile-function (car cmd) cmd) | |
370 cmd)))) | |
371 | |
372 (t | |
373 (ccl-syntax-error cmd)))) | |
374 (setq ccl-block (cdr ccl-block))) | |
375 unconditional-jump)) | |
376 | |
377 (defconst ccl-max-short-const (ash 1 19)) | |
378 (defconst ccl-min-short-const (ash -1 19)) | |
379 | |
380 ;; Compile SET statement. | |
381 (defun ccl-compile-set (cmd) | |
382 (let ((rrr (ccl-check-register (car cmd) cmd)) | |
383 (right (nth 2 cmd))) | |
384 (cond ((listp right) | |
385 ;; CMD has the form `(RRR = (XXX OP YYY))'. | |
386 (ccl-compile-expression rrr right)) | |
387 | |
388 ((integerp right) | |
389 ;; CMD has the form `(RRR = integer)'. | |
390 (if (and (<= right ccl-max-short-const) | |
391 (>= right ccl-min-short-const)) | |
392 (ccl-embed-code 'set-short-const rrr right) | |
393 (ccl-embed-code 'set-const rrr 0) | |
394 (ccl-embed-data right))) | |
395 | |
396 (t | |
397 ;; CMD has the form `(RRR = rrr [ array ])'. | |
398 (ccl-check-register right cmd) | |
399 (let ((ary (nth 3 cmd))) | |
400 (if (vectorp ary) | |
401 (let ((i 0) (len (length ary))) | |
402 (ccl-embed-code 'set-array rrr len right) | |
403 (while (< i len) | |
404 (ccl-embed-data (aref ary i)) | |
405 (setq i (1+ i)))) | |
406 (ccl-embed-code 'set-register rrr 0 right)))))) | |
407 nil) | |
408 | |
409 ;; Compile SET statement with ASSIGNMENT_OPERATOR. | |
410 (defun ccl-compile-self-set (cmd) | |
411 (let ((rrr (ccl-check-register (car cmd) cmd)) | |
412 (right (nth 2 cmd))) | |
413 (if (listp right) | |
414 ;; CMD has the form `(RRR ASSIGN_OP (XXX OP YYY))', compile | |
415 ;; the right hand part as `(r7 = (XXX OP YYY))' (note: the | |
416 ;; register 7 can be used for storing temporary value). | |
417 (progn | |
418 (ccl-compile-expression 'r7 right) | |
419 (setq right 'r7))) | |
420 ;; Now CMD has the form `(RRR ASSIGN_OP ARG)'. Compile it as | |
421 ;; `(RRR = (RRR OP ARG))'. | |
422 (ccl-compile-expression | |
423 rrr | |
424 (list rrr (intern (substring (symbol-name (nth 1 cmd)) 0 -1)) right))) | |
425 nil) | |
426 | |
427 ;; Compile SET statement of the form `(RRR = EXPR)'. | |
428 (defun ccl-compile-expression (rrr expr) | |
429 (let ((left (car expr)) | |
430 (op (get (nth 1 expr) 'ccl-arith-code)) | |
431 (right (nth 2 expr))) | |
432 (if (listp left) | |
433 (progn | |
434 ;; EXPR has the form `((EXPR2 OP2 ARG) OP RIGHT)'. Compile | |
435 ;; the first term as `(r7 = (EXPR2 OP2 ARG)).' | |
436 (ccl-compile-expression 'r7 left) | |
437 (setq left 'r7))) | |
438 | |
439 ;; Now EXPR has the form (LEFT OP RIGHT). | |
28152
1b7866e465bd
(ccl-compile-expression): Don't generate
Kenichi Handa <handa@m17n.org>
parents:
25064
diff
changeset
|
440 (if (and (eq rrr left) |
1b7866e465bd
(ccl-compile-expression): Don't generate
Kenichi Handa <handa@m17n.org>
parents:
25064
diff
changeset
|
441 (< op (length ccl-assign-arith-table))) |
17052 | 442 ;; Compile this SET statement as `(RRR OP= RIGHT)'. |
443 (if (integerp right) | |
444 (progn | |
445 (ccl-embed-code 'set-assign-expr-const rrr (ash op 3) 'r0) | |
446 (ccl-embed-data right)) | |
447 (ccl-check-register right expr) | |
448 (ccl-embed-code 'set-assign-expr-register rrr (ash op 3) right)) | |
449 | |
450 ;; Compile this SET statement as `(RRR = (LEFT OP RIGHT))'. | |
451 (if (integerp right) | |
452 (progn | |
453 (ccl-embed-code 'set-expr-const rrr (ash op 3) left) | |
454 (ccl-embed-data right)) | |
455 (ccl-check-register right expr) | |
456 (ccl-embed-code 'set-expr-register | |
457 rrr | |
458 (logior (ash op 3) (get right 'ccl-register-number)) | |
459 left))))) | |
460 | |
461 ;; Compile WRITE statement with string argument. | |
462 (defun ccl-compile-write-string (str) | |
29030
837bc0327945
(ccl-compile-write-string): Make STR unibyte.
Kenichi Handa <handa@m17n.org>
parents:
28152
diff
changeset
|
463 (setq str (string-as-unibyte str)) |
17052 | 464 (let ((len (length str))) |
465 (ccl-embed-code 'write-const-string 1 len) | |
466 (ccl-embed-string len str)) | |
467 nil) | |
468 | |
469 ;; Compile IF statement of the form `(if CONDITION TRUE-PART FALSE-PART)'. | |
470 ;; If READ-FLAG is non-nil, this statement has the form | |
471 ;; `(read-if (REG OPERATOR ARG) TRUE-PART FALSE-PART)'. | |
472 (defun ccl-compile-if (cmd &optional read-flag) | |
473 (if (and (/= (length cmd) 3) (/= (length cmd) 4)) | |
474 (error "CCL: Invalid number of arguments: %s" cmd)) | |
475 (let ((condition (nth 1 cmd)) | |
476 (true-cmds (nth 2 cmd)) | |
477 (false-cmds (nth 3 cmd)) | |
478 jump-cond-address | |
479 false-ic) | |
480 (if (and (listp condition) | |
481 (listp (car condition))) | |
482 ;; If CONDITION is a nested expression, the inner expression | |
483 ;; should be compiled at first as SET statement, i.e.: | |
484 ;; `(if ((X OP2 Y) OP Z) ...)' is compiled into two statements: | |
485 ;; `(r7 = (X OP2 Y)) (if (r7 OP Z) ...)'. | |
486 (progn | |
487 (ccl-compile-expression 'r7 (car condition)) | |
488 (setq condition (cons 'r7 (cdr condition))) | |
489 (setq cmd (cons (car cmd) | |
490 (cons condition (cdr (cdr cmd))))))) | |
491 | |
492 (setq jump-cond-address ccl-current-ic) | |
493 ;; Compile CONDITION. | |
494 (if (symbolp condition) | |
495 ;; CONDITION is a register. | |
496 (progn | |
497 (ccl-check-register condition cmd) | |
498 (ccl-embed-code 'jump-cond condition 0)) | |
499 ;; CONDITION is a simple expression of the form (RRR OP ARG). | |
500 (let ((rrr (car condition)) | |
501 (op (get (nth 1 condition) 'ccl-arith-code)) | |
502 (arg (nth 2 condition))) | |
503 (ccl-check-register rrr cmd) | |
504 (if (integerp arg) | |
505 (progn | |
506 (ccl-embed-code (if read-flag 'read-jump-cond-expr-const | |
507 'jump-cond-expr-const) | |
508 rrr 0) | |
509 (ccl-embed-data op) | |
510 (ccl-embed-data arg)) | |
511 (ccl-check-register arg cmd) | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46493
diff
changeset
|
512 (ccl-embed-code (if read-flag 'read-jump-cond-expr-register |
17052 | 513 'jump-cond-expr-register) |
514 rrr 0) | |
515 (ccl-embed-data op) | |
516 (ccl-embed-data (get arg 'ccl-register-number))))) | |
517 | |
518 ;; Compile TRUE-PART. | |
519 (let ((unconditional-jump (ccl-compile-1 true-cmds))) | |
520 (if (null false-cmds) | |
521 ;; This is the place to jump to if condition is false. | |
23432
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
522 (progn |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
523 (ccl-embed-current-address jump-cond-address) |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
524 (setq unconditional-jump nil)) |
17052 | 525 (let (end-true-part-address) |
526 (if (not unconditional-jump) | |
527 (progn | |
528 ;; If TRUE-PART does not end with unconditional jump, we | |
529 ;; have to jump to the end of FALSE-PART from here. | |
530 (setq end-true-part-address ccl-current-ic) | |
531 (ccl-embed-code 'jump 0 0))) | |
532 ;; This is the place to jump to if CONDITION is false. | |
533 (ccl-embed-current-address jump-cond-address) | |
534 ;; Compile FALSE-PART. | |
535 (setq unconditional-jump | |
536 (and (ccl-compile-1 false-cmds) unconditional-jump)) | |
537 (if end-true-part-address | |
538 ;; This is the place to jump to after the end of TRUE-PART. | |
539 (ccl-embed-current-address end-true-part-address)))) | |
540 unconditional-jump))) | |
541 | |
542 ;; Compile BRANCH statement. | |
543 (defun ccl-compile-branch (cmd) | |
544 (if (< (length cmd) 3) | |
545 (error "CCL: Invalid number of arguments: %s" cmd)) | |
546 (ccl-compile-branch-blocks 'branch | |
547 (ccl-compile-branch-expression (nth 1 cmd) cmd) | |
548 (cdr (cdr cmd)))) | |
549 | |
550 ;; Compile READ statement of the form `(read-branch EXPR BLOCK0 BLOCK1 ...)'. | |
551 (defun ccl-compile-read-branch (cmd) | |
552 (if (< (length cmd) 3) | |
553 (error "CCL: Invalid number of arguments: %s" cmd)) | |
554 (ccl-compile-branch-blocks 'read-branch | |
555 (ccl-compile-branch-expression (nth 1 cmd) cmd) | |
556 (cdr (cdr cmd)))) | |
557 | |
558 ;; Compile EXPRESSION part of BRANCH statement and return register | |
559 ;; which holds a value of the expression. | |
560 (defun ccl-compile-branch-expression (expr cmd) | |
561 (if (listp expr) | |
562 ;; EXPR has the form `(EXPR2 OP ARG)'. Compile it as SET | |
563 ;; statement of the form `(r7 = (EXPR2 OP ARG))'. | |
564 (progn | |
565 (ccl-compile-expression 'r7 expr) | |
566 'r7) | |
567 (ccl-check-register expr cmd))) | |
568 | |
569 ;; Compile BLOCKs of BRANCH statement. CODE is 'branch or 'read-branch. | |
570 ;; REG is a register which holds a value of EXPRESSION part. BLOCKs | |
571 ;; is a list of CCL-BLOCKs. | |
572 (defun ccl-compile-branch-blocks (code rrr blocks) | |
573 (let ((branches (length blocks)) | |
574 branch-idx | |
575 jump-table-head-address | |
576 empty-block-indexes | |
577 block-tail-addresses | |
578 block-unconditional-jump) | |
579 (ccl-embed-code code rrr branches) | |
580 (setq jump-table-head-address ccl-current-ic) | |
581 ;; The size of jump table is the number of blocks plus 1 (for the | |
582 ;; case RRR is out of range). | |
583 (ccl-increment-ic (1+ branches)) | |
584 (setq empty-block-indexes (list branches)) | |
585 ;; Compile each block. | |
586 (setq branch-idx 0) | |
587 (while blocks | |
588 (if (null (car blocks)) | |
589 ;; This block is empty. | |
590 (setq empty-block-indexes (cons branch-idx empty-block-indexes) | |
591 block-unconditional-jump t) | |
592 ;; This block is not empty. | |
593 (ccl-embed-data (- ccl-current-ic jump-table-head-address) | |
594 (+ jump-table-head-address branch-idx)) | |
595 (setq block-unconditional-jump (ccl-compile-1 (car blocks))) | |
596 (if (not block-unconditional-jump) | |
597 (progn | |
598 ;; Jump address of the end of branches are embedded later. | |
599 ;; For the moment, just remember where to embed them. | |
600 (setq block-tail-addresses | |
601 (cons ccl-current-ic block-tail-addresses)) | |
602 (ccl-embed-code 'jump 0 0)))) | |
603 (setq branch-idx (1+ branch-idx)) | |
604 (setq blocks (cdr blocks))) | |
605 (if (not block-unconditional-jump) | |
606 ;; We don't need jump code at the end of the last block. | |
607 (setq block-tail-addresses (cdr block-tail-addresses) | |
608 ccl-current-ic (1- ccl-current-ic))) | |
609 ;; Embed jump address at the tailing jump commands of blocks. | |
610 (while block-tail-addresses | |
611 (ccl-embed-current-address (car block-tail-addresses)) | |
612 (setq block-tail-addresses (cdr block-tail-addresses))) | |
613 ;; For empty blocks, make entries in the jump table point directly here. | |
614 (while empty-block-indexes | |
615 (ccl-embed-data (- ccl-current-ic jump-table-head-address) | |
616 (+ jump-table-head-address (car empty-block-indexes))) | |
617 (setq empty-block-indexes (cdr empty-block-indexes)))) | |
618 ;; Branch command ends by unconditional jump if RRR is out of range. | |
619 nil) | |
620 | |
621 ;; Compile LOOP statement. | |
622 (defun ccl-compile-loop (cmd) | |
623 (if (< (length cmd) 2) | |
624 (error "CCL: Invalid number of arguments: %s" cmd)) | |
625 (let* ((ccl-loop-head ccl-current-ic) | |
626 (ccl-breaks nil) | |
627 unconditional-jump) | |
628 (setq cmd (cdr cmd)) | |
629 (if cmd | |
630 (progn | |
631 (setq unconditional-jump t) | |
632 (while cmd | |
633 (setq unconditional-jump | |
634 (and (ccl-compile-1 (car cmd)) unconditional-jump)) | |
635 (setq cmd (cdr cmd))) | |
636 (if (not ccl-breaks) | |
637 unconditional-jump | |
638 ;; Embed jump address for break statements encountered in | |
639 ;; this loop. | |
640 (while ccl-breaks | |
641 (ccl-embed-current-address (car ccl-breaks)) | |
642 (setq ccl-breaks (cdr ccl-breaks)))) | |
643 nil)))) | |
644 | |
645 ;; Compile BREAK statement. | |
646 (defun ccl-compile-break (cmd) | |
647 (if (/= (length cmd) 1) | |
648 (error "CCL: Invalid number of arguments: %s" cmd)) | |
649 (if (null ccl-loop-head) | |
650 (error "CCL: No outer loop: %s" cmd)) | |
651 (setq ccl-breaks (cons ccl-current-ic ccl-breaks)) | |
652 (ccl-embed-code 'jump 0 0) | |
653 t) | |
654 | |
655 ;; Compile REPEAT statement. | |
656 (defun ccl-compile-repeat (cmd) | |
657 (if (/= (length cmd) 1) | |
658 (error "CCL: Invalid number of arguments: %s" cmd)) | |
659 (if (null ccl-loop-head) | |
660 (error "CCL: No outer loop: %s" cmd)) | |
661 (ccl-embed-code 'jump 0 ccl-loop-head) | |
662 t) | |
663 | |
664 ;; Compile WRITE-REPEAT statement. | |
665 (defun ccl-compile-write-repeat (cmd) | |
666 (if (/= (length cmd) 2) | |
667 (error "CCL: Invalid number of arguments: %s" cmd)) | |
668 (if (null ccl-loop-head) | |
669 (error "CCL: No outer loop: %s" cmd)) | |
670 (let ((arg (nth 1 cmd))) | |
671 (cond ((integerp arg) | |
672 (ccl-embed-code 'write-const-jump 0 ccl-loop-head) | |
673 (ccl-embed-data arg)) | |
674 ((stringp arg) | |
29030
837bc0327945
(ccl-compile-write-string): Make STR unibyte.
Kenichi Handa <handa@m17n.org>
parents:
28152
diff
changeset
|
675 (setq arg (string-as-unibyte arg)) |
17052 | 676 (let ((len (length arg)) |
677 (i 0)) | |
678 (ccl-embed-code 'write-string-jump 0 ccl-loop-head) | |
679 (ccl-embed-data len) | |
680 (ccl-embed-string len arg))) | |
681 (t | |
682 (ccl-check-register arg cmd) | |
683 (ccl-embed-code 'write-register-jump arg ccl-loop-head)))) | |
684 t) | |
685 | |
686 ;; Compile WRITE-READ-REPEAT statement. | |
687 (defun ccl-compile-write-read-repeat (cmd) | |
688 (if (or (< (length cmd) 2) (> (length cmd) 3)) | |
689 (error "CCL: Invalid number of arguments: %s" cmd)) | |
690 (if (null ccl-loop-head) | |
691 (error "CCL: No outer loop: %s" cmd)) | |
692 (let ((rrr (ccl-check-register (nth 1 cmd) cmd)) | |
693 (arg (nth 2 cmd))) | |
694 (cond ((null arg) | |
695 (ccl-embed-code 'write-register-read-jump rrr ccl-loop-head)) | |
696 ((integerp arg) | |
697 (ccl-embed-code 'write-const-read-jump rrr arg ccl-loop-head)) | |
698 ((vectorp arg) | |
699 (let ((len (length arg)) | |
700 (i 0)) | |
701 (ccl-embed-code 'write-array-read-jump rrr ccl-loop-head) | |
702 (ccl-embed-data len) | |
703 (while (< i len) | |
704 (ccl-embed-data (aref arg i)) | |
705 (setq i (1+ i))))) | |
706 (t | |
707 (error "CCL: Invalid argument %s: %s" arg cmd))) | |
708 (ccl-embed-code 'read-jump rrr ccl-loop-head)) | |
709 t) | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46493
diff
changeset
|
710 |
17052 | 711 ;; Compile READ statement. |
712 (defun ccl-compile-read (cmd) | |
713 (if (< (length cmd) 2) | |
714 (error "CCL: Invalid number of arguments: %s" cmd)) | |
715 (let* ((args (cdr cmd)) | |
716 (i (1- (length args)))) | |
717 (while args | |
718 (let ((rrr (ccl-check-register (car args) cmd))) | |
719 (ccl-embed-code 'read-register rrr i) | |
720 (setq args (cdr args) i (1- i))))) | |
721 nil) | |
722 | |
723 ;; Compile READ-IF statement. | |
724 (defun ccl-compile-read-if (cmd) | |
725 (ccl-compile-if cmd 'read)) | |
726 | |
727 ;; Compile WRITE statement. | |
728 (defun ccl-compile-write (cmd) | |
729 (if (< (length cmd) 2) | |
730 (error "CCL: Invalid number of arguments: %s" cmd)) | |
731 (let ((rrr (nth 1 cmd))) | |
732 (cond ((integerp rrr) | |
733 (ccl-embed-code 'write-const-string 0 rrr)) | |
734 ((stringp rrr) | |
735 (ccl-compile-write-string rrr)) | |
736 ((and (symbolp rrr) (vectorp (nth 2 cmd))) | |
737 (ccl-check-register rrr cmd) | |
738 ;; CMD has the form `(write REG ARRAY)'. | |
739 (let* ((arg (nth 2 cmd)) | |
740 (len (length arg)) | |
741 (i 0)) | |
742 (ccl-embed-code 'write-array rrr len) | |
743 (while (< i len) | |
744 (if (not (integerp (aref arg i))) | |
745 (error "CCL: Invalid argument %s: %s" arg cmd)) | |
746 (ccl-embed-data (aref arg i)) | |
747 (setq i (1+ i))))) | |
748 | |
749 ((symbolp rrr) | |
750 ;; CMD has the form `(write REG ...)'. | |
751 (let* ((args (cdr cmd)) | |
752 (i (1- (length args)))) | |
753 (while args | |
754 (setq rrr (ccl-check-register (car args) cmd)) | |
755 (ccl-embed-code 'write-register rrr i) | |
756 (setq args (cdr args) i (1- i))))) | |
757 | |
758 ((listp rrr) | |
759 ;; CMD has the form `(write (LEFT OP RIGHT))'. | |
760 (let ((left (car rrr)) | |
761 (op (get (nth 1 rrr) 'ccl-arith-code)) | |
762 (right (nth 2 rrr))) | |
763 (if (listp left) | |
764 (progn | |
765 ;; RRR has the form `((EXPR OP2 ARG) OP RIGHT)'. | |
766 ;; Compile the first term as `(r7 = (EXPR OP2 ARG))'. | |
767 (ccl-compile-expression 'r7 left) | |
768 (setq left 'r7))) | |
769 ;; Now RRR has the form `(ARG OP RIGHT)'. | |
770 (if (integerp right) | |
771 (progn | |
772 (ccl-embed-code 'write-expr-const 0 (ash op 3) left) | |
773 (ccl-embed-data right)) | |
774 (ccl-check-register right rrr) | |
775 (ccl-embed-code 'write-expr-register 0 | |
776 (logior (ash op 3) | |
53961
74d57e5bfed4
(ccl-compile-write): Pass `left' to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
777 (get right 'ccl-register-number)) |
74d57e5bfed4
(ccl-compile-write): Pass `left' to
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
778 left)))) |
17052 | 779 |
780 (t | |
781 (error "CCL: Invalid argument: %s" cmd)))) | |
782 nil) | |
783 | |
784 ;; Compile CALL statement. | |
785 (defun ccl-compile-call (cmd) | |
786 (if (/= (length cmd) 2) | |
787 (error "CCL: Invalid number of arguments: %s" cmd)) | |
788 (if (not (symbolp (nth 1 cmd))) | |
789 (error "CCL: Subroutine should be a symbol: %s" cmd)) | |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
790 (ccl-embed-code 'call 1 0) |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
791 (ccl-embed-symbol (nth 1 cmd) 'ccl-program-idx) |
17052 | 792 nil) |
793 | |
794 ;; Compile END statement. | |
795 (defun ccl-compile-end (cmd) | |
796 (if (/= (length cmd) 1) | |
797 (error "CCL: Invalid number of arguments: %s" cmd)) | |
798 (ccl-embed-code 'end 0 0) | |
799 t) | |
800 | |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
801 ;; Compile read-multibyte-character |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
802 (defun ccl-compile-read-multibyte-character (cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
803 (if (/= (length cmd) 3) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
804 (error "CCL: Invalid number of arguments: %s" cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
805 (let ((RRR (nth 1 cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
806 (rrr (nth 2 cmd))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
807 (ccl-check-register rrr cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
808 (ccl-check-register RRR cmd) |
23432
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
809 (ccl-embed-extended-command 'read-multibyte-character rrr RRR 0)) |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
810 nil) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
811 |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
812 ;; Compile write-multibyte-character |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
813 (defun ccl-compile-write-multibyte-character (cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
814 (if (/= (length cmd) 3) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
815 (error "CCL: Invalid number of arguments: %s" cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
816 (let ((RRR (nth 1 cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
817 (rrr (nth 2 cmd))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
818 (ccl-check-register rrr cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
819 (ccl-check-register RRR cmd) |
23432
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
820 (ccl-embed-extended-command 'write-multibyte-character rrr RRR 0)) |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
821 nil) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
822 |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
823 ;; Compile translate-character |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
824 (defun ccl-compile-translate-character (cmd) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
825 (if (/= (length cmd) 4) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
826 (error "CCL: Invalid number of arguments: %s" cmd)) |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
827 (let ((Rrr (nth 1 cmd)) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
828 (RRR (nth 2 cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
829 (rrr (nth 3 cmd))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
830 (ccl-check-register rrr cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
831 (ccl-check-register RRR cmd) |
24152
202b1402425b
(ccl-compile-translate-character): Handle
Kenichi Handa <handa@m17n.org>
parents:
23771
diff
changeset
|
832 (cond ((and (symbolp Rrr) (not (get Rrr 'ccl-register-number))) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
833 (ccl-embed-extended-command 'translate-character-const-tbl |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
834 rrr RRR 0) |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
835 (ccl-embed-symbol Rrr 'translation-table-id)) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
836 (t |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
837 (ccl-check-register Rrr cmd) |
23432
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
838 (ccl-embed-extended-command 'translate-character rrr RRR Rrr)))) |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
839 nil) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
840 |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
841 ;; Compile lookup-integer |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
842 (defun ccl-compile-lookup-integer (cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
843 (if (/= (length cmd) 4) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
844 (error "CCL: Invalid number of arguments: %s" cmd)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
845 (let ((Rrr (nth 1 cmd)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
846 (RRR (nth 2 cmd)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
847 (rrr (nth 3 cmd))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
848 (ccl-check-register RRR cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
849 (ccl-check-register rrr cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
850 (cond ((and (symbolp Rrr) (not (get Rrr 'ccl-register-number))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
851 (ccl-embed-extended-command 'lookup-int-const-tbl |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
852 rrr RRR 0) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
853 (ccl-embed-symbol Rrr 'translation-hash-table-id)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
854 (t |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
855 (error "CCL: non-constant table: %s" cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
856 ;; not implemented: |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
857 (ccl-check-register Rrr cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
858 (ccl-embed-extended-command 'lookup-int rrr RRR 0)))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
859 nil) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
860 |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
861 ;; Compile lookup-character |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
862 (defun ccl-compile-lookup-character (cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
863 (if (/= (length cmd) 4) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
864 (error "CCL: Invalid number of arguments: %s" cmd)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
865 (let ((Rrr (nth 1 cmd)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
866 (RRR (nth 2 cmd)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
867 (rrr (nth 3 cmd))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
868 (ccl-check-register RRR cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
869 (ccl-check-register rrr cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
870 (cond ((and (symbolp Rrr) (not (get Rrr 'ccl-register-number))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
871 (ccl-embed-extended-command 'lookup-char-const-tbl |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
872 rrr RRR 0) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
873 (ccl-embed-symbol Rrr 'translation-hash-table-id)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
874 (t |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
875 (error "CCL: non-constant table: %s" cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
876 ;; not implemented: |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
877 (ccl-check-register Rrr cmd) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
878 (ccl-embed-extended-command 'lookup-char rrr RRR 0)))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
879 nil) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
880 |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
881 (defun ccl-compile-iterate-multiple-map (cmd) |
23432
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
882 (ccl-compile-multiple-map-function 'iterate-multiple-map cmd) |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
883 nil) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
884 |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
885 (defun ccl-compile-map-multiple (cmd) |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
886 (if (/= (length cmd) 4) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
887 (error "CCL: Invalid number of arguments: %s" cmd)) |
29429
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
888 (let (func arg) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
889 (setq func |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
890 (lambda (arg mp) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
891 (let ((len 0) result add) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
892 (while arg |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
893 (if (consp (car arg)) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
894 (setq add (funcall func (car arg) t) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
895 result (append result add) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
896 add (+ (- (car add)) 1)) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
897 (setq result |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
898 (append result |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
899 (list (car arg))) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
900 add 1)) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
901 (setq arg (cdr arg) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
902 len (+ len add))) |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46493
diff
changeset
|
903 (if mp |
29429
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
904 (cons (- len) result) |
1fa36ef2bb6c
(ccl-compile-translate-character): Don't check if Rrr has property
Kenichi Handa <handa@m17n.org>
parents:
29044
diff
changeset
|
905 result)))) |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
906 (setq arg (append (list (nth 0 cmd) (nth 1 cmd) (nth 2 cmd)) |
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
907 (funcall func (nth 3 cmd) nil))) |
23432
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
908 (ccl-compile-multiple-map-function 'map-multiple arg)) |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
909 nil) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
910 |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
911 (defun ccl-compile-map-single (cmd) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
912 (if (/= (length cmd) 4) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
913 (error "CCL: Invalid number of arguments: %s" cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
914 (let ((RRR (nth 1 cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
915 (rrr (nth 2 cmd)) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
916 (map (nth 3 cmd)) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
917 id) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
918 (ccl-check-register rrr cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
919 (ccl-check-register RRR cmd) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
920 (ccl-embed-extended-command 'map-single rrr RRR 0) |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
921 (cond ((symbolp map) |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
922 (if (get map 'code-conversion-map) |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
923 (ccl-embed-symbol map 'code-conversion-map-id) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
924 (error "CCL: Invalid map: %s" map))) |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
925 (t |
23432
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
926 (error "CCL: Invalid type of arguments: %s" cmd)))) |
5f51adf0b6ec
(ccl-compile-if): If there's no false-cmds,
Kenichi Handa <handa@m17n.org>
parents:
23196
diff
changeset
|
927 nil) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
928 |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
929 (defun ccl-compile-multiple-map-function (command cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
930 (if (< (length cmd) 4) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
931 (error "CCL: Invalid number of arguments: %s" cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
932 (let ((RRR (nth 1 cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
933 (rrr (nth 2 cmd)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
934 (args (nthcdr 3 cmd)) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
935 map) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
936 (ccl-check-register rrr cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
937 (ccl-check-register RRR cmd) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
938 (ccl-embed-extended-command command rrr RRR 0) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
939 (ccl-embed-data (length args)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
940 (while args |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
941 (setq map (car args)) |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
942 (cond ((symbolp map) |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
943 (if (get map 'code-conversion-map) |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
944 (ccl-embed-symbol map 'code-conversion-map-id) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
945 (error "CCL: Invalid map: %s" map))) |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
946 ((numberp map) |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
947 (ccl-embed-data map)) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
948 (t |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
949 (error "CCL: Invalid type of arguments: %s" cmd))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
950 (setq args (cdr args))))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
951 |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
952 |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
953 ;;; CCL dump stuff |
17052 | 954 |
955 ;; To avoid byte-compiler warning. | |
956 (defvar ccl-code) | |
957 | |
958 ;;;###autoload | |
959 (defun ccl-dump (ccl-code) | |
960 "Disassemble compiled CCL-CODE." | |
961 (let ((len (length ccl-code)) | |
962 (buffer-mag (aref ccl-code 0))) | |
963 (cond ((= buffer-mag 0) | |
964 (insert "Don't output anything.\n")) | |
965 ((= buffer-mag 1) | |
966 (insert "Out-buffer must be as large as in-buffer.\n")) | |
967 (t | |
968 (insert | |
969 (format "Out-buffer must be %d times bigger than in-buffer.\n" | |
970 buffer-mag)))) | |
971 (insert "Main-body:\n") | |
972 (setq ccl-current-ic 2) | |
973 (if (> (aref ccl-code 1) 0) | |
974 (progn | |
975 (while (< ccl-current-ic (aref ccl-code 1)) | |
976 (ccl-dump-1)) | |
977 (insert "At EOF:\n"))) | |
978 (while (< ccl-current-ic len) | |
979 (ccl-dump-1)) | |
980 )) | |
981 | |
982 ;; Return a CCL code in `ccl-code' at `ccl-current-ic'. | |
983 (defun ccl-get-next-code () | |
984 (prog1 | |
985 (aref ccl-code ccl-current-ic) | |
986 (setq ccl-current-ic (1+ ccl-current-ic)))) | |
987 | |
988 (defun ccl-dump-1 () | |
989 (let* ((code (ccl-get-next-code)) | |
990 (cmd (aref ccl-code-table (logand code 31))) | |
991 (rrr (ash (logand code 255) -5)) | |
992 (cc (ash code -8))) | |
993 (insert (format "%5d:[%s] " (1- ccl-current-ic) cmd)) | |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46493
diff
changeset
|
994 (funcall (get cmd 'ccl-dump-function) rrr cc))) |
17052 | 995 |
996 (defun ccl-dump-set-register (rrr cc) | |
997 (insert (format "r%d = r%d\n" rrr cc))) | |
998 | |
999 (defun ccl-dump-set-short-const (rrr cc) | |
1000 (insert (format "r%d = %d\n" rrr cc))) | |
1001 | |
1002 (defun ccl-dump-set-const (rrr ignore) | |
1003 (insert (format "r%d = %d\n" rrr (ccl-get-next-code)))) | |
1004 | |
1005 (defun ccl-dump-set-array (rrr cc) | |
1006 (let ((rrr2 (logand cc 7)) | |
1007 (len (ash cc -3)) | |
1008 (i 0)) | |
1009 (insert (format "r%d = array[r%d] of length %d\n\t" | |
1010 rrr rrr2 len)) | |
1011 (while (< i len) | |
1012 (insert (format "%d " (ccl-get-next-code))) | |
1013 (setq i (1+ i))) | |
1014 (insert "\n"))) | |
1015 | |
1016 (defun ccl-dump-jump (ignore cc &optional address) | |
1017 (insert (format "jump to %d(" (+ (or address ccl-current-ic) cc))) | |
1018 (if (>= cc 0) | |
1019 (insert "+")) | |
1020 (insert (format "%d)\n" (1+ cc)))) | |
1021 | |
1022 (defun ccl-dump-jump-cond (rrr cc) | |
1023 (insert (format "if (r%d == 0), " rrr)) | |
1024 (ccl-dump-jump nil cc)) | |
1025 | |
1026 (defun ccl-dump-write-register-jump (rrr cc) | |
1027 (insert (format "write r%d, " rrr)) | |
1028 (ccl-dump-jump nil cc)) | |
1029 | |
1030 (defun ccl-dump-write-register-read-jump (rrr cc) | |
1031 (insert (format "write r%d, read r%d, " rrr rrr)) | |
1032 (ccl-dump-jump nil cc) | |
1033 (ccl-get-next-code) ; Skip dummy READ-JUMP | |
1034 ) | |
1035 | |
1036 (defun ccl-extract-arith-op (cc) | |
1037 (aref ccl-arith-table (ash cc -6))) | |
1038 | |
1039 (defun ccl-dump-write-expr-const (ignore cc) | |
1040 (insert (format "write (r%d %s %d)\n" | |
1041 (logand cc 7) | |
1042 (ccl-extract-arith-op cc) | |
1043 (ccl-get-next-code)))) | |
1044 | |
1045 (defun ccl-dump-write-expr-register (ignore cc) | |
1046 (insert (format "write (r%d %s r%d)\n" | |
1047 (logand cc 7) | |
1048 (ccl-extract-arith-op cc) | |
1049 (logand (ash cc -3) 7)))) | |
1050 | |
1051 (defun ccl-dump-insert-char (cc) | |
1052 (cond ((= cc ?\t) (insert " \"^I\"")) | |
1053 ((= cc ?\n) (insert " \"^J\"")) | |
1054 (t (insert (format " \"%c\"" cc))))) | |
1055 | |
1056 (defun ccl-dump-write-const-jump (ignore cc) | |
1057 (let ((address ccl-current-ic)) | |
1058 (insert "write char") | |
1059 (ccl-dump-insert-char (ccl-get-next-code)) | |
1060 (insert ", ") | |
1061 (ccl-dump-jump nil cc address))) | |
1062 | |
1063 (defun ccl-dump-write-const-read-jump (rrr cc) | |
1064 (let ((address ccl-current-ic)) | |
1065 (insert "write char") | |
1066 (ccl-dump-insert-char (ccl-get-next-code)) | |
1067 (insert (format ", read r%d, " rrr)) | |
1068 (ccl-dump-jump cc address) | |
1069 (ccl-get-next-code) ; Skip dummy READ-JUMP | |
1070 )) | |
1071 | |
1072 (defun ccl-dump-write-string-jump (ignore cc) | |
1073 (let ((address ccl-current-ic) | |
1074 (len (ccl-get-next-code)) | |
1075 (i 0)) | |
1076 (insert "write \"") | |
1077 (while (< i len) | |
1078 (let ((code (ccl-get-next-code))) | |
1079 (insert (ash code -16)) | |
1080 (if (< (1+ i) len) (insert (logand (ash code -8) 255))) | |
1081 (if (< (+ i 2) len) (insert (logand code 255)))) | |
1082 (setq i (+ i 3))) | |
1083 (insert "\", ") | |
1084 (ccl-dump-jump nil cc address))) | |
1085 | |
1086 (defun ccl-dump-write-array-read-jump (rrr cc) | |
1087 (let ((address ccl-current-ic) | |
1088 (len (ccl-get-next-code)) | |
1089 (i 0)) | |
1090 (insert (format "write array[r%d] of length %d,\n\t" rrr len)) | |
1091 (while (< i len) | |
1092 (ccl-dump-insert-char (ccl-get-next-code)) | |
1093 (setq i (1+ i))) | |
1094 (insert (format "\n\tthen read r%d, " rrr)) | |
1095 (ccl-dump-jump nil cc address) | |
1096 (ccl-get-next-code) ; Skip dummy READ-JUMP. | |
1097 )) | |
1098 | |
1099 (defun ccl-dump-read-jump (rrr cc) | |
1100 (insert (format "read r%d, " rrr)) | |
1101 (ccl-dump-jump nil cc)) | |
1102 | |
1103 (defun ccl-dump-branch (rrr len) | |
1104 (let ((jump-table-head ccl-current-ic) | |
1105 (i 0)) | |
1106 (insert (format "jump to array[r%d] of length %d\n\t" rrr len)) | |
1107 (while (<= i len) | |
1108 (insert (format "%d " (+ jump-table-head (ccl-get-next-code)))) | |
1109 (setq i (1+ i))) | |
1110 (insert "\n"))) | |
1111 | |
1112 (defun ccl-dump-read-register (rrr cc) | |
1113 (insert (format "read r%d (%d remaining)\n" rrr cc))) | |
1114 | |
1115 (defun ccl-dump-read-branch (rrr len) | |
1116 (insert (format "read r%d, " rrr)) | |
1117 (ccl-dump-branch rrr len)) | |
1118 | |
1119 (defun ccl-dump-write-register (rrr cc) | |
1120 (insert (format "write r%d (%d remaining)\n" rrr cc))) | |
1121 | |
1122 (defun ccl-dump-call (ignore cc) | |
1123 (insert (format "call subroutine #%d\n" cc))) | |
1124 | |
1125 (defun ccl-dump-write-const-string (rrr cc) | |
1126 (if (= rrr 0) | |
1127 (progn | |
1128 (insert "write char") | |
1129 (ccl-dump-insert-char cc) | |
1130 (newline)) | |
1131 (let ((len cc) | |
1132 (i 0)) | |
1133 (insert "write \"") | |
1134 (while (< i len) | |
1135 (let ((code (ccl-get-next-code))) | |
1136 (insert (format "%c" (lsh code -16))) | |
1137 (if (< (1+ i) len) | |
1138 (insert (format "%c" (logand (lsh code -8) 255)))) | |
1139 (if (< (+ i 2) len) | |
1140 (insert (format "%c" (logand code 255)))) | |
1141 (setq i (+ i 3)))) | |
1142 (insert "\"\n")))) | |
1143 | |
1144 (defun ccl-dump-write-array (rrr cc) | |
1145 (let ((i 0)) | |
1146 (insert (format "write array[r%d] of length %d\n\t" rrr cc)) | |
1147 (while (< i cc) | |
1148 (ccl-dump-insert-char (ccl-get-next-code)) | |
1149 (setq i (1+ i))) | |
1150 (insert "\n"))) | |
1151 | |
1152 (defun ccl-dump-end (&rest ignore) | |
1153 (insert "end\n")) | |
1154 | |
1155 (defun ccl-dump-set-assign-expr-const (rrr cc) | |
1156 (insert (format "r%d %s= %d\n" | |
1157 rrr | |
1158 (ccl-extract-arith-op cc) | |
1159 (ccl-get-next-code)))) | |
1160 | |
1161 (defun ccl-dump-set-assign-expr-register (rrr cc) | |
1162 (insert (format "r%d %s= r%d\n" | |
1163 rrr | |
1164 (ccl-extract-arith-op cc) | |
1165 (logand cc 7)))) | |
1166 | |
1167 (defun ccl-dump-set-expr-const (rrr cc) | |
1168 (insert (format "r%d = r%d %s %d\n" | |
1169 rrr | |
1170 (logand cc 7) | |
1171 (ccl-extract-arith-op cc) | |
1172 (ccl-get-next-code)))) | |
1173 | |
1174 (defun ccl-dump-set-expr-register (rrr cc) | |
1175 (insert (format "r%d = r%d %s r%d\n" | |
1176 rrr | |
1177 (logand cc 7) | |
1178 (ccl-extract-arith-op cc) | |
1179 (logand (ash cc -3) 7)))) | |
1180 | |
1181 (defun ccl-dump-jump-cond-expr-const (rrr cc) | |
1182 (let ((address ccl-current-ic)) | |
1183 (insert (format "if !(r%d %s %d), " | |
1184 rrr | |
1185 (aref ccl-arith-table (ccl-get-next-code)) | |
1186 (ccl-get-next-code))) | |
1187 (ccl-dump-jump nil cc address))) | |
1188 | |
1189 (defun ccl-dump-jump-cond-expr-register (rrr cc) | |
1190 (let ((address ccl-current-ic)) | |
1191 (insert (format "if !(r%d %s r%d), " | |
1192 rrr | |
1193 (aref ccl-arith-table (ccl-get-next-code)) | |
1194 (ccl-get-next-code))) | |
1195 (ccl-dump-jump nil cc address))) | |
1196 | |
1197 (defun ccl-dump-read-jump-cond-expr-const (rrr cc) | |
1198 (insert (format "read r%d, " rrr)) | |
1199 (ccl-dump-jump-cond-expr-const rrr cc)) | |
1200 | |
1201 (defun ccl-dump-read-jump-cond-expr-register (rrr cc) | |
1202 (insert (format "read r%d, " rrr)) | |
1203 (ccl-dump-jump-cond-expr-register rrr cc)) | |
1204 | |
1205 (defun ccl-dump-binary (ccl-code) | |
1206 (let ((len (length ccl-code)) | |
1207 (i 2)) | |
1208 (while (< i len) | |
1209 (let ((code (aref ccl-code i)) | |
1210 (j 27)) | |
1211 (while (>= j 0) | |
1212 (insert (if (= (logand code (ash 1 j)) 0) ?0 ?1)) | |
1213 (setq j (1- j))) | |
1214 (setq code (logand code 31)) | |
1215 (if (< code (length ccl-code-table)) | |
1216 (insert (format ":%s" (aref ccl-code-table code)))) | |
1217 (insert "\n")) | |
1218 (setq i (1+ i))))) | |
1219 | |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1220 (defun ccl-dump-ex-cmd (rrr cc) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1221 (let* ((RRR (logand cc ?\x7)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1222 (Rrr (logand (ash cc -3) ?\x7)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1223 (ex-op (aref ccl-extended-code-table (logand (ash cc -6) ?\x3fff)))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1224 (insert (format "<%s> " ex-op)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1225 (funcall (get ex-op 'ccl-dump-function) rrr RRR Rrr))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1226 |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1227 (defun ccl-dump-read-multibyte-character (rrr RRR Rrr) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1228 (insert (format "read-multibyte-character r%d r%d\n" RRR rrr))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1229 |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1230 (defun ccl-dump-write-multibyte-character (rrr RRR Rrr) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1231 (insert (format "write-multibyte-character r%d r%d\n" RRR rrr))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1232 |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1233 (defun ccl-dump-translate-character (rrr RRR Rrr) |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22127
diff
changeset
|
1234 (insert (format "translation table(r%d) r%d r%d\n" Rrr RRR rrr))) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1235 |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1236 (defun ccl-dump-translate-character-const-tbl (rrr RRR Rrr) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1237 (let ((tbl (ccl-get-next-code))) |
23771
0ed776e14a50
(ccl-dump-translate-character-const-tbl):
Kenichi Handa <handa@m17n.org>
parents:
23432
diff
changeset
|
1238 (insert (format "translation table(%S) r%d r%d\n" tbl RRR rrr)))) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1239 |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1240 (defun ccl-dump-lookup-int-const-tbl (rrr RRR Rrr) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1241 (let ((tbl (ccl-get-next-code))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1242 (insert (format "hash table(%S) r%d r%d\n" tbl RRR rrr)))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1243 |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1244 (defun ccl-dump-lookup-char-const-tbl (rrr RRR Rrr) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1245 (let ((tbl (ccl-get-next-code))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1246 (insert (format "hash table(%S) r%d r%d\n" tbl RRR rrr)))) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1247 |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1248 (defun ccl-dump-iterate-multiple-map (rrr RRR Rrr) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1249 (let ((notbl (ccl-get-next-code)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1250 (i 0) id) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1251 (insert (format "iterate-multiple-map r%d r%d\n" RRR rrr)) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1252 (insert (format "\tnumber of maps is %d .\n\t [" notbl)) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1253 (while (< i notbl) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1254 (setq id (ccl-get-next-code)) |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1255 (insert (format "%S" id)) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1256 (setq i (1+ i))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1257 (insert "]\n"))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1258 |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1259 (defun ccl-dump-map-multiple (rrr RRR Rrr) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1260 (let ((notbl (ccl-get-next-code)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1261 (i 0) id) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1262 (insert (format "map-multiple r%d r%d\n" RRR rrr)) |
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1263 (insert (format "\tnumber of maps and separators is %d\n\t [" notbl)) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1264 (while (< i notbl) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1265 (setq id (ccl-get-next-code)) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1266 (if (= id -1) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1267 (insert "]\n\t [") |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1268 (insert (format "%S " id))) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1269 (setq i (1+ i))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1270 (insert "]\n"))) |
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1271 |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1272 (defun ccl-dump-map-single (rrr RRR Rrr) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1273 (let ((id (ccl-get-next-code))) |
22127
dc00ef92855c
Change term translate-XXX-map to map-XXX
Kenichi Handa <handa@m17n.org>
parents:
21977
diff
changeset
|
1274 (insert (format "map-single r%d r%d map(%S)\n" RRR rrr id)))) |
20735
d97c44710cac
Comment about CCL syntax modified.
Kenichi Handa <handa@m17n.org>
parents:
18377
diff
changeset
|
1275 |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1276 |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46493
diff
changeset
|
1277 ;; CCL emulation staffs |
17052 | 1278 |
1279 ;; Not yet implemented. | |
1280 | |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1281 ;; Auto-loaded functions. |
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1282 |
17052 | 1283 ;;;###autoload |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1284 (defmacro declare-ccl-program (name &optional vector) |
17052 | 1285 "Declare NAME as a name of CCL program. |
1286 | |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1287 This macro exists for backward compatibility. In the old version of |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1288 Emacs, to compile a CCL program which calls another CCL program not |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1289 yet defined, it must be declared as a CCL program in advance. But, |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1290 now CCL program names are resolved not at compile time but before |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1291 execution. |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1292 |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1293 Optional arg VECTOR is a compiled CCL code of the CCL program." |
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1294 `(put ',name 'ccl-program-idx (register-ccl-program ',name ,vector))) |
17052 | 1295 |
1296 ;;;###autoload | |
1297 (defmacro define-ccl-program (name ccl-program &optional doc) | |
1298 "Set NAME the compiled code of CCL-PROGRAM. | |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1299 |
35299
ff1e51ba81cb
(define-ccl-program): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
35252
diff
changeset
|
1300 CCL-PROGRAM has this form: |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1301 (BUFFER_MAGNIFICATION |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1302 CCL_MAIN_CODE |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1303 [ CCL_EOF_CODE ]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1304 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1305 BUFFER_MAGNIFICATION is an integer value specifying the approximate |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1306 output buffer magnification size compared with the bytes of input data |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1307 text. If the value is zero, the CCL program can't execute `read' and |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1308 `write' commands. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1309 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1310 CCL_MAIN_CODE and CCL_EOF_CODE are CCL program codes. CCL_MAIN_CODE |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1311 executed at first. If there's no more input data when `read' command |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1312 is executed in CCL_MAIN_CODE, CCL_EOF_CODE is executed. If |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1313 CCL_MAIN_CODE is terminated, CCL_EOF_CODE is not executed. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1314 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1315 Here's the syntax of CCL program code in BNF notation. The lines |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1316 starting by two semicolons (and optional leading spaces) describe the |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1317 semantics. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1318 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1319 CCL_MAIN_CODE := CCL_BLOCK |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1320 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1321 CCL_EOF_CODE := CCL_BLOCK |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1322 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1323 CCL_BLOCK := STATEMENT | (STATEMENT [STATEMENT ...]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1324 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1325 STATEMENT := |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1326 SET | IF | BRANCH | LOOP | REPEAT | BREAK | READ | WRITE | CALL |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1327 | TRANSLATE | MAP | LOOKUP | END |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1328 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1329 SET := (REG = EXPRESSION) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1330 | (REG ASSIGNMENT_OPERATOR EXPRESSION) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1331 ;; The following form is the same as (r0 = integer). |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1332 | integer |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1333 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1334 EXPRESSION := ARG | (EXPRESSION OPERATOR ARG) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1335 |
37827
00b85403781e
(define-ccl-program): Fix a typo. From Pavel Janik <Pavel@Janik.cz>.
Eli Zaretskii <eliz@gnu.org>
parents:
36466
diff
changeset
|
1336 ;; Evaluate EXPRESSION. If the result is nonzero, execute |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1337 ;; CCL_BLOCK_0. Otherwise, execute CCL_BLOCK_1. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1338 IF := (if EXPRESSION CCL_BLOCK_0 CCL_BLOCK_1) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1339 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1340 ;; Evaluate EXPRESSION. Provided that the result is N, execute |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1341 ;; CCL_BLOCK_N. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1342 BRANCH := (branch EXPRESSION CCL_BLOCK_0 [CCL_BLOCK_1 ...]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1343 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1344 ;; Execute STATEMENTs until (break) or (end) is executed. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1345 LOOP := (loop STATEMENT [STATEMENT ...]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1346 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1347 ;; Terminate the most inner loop. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1348 BREAK := (break) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1349 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1350 REPEAT := |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1351 ;; Jump to the head of the most inner loop. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1352 (repeat) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1353 ;; Same as: ((write [REG | integer | string]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1354 ;; (repeat)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1355 | (write-repeat [REG | integer | string]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1356 ;; Same as: ((write REG [ARRAY]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1357 ;; (read REG) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1358 ;; (repeat)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1359 | (write-read-repeat REG [ARRAY]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1360 ;; Same as: ((write integer) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1361 ;; (read REG) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1362 ;; (repeat)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1363 | (write-read-repeat REG integer) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1364 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1365 READ := ;; Set REG_0 to a byte read from the input text, set REG_1 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1366 ;; to the next byte read, and so on. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1367 (read REG_0 [REG_1 ...]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1368 ;; Same as: ((read REG) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1369 ;; (if (REG OPERATOR ARG) CCL_BLOCK_0 CCL_BLOCK_1)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1370 | (read-if (REG OPERATOR ARG) CCL_BLOCK_0 CCL_BLOCK_1) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1371 ;; Same as: ((read REG) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1372 ;; (branch REG CCL_BLOCK_0 [CCL_BLOCK_1 ...])) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1373 | (read-branch REG CCL_BLOCK_0 [CCL_BLOCK_1 ...]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1374 ;; Read a character from the input text while parsing |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1375 ;; multibyte representation, set REG_0 to the charset ID of |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1376 ;; the character, set REG_1 to the code point of the |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1377 ;; character. If the dimension of charset is two, set REG_1 |
35252
496f65930f98
(define-ccl-program): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
30845
diff
changeset
|
1378 ;; to ((CODE0 << 7) | CODE1), where CODE0 is the first code |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1379 ;; point and CODE1 is the second code point. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1380 | (read-multibyte-character REG_0 REG_1) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1381 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1382 WRITE := |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1383 ;; Write REG_0, REG_1, ... to the output buffer. If REG_N is |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1384 ;; a multibyte character, write the corresponding multibyte |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1385 ;; representation. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1386 (write REG_0 [REG_1 ...]) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1387 ;; Same as: ((r7 = EXPRESSION) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1388 ;; (write r7)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1389 | (write EXPRESSION) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1390 ;; Write the value of `integer' to the output buffer. If it |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1391 ;; is a multibyte character, write the corresponding multibyte |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1392 ;; representation. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1393 | (write integer) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1394 ;; Write the byte sequence of `string' as is to the output |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1395 ;; buffer. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1396 | (write string) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1397 ;; Same as: (write string) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1398 | string |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1399 ;; Provided that the value of REG is N, write Nth element of |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1400 ;; ARRAY to the output buffer. If it is a multibyte |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1401 ;; character, write the corresponding multibyte |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1402 ;; representation. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1403 | (write REG ARRAY) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1404 ;; Write a multibyte representation of a character whose |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1405 ;; charset ID is REG_0 and code point is REG_1. If the |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1406 ;; dimension of the charset is two, REG_1 should be ((CODE0 << |
35252
496f65930f98
(define-ccl-program): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents:
30845
diff
changeset
|
1407 ;; 7) | CODE1), where CODE0 is the first code point and CODE1 |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1408 ;; is the second code point of the character. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1409 | (write-multibyte-character REG_0 REG_1) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1410 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1411 ;; Call CCL program whose name is ccl-program-name. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1412 CALL := (call ccl-program-name) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1413 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1414 ;; Terminate the CCL program. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1415 END := (end) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1416 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1417 ;; CCL registers that can contain any integer value. As r7 is also |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1418 ;; used by CCL interpreter, its value is changed unexpectedly. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1419 REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1420 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1421 ARG := REG | integer |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1422 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1423 OPERATOR := |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1424 ;; Normal arithmethic operators (same meaning as C code). |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1425 + | - | * | / | % |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1426 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1427 ;; Bitwize operators (same meaning as C code) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1428 | & | `|' | ^ |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1429 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1430 ;; Shifting operators (same meaning as C code) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1431 | << | >> |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1432 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1433 ;; (REG = ARG_0 <8 ARG_1) means: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1434 ;; (REG = ((ARG_0 << 8) | ARG_1)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1435 | <8 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1436 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1437 ;; (REG = ARG_0 >8 ARG_1) means: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1438 ;; ((REG = (ARG_0 >> 8)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1439 ;; (r7 = (ARG_0 & 255))) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1440 | >8 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1441 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1442 ;; (REG = ARG_0 // ARG_1) means: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1443 ;; ((REG = (ARG_0 / ARG_1)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1444 ;; (r7 = (ARG_0 % ARG_1))) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1445 | // |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1446 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1447 ;; Normal comparing operators (same meaning as C code) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1448 | < | > | == | <= | >= | != |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1449 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1450 ;; If ARG_0 and ARG_1 are higher and lower byte of Shift-JIS |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1451 ;; code, and CHAR is the corresponding JISX0208 character, |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1452 ;; (REG = ARG_0 de-sjis ARG_1) means: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1453 ;; ((REG = CODE0) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1454 ;; (r7 = CODE1)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1455 ;; where CODE0 is the first code point of CHAR, CODE1 is the |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1456 ;; second code point of CHAR. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1457 | de-sjis |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1458 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1459 ;; If ARG_0 and ARG_1 are the first and second code point of |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1460 ;; JISX0208 character CHAR, and SJIS is the correponding |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1461 ;; Shift-JIS code, |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1462 ;; (REG = ARG_0 en-sjis ARG_1) means: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1463 ;; ((REG = HIGH) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1464 ;; (r7 = LOW)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1465 ;; where HIGH is the higher byte of SJIS, LOW is the lower |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1466 ;; byte of SJIS. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1467 | en-sjis |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1468 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1469 ASSIGNMENT_OPERATOR := |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1470 ;; Same meaning as C code |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1471 += | -= | *= | /= | %= | &= | `|=' | ^= | <<= | >>= |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1472 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1473 ;; (REG <8= ARG) is the same as: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1474 ;; ((REG <<= 8) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1475 ;; (REG |= ARG)) |
47939
5f47d61ffbdc
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
46493
diff
changeset
|
1476 | <8= |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1477 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1478 ;; (REG >8= ARG) is the same as: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1479 ;; ((r7 = (REG & 255)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1480 ;; (REG >>= 8)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1481 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1482 ;; (REG //= ARG) is the same as: |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1483 ;; ((r7 = (REG % ARG)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1484 ;; (REG /= ARG)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1485 | //= |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1486 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1487 ARRAY := `[' integer ... `]' |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1488 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1489 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1490 TRANSLATE := |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1491 (translate-character REG(table) REG(charset) REG(codepoint)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1492 | (translate-character SYMBOL REG(charset) REG(codepoint)) |
36037 | 1493 ;; SYMBOL must refer to a table defined by `define-translation-table'. |
46493
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1494 LOOKUP := |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1495 (lookup-character SYMBOL REG(charset) REG(codepoint)) |
109eee3b7af4
(ccl-command-table): Add lookup-integer,
Dave Love <fx@gnu.org>
parents:
38414
diff
changeset
|
1496 | (lookup-integer SYMBOL REG(integer)) |
51168 | 1497 ;; SYMBOL refers to a table defined by `define-translation-hash-table'. |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1498 MAP := |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1499 (iterate-multiple-map REG REG MAP-IDs) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1500 | (map-multiple REG REG (MAP-SET)) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1501 | (map-single REG REG MAP-ID) |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1502 MAP-IDs := MAP-ID ... |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1503 MAP-SET := MAP-IDs | (MAP-IDs) MAP-SET |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1504 MAP-ID := integer |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1505 " |
17052 | 1506 `(let ((prog ,(ccl-compile (eval ccl-program)))) |
1507 (defconst ,name prog ,doc) | |
1508 (put ',name 'ccl-program-idx (register-ccl-program ',name prog)) | |
1509 nil)) | |
1510 | |
1511 ;;;###autoload | |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1512 (defmacro check-ccl-program (ccl-program &optional name) |
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1513 "Check validity of CCL-PROGRAM. |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1514 If CCL-PROGRAM is a symbol denoting a CCL program, return |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1515 CCL-PROGRAM, else return nil. |
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1516 If CCL-PROGRAM is a vector and optional arg NAME (symbol) is supplied, |
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1517 register CCL-PROGRAM by name NAME, and return NAME." |
25064
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1518 `(if (ccl-program-p ,ccl-program) |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1519 (if (vectorp ,ccl-program) |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1520 (progn |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1521 (register-ccl-program ,name ,ccl-program) |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1522 ,name) |
206f04753cc1
(ccl-embed-symbol): New function.
Kenichi Handa <handa@m17n.org>
parents:
24152
diff
changeset
|
1523 ,ccl-program))) |
21661
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1524 |
f763b61886ce
(ccl-compile-unify-character): Inhibit
Kenichi Handa <handa@m17n.org>
parents:
21645
diff
changeset
|
1525 ;;;###autoload |
17052 | 1526 (defun ccl-execute-with-args (ccl-prog &rest args) |
1527 "Execute CCL-PROGRAM with registers initialized by the remaining args. | |
30845
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1528 The return value is a vector of resulting CCL registers. |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1529 |
dcfcae58d8d6
(declare-ccl-program): Docstring modified.
Kenichi Handa <handa@m17n.org>
parents:
30705
diff
changeset
|
1530 See the documentation of `define-ccl-program' for the detail of CCL program." |
17052 | 1531 (let ((reg (make-vector 8 0)) |
1532 (i 0)) | |
1533 (while (and args (< i 8)) | |
1534 (if (not (integerp (car args))) | |
1535 (error "Arguments should be integer")) | |
1536 (aset reg i (car args)) | |
1537 (setq args (cdr args) i (1+ i))) | |
1538 (ccl-execute ccl-prog reg) | |
1539 reg)) | |
1540 | |
1541 (provide 'ccl) | |
1542 | |
52401 | 1543 ;;; arch-tag: 836bcd27-63a1-4a56-b232-1145ecf823fb |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37827
diff
changeset
|
1544 ;;; ccl.el ends here |