comparison lisp/mule/mule-ccl.el @ 2757:7844ab77b582

[xemacs-hg @ 2005-05-05 17:10:19 by aidan] Some spelling and grammar fixes.
author aidan
date Thu, 05 May 2005 17:10:54 +0000
parents ecf1ebac70d8
children d1754e7f0cea
comparison
equal deleted inserted replaced
2756:f441e940eed8 2757:7844ab77b582
1236 Optional arg VECTOR is a compiled CCL code of the CCL program." 1236 Optional arg VECTOR is a compiled CCL code of the CCL program."
1237 `(put ',name 'ccl-program-idx (register-ccl-program ',name ,vector))) 1237 `(put ',name 'ccl-program-idx (register-ccl-program ',name ,vector)))
1238 1238
1239 ;;;###autoload 1239 ;;;###autoload
1240 (defmacro define-ccl-program (name ccl-program &optional doc) 1240 (defmacro define-ccl-program (name ccl-program &optional doc)
1241 "Set NAME the compiled code of CCL-PROGRAM. 1241 "Set NAME to be the compiled CCL code of CCL-PROGRAM.
1242 1242
1243 CCL-PROGRAM has this form: 1243 CCL-PROGRAM has this form:
1244 (BUFFER_MAGNIFICATION 1244 (BUFFER_MAGNIFICATION
1245 CCL_MAIN_CODE 1245 CCL_MAIN_CODE
1246 [ CCL_EOF_CODE ]) 1246 [ CCL_EOF_CODE ])
1248 BUFFER_MAGNIFICATION is an integer value specifying the approximate 1248 BUFFER_MAGNIFICATION is an integer value specifying the approximate
1249 output buffer magnification size compared with the bytes of input data 1249 output buffer magnification size compared with the bytes of input data
1250 text. If the value is zero, the CCL program can't execute `read' and 1250 text. If the value is zero, the CCL program can't execute `read' and
1251 `write' commands. 1251 `write' commands.
1252 1252
1253 CCL_MAIN_CODE and CCL_EOF_CODE are CCL program codes. CCL_MAIN_CODE 1253 CCL_MAIN_CODE and CCL_EOF_CODE are CCL program codes. CCL_MAIN_CODE is
1254 executed at first. If there's no more input data when `read' command 1254 executed first. If there are no more input data when a `read' command is
1255 is executed in CCL_MAIN_CODE, CCL_EOF_CODE is executed. If 1255 executed in CCL_MAIN_CODE, CCL_EOF_CODE is executed. If CCL_MAIN_CODE is
1256 CCL_MAIN_CODE is terminated, CCL_EOF_CODE is not executed. 1256 terminated, CCL_EOF_CODE is not executed.
1257 1257
1258 Here's the syntax of CCL program code in BNF notation. The lines 1258 Here's the syntax of CCL program code in BNF notation. The lines starting
1259 starting by two semicolons (and optional leading spaces) describe the 1259 with two semicolons (and optional leading spaces) describe the semantics.
1260 semantics.
1261 1260
1262 CCL_MAIN_CODE := CCL_BLOCK 1261 CCL_MAIN_CODE := CCL_BLOCK
1263 1262
1264 CCL_EOF_CODE := CCL_BLOCK 1263 CCL_EOF_CODE := CCL_BLOCK
1265 1264
1274 ;; The following form is the same as (r0 = INT-OR-CHAR). 1273 ;; The following form is the same as (r0 = INT-OR-CHAR).
1275 | INT-OR-CHAR 1274 | INT-OR-CHAR
1276 1275
1277 EXPRESSION := ARG | (EXPRESSION OPERATOR ARG) 1276 EXPRESSION := ARG | (EXPRESSION OPERATOR ARG)
1278 1277
1279 ;; Evaluate EXPRESSION. If the result is nonzeor, execute 1278 ;; Evaluate EXPRESSION. If the result is nonzero, execute
1280 ;; CCL_BLOCK_0. Otherwise, execute CCL_BLOCK_1. 1279 ;; CCL_BLOCK_0. Otherwise, execute CCL_BLOCK_1.
1281 IF := (if EXPRESSION CCL_BLOCK_0 [CCL_BLOCK_1]) 1280 IF := (if EXPRESSION CCL_BLOCK_0 [CCL_BLOCK_1])
1282 1281
1283 ;; Evaluate EXPRESSION. Provided that the result is N, execute 1282 ;; Evaluate EXPRESSION. Provided that the result is N, execute
1284 ;; CCL_BLOCK_N. 1283 ;; CCL_BLOCK_N.
1285 BRANCH := (branch EXPRESSION CCL_BLOCK_0 [CCL_BLOCK_1 ...]) 1284 BRANCH := (branch EXPRESSION CCL_BLOCK_0 [CCL_BLOCK_1 ...])
1286 1285
1287 ;; Execute STATEMENTs until (break) or (end) is executed. 1286 ;; Execute STATEMENTs until (break) or (end) is executed.
1288 LOOP := (loop STATEMENT [STATEMENT ...]) 1287 LOOP := (loop STATEMENT [STATEMENT ...])
1289 1288
1290 ;; Terminate the most inner loop. 1289 ;; Terminate the innermost loop.
1291 BREAK := (break) 1290 BREAK := (break)
1292 1291
1293 REPEAT := 1292 REPEAT :=
1294 ;; Jump to the head of the most inner loop. 1293 ;; Jump to the head of the innermost loop.
1295 (repeat) 1294 (repeat)
1296 ;; Same as: ((write [REG | INT-OR-CHAR | string]) 1295 ;; Same as: ((write [REG | INT-OR-CHAR | string])
1297 ;; (repeat)) 1296 ;; (repeat))
1298 | (write-repeat [REG | INT-OR-CHAR | string]) 1297 | (write-repeat [REG | INT-OR-CHAR | string])
1299 ;; Same as: ((write REG [ARRAY]) 1298 ;; Same as: ((write REG [ARRAY])
1304 ;; (read REG) 1303 ;; (read REG)
1305 ;; (repeat)) 1304 ;; (repeat))
1306 | (write-read-repeat REG INT-OR-CHAR) 1305 | (write-read-repeat REG INT-OR-CHAR)
1307 1306
1308 READ := ;; Set REG_0 to a byte read from the input text, set REG_1 1307 READ := ;; Set REG_0 to a byte read from the input text, set REG_1
1309 ;; to the next byte read, and so on. 1308 ;; to the next byte read, and so on. Note that \"byte\" here means
1309 ;; \"some octet from XEmacs' internal representation\", which may
1310 ;; not be that useful to you when non-ASCII characters are involved.
1311 ;;
1312 ;; Yes, this is exactly the opposite of what (write ...) does.
1310 (read REG_0 [REG_1 ...]) 1313 (read REG_0 [REG_1 ...])
1311 ;; Same as: ((read REG) 1314 ;; Same as: ((read REG)
1312 ;; (if (REG OPERATOR ARG) CCL_BLOCK_0 CCL_BLOCK_1)) 1315 ;; (if (REG OPERATOR ARG) CCL_BLOCK_0 CCL_BLOCK_1))
1313 | (read-if (REG OPERATOR ARG) CCL_BLOCK_0 [CCL_BLOCK_1]) 1316 | (read-if (REG OPERATOR ARG) CCL_BLOCK_0 [CCL_BLOCK_1])
1314 ;; Same as: ((read REG) 1317 ;; Same as: ((read REG)
1315 ;; (branch REG CCL_BLOCK_0 [CCL_BLOCK_1 ...])) 1318 ;; (branch REG CCL_BLOCK_0 [CCL_BLOCK_1 ...]))
1316 | (read-branch REG CCL_BLOCK_0 [CCL_BLOCK_1 ...]) 1319 | (read-branch REG CCL_BLOCK_0 [CCL_BLOCK_1 ...])
1317 ;; Read a character from the input text while parsing 1320 ;; Read a character from the input text, splitting it into its
1318 ;; multibyte representation, set REG_0 to the charset ID of 1321 ;; multibyte representation. Set REG_0 to the charset ID of the
1319 ;; the character, set REG_1 to the code point of the 1322 ;; character, and set REG_1 to the code point of the character. If
1320 ;; character. If the dimension of charset is two, set REG_1 1323 ;; the dimension of charset is two, set REG_1 to ((CODE0 << 8) |
1321 ;; to ((CODE0 << 8) | CODE1), where CODE0 is the first code 1324 ;; CODE1), where CODE0 is the first code point and CODE1 is the
1322 ;; point and CODE1 is the second code point. 1325 ;; second code point.
1323 | (read-multibyte-character REG_0 REG_1) 1326 | (read-multibyte-character REG_0 REG_1)
1324 1327
1325 WRITE := 1328 WRITE :=
1326 ;; Write REG_0, REG_1, ... to the output buffer. If REG_N is 1329 ;; Write REG_0, REG_1, ... to the output buffer. If REG_N is
1327 ;; a multibyte character, write the corresponding multibyte 1330 ;; a multibyte character, write the corresponding multibyte
1354 | (write-multibyte-character REG_0 REG_1) 1357 | (write-multibyte-character REG_0 REG_1)
1355 1358
1356 ;; Call CCL program whose name is ccl-program-name. 1359 ;; Call CCL program whose name is ccl-program-name.
1357 CALL := (call ccl-program-name) 1360 CALL := (call ccl-program-name)
1358 1361
1359 TRANSLATE := 1362 TRANSLATE := ;; Not implemented under XEmacs.
1360 (translate-character REG(table) REG(charset) REG(codepoint)) 1363 (translate-character REG(table) REG(charset) REG(codepoint))
1361 | (translate-character SYMBOL REG(charset) REG(codepoint)) 1364 | (translate-character SYMBOL REG(charset) REG(codepoint))
1362 MAP := 1365 MAP :=
1363 (iterate-multiple-map REG REG MAP-IDs) 1366 (iterate-multiple-map REG REG MAP-IDs)
1364 | (map-multiple REG REG (MAP-SET)) 1367 | (map-multiple REG REG (MAP-SET))
1368 MAP-ID := INT-OR-CHAR 1371 MAP-ID := INT-OR-CHAR
1369 1372
1370 ;; Terminate the CCL program. 1373 ;; Terminate the CCL program.
1371 END := (end) 1374 END := (end)
1372 1375
1373 ;; CCL registers that can contain any integer value. As r7 is also 1376 ;; CCL registers. These can contain any integer value. As r7 is used by CCL
1374 ;; used by CCL interpreter, its value is changed unexpectedly. 1377 ;; interpreter itself, its value change unexpectedly.
1375 REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7 1378 REG := r0 | r1 | r2 | r3 | r4 | r5 | r6 | r7
1376 1379
1377 ARG := REG | INT-OR-CHAR 1380 ARG := REG | INT-OR-CHAR
1378 1381
1379 OPERATOR := 1382 OPERATOR :=
1380 ;; Normal arithmethic operators (same meaning as C code). 1383 ;; Normal arithmetical operators (same meaning as C code).
1381 + | - | * | / | % 1384 + | - | * | / | %
1382 1385
1383 ;; Bitwize operators (same meaning as C code) 1386 ;; Bitwise operators (same meaning as C code)
1384 | & | `|' | ^ 1387 | & | `|' | ^
1385 1388
1386 ;; Shifting operators (same meaning as C code) 1389 ;; Shifting operators (same meaning as C code)
1387 | << | >> 1390 | << | >>
1388 1391