From: morioka Date: Sun, 30 Aug 1998 12:23:17 +0000 (+0000) Subject: Sync up with egg-980712. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=elisp%2Fegg.git Sync up with egg-980712. --- diff --git a/ChangeLog b/ChangeLog index 3829a2c..bbcbd66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,81 @@ +1998-07-12 NIIBE Yutaka + + * egg-mlh.el (mlh-space-bar-backward-henkan): Don't test against + egg-conversion-backend-alist. + + * egg/wnn.el (wnn-fini-lang): Reneme from wnn-fini. + (wnn-fini): New implementation calling wnn-fini-lang. + + (wnn-close): Call wnn-fini-lang. + (wnn-dictionary-save): Ditto. + + * egg/canna.el (canna-fini): Delete LANG argument. + * egg/sj3.el (sj3-fini): Ditto. + + * egg-cnv.el (egg-set-conversion-backend): Removed. + + * egg/sj3.el (sj3-start-conversion): Signal error on non-supported + language. + * egg/canna.el (canna-start-conversion): Likewise. + * egg/wnn.el (wnn-start-conversion): Likewise. + + * egg-cnv.el (egg-convert-region): Add handler for + lang-not-supported. + + * egg/wnn.el (egg-activate-wnn): load wnnrpc here conditionally. + * egg/sj3.el: Likewise. + * egg/canna.el: Likewise. + + * egg.el (egg-support-languages, egg-set-support-languages): Removed. + (egg-mode): Don't call egg-set-conversion-backend. + * egg/{canna.el, wnn.el, sj3.el}: Don't call egg-support-languages. + + * egg-cnv.el (egg-set-current-backend): Removed. + (egg-initialize-backend, egg-start-conversion, + egg-start-reverse-conversion): Don't call egg-set-current-backend. + (egg-conversion-backend-null): Rename from *-other-languages. + (egg-conversion-backend-alist): Removed. + (egg-conversion-backend): Not buffer local. + (egg-finalize-backend-alist): Removed. + +1998-07-10 NIIBE Yutaka + + * egg-cnv.el (egg-start-conversion-failure-hook): New Variable. + (egg-start-conversion-failure-fallback): New Function. + (egg-convert-region): Handle error and hook on failure. + + * egg/sj3.el (sj3-open): Remove bogus setq-s of sj3-sys-dict-list, + sj3-user-dict-list. + + * egg-mlh.el (mlh-space-bar-backward-henkan): Don't emit message + "converting...", as it may flush out error message. + + * egg/sj3rpc.el ("egg-com", "egg/sj3"): Require on compilation. + (sj3rpc-open): Failure when version is different. + +1998-07-03 KATAYAMA Yoshio + + * its/erpin.el, its/hangul.el, its/hankata.el, its/hira.el, + its/jeonkak.el, its/kata.el, its/pinyin.el, its/quanjiao.el, + its/thai.el, its/zenkaku.el: Updated using new its-*. + + * its.el (define-its-state-machine): Rewritten. + (define-its-compiled-map): Deleted. + (define-its-state-machine-append): Rewritten. + (its-defrule): Rewritten. + (its-defrule*): Rewritten. + (its-parent-states): New Variable. + (its-goto-state): Remove 2nd optional argument INITIAL-STATE. + (its-set-interim-terminal-state): New Function. + (its-make-next-state): Remove 2nd argument KEYSEQ. + +1998-07-01 NIIBE Yutaka + + * egg-mlh.el (mlh-hira-to-kata): Removed. Doesn't work any more. + (mlh-katakana): Use japanese-katakana-region. + + * egg-cnv.el (egg-conversion-map): Add again mapping for "/". + 1998-06-27 KATAYAMA Yoshio * egg-cnv.el (egg-abort-conversion): Bug fix. diff --git a/egg-cnv.el b/egg-cnv.el index a996838..515fb91 100644 --- a/egg-cnv.el +++ b/egg-cnv.el @@ -1,4 +1,4 @@ -pn;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture +;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture ;; Copyright (C) 1997, 1998 Mule Project, ;; Powered by Electrotechnical Laboratory, JAPAN. @@ -47,74 +47,60 @@ pn;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture bunsetsu-info)) ;; -(defconst egg-conversion-backend-other-languages - [ egg-init-other-languages - - egg-start-conversion-other-languages - egg-get-bunsetsu-converted-other-languages - egg-get-bunsetsu-source-other-languages - egg-list-candidates-other-languages - egg-get-number-of-candidates-other-languages - egg-get-current-candidate-number-other-languages - egg-get-all-candidates-other-languages - egg-decide-candidate-other-languages - egg-change-bunsetsu-length-other-languages - egg-end-conversion-other-languages +(defconst egg-conversion-backend-null + [ egg-init-null + + egg-start-conversion-null + egg-get-bunsetsu-converted-null + egg-get-bunsetsu-source-null + egg-list-candidates-null + egg-get-number-of-candidates-null + egg-get-current-candidate-number-null + egg-get-all-candidates-null + egg-decide-candidate-null + egg-change-bunsetsu-length-null + egg-end-conversion-null nil - egg-fini-other-languages + egg-fini-null ]) -(defun egg-init-other-languages () - ) +(defun egg-init-null () + ) -(defun egg-start-conversion-other-languages (yomi-string language) - (setq egg-conversion-backend egg-conversion-backend-other-languages) +(defun egg-start-conversion-null (yomi-string language) (list yomi-string)) -(defun egg-get-bunsetsu-converted-other-languages (bunsetsu-info) +(defun egg-get-bunsetsu-converted-null (bunsetsu-info) bunsetsu-info) -(defun egg-get-bunsetsu-source-other-languages (bunsetsu-info) +(defun egg-get-bunsetsu-source-null (bunsetsu-info) bunsetsu-info) -(defun egg-list-candidates-other-languages (bunsetsu-info prev-bunsetsu-info) +(defun egg-list-candidates-null (bunsetsu-info prev-bunsetsu-info) 1) -(defun egg-get-number-of-candidates-other-languages (bunsetsu-info) +(defun egg-get-number-of-candidates-null (bunsetsu-info) 1) -(defun egg-get-current-candidate-number-other-languages (bunsetsu-info) +(defun egg-get-current-candidate-number-null (bunsetsu-info) 0) -(defun egg-get-all-candidates-other-languages (bunsetsu-info) +(defun egg-get-all-candidates-null (bunsetsu-info) (list bunsetsu-info)) -(defun egg-decide-candidate-other-languages (bunsetsu-info candidate-pos) +(defun egg-decide-candidate-null (bunsetsu-info candidate-pos) bunsetsu-info) -(defun egg-change-bunsetsu-length-other-languages (b0 b1 b2 len) +(defun egg-change-bunsetsu-length-null (b0 b1 b2 len) (let ((s (concat b1 b2))) (set-text-properties 0 (length s) nil s) (if (= len (length s)) (list s) (list (substring s 0 len) (substring s len))))) -(defun egg-end-conversion-other-languages (bunsetsu-info-list abort) +(defun egg-end-conversion-null (bunsetsu-info-list abort) nil) -(defun egg-fini-other-languages (language) +(defun egg-fini-null (language) nil) -(defvar egg-conversion-backend-alist nil) -(make-variable-buffer-local 'egg-conversion-backend-alist) (defvar egg-conversion-backend nil) -(make-variable-buffer-local 'egg-conversion-backend) - -(defvar egg-finalize-backend-alist nil) - -(defun egg-set-current-backend (language) - (setq egg-conversion-backend - (cdr (assq language egg-conversion-backend-alist))) - (if (null egg-conversion-backend) - (setq egg-conversion-backend egg-conversion-backend-other-languages))) (defun egg-initialize-backend (language) - (egg-set-current-backend language) (funcall (aref egg-conversion-backend 0))) (defun egg-start-conversion (yomi-string language) - (egg-set-current-backend language) (funcall (aref egg-conversion-backend 1) yomi-string language)) (defun egg-get-bunsetsu-converted (bunsetsu-info) (funcall (aref egg-conversion-backend 2) bunsetsu-info)) @@ -135,35 +121,12 @@ pn;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture (defun egg-end-conversion (bunsetsu-info-list abort) (funcall (aref egg-conversion-backend 10) bunsetsu-info-list abort)) (defun egg-start-reverse-conversion (yomi-string language) - (egg-set-current-backend language) (if (aref egg-conversion-backend 11) (funcall (aref egg-conversion-backend 11) yomi-string language) (beep))) (defun egg-finalize-backend () - (let ((alist egg-finalize-backend-alist)) - (while alist - (funcall (car (car (car alist))) (cdr (car (car alist)))) - (setq alist (cdr alist))))) - -(defun egg-set-conversion-backend (backend langs &optional force) - (let (pair) - (if backend - (setq egg-conversion-backend backend) - (setq backend egg-conversion-backend)) - (while langs - (setq pair (assoc (car langs) egg-conversion-backend-alist)) - (cond - ((null pair) - (setq egg-conversion-backend-alist - (cons (cons (car langs) backend) egg-conversion-backend-alist))) - (force - (setcdr pair backend))) - (setq pair (cons (aref backend (1- (length backend))) (car langs))) - (if (null (assoc pair egg-finalize-backend-alist)) - (setq egg-finalize-backend-alist - (cons (list pair) egg-finalize-backend-alist))) - (setq langs (cdr langs))))) + (aref egg-conversion-backend 12)) (defvar egg-conversion-open "|" "*$B%U%'%s%9$N;OE@$r<($9J8;zNs(B (1 $BJ8;z0J>e(B)") (defvar egg-conversion-close "|" "*$B%U%'%s%9$N=*E@$r<($9J8;zNs(B (1 $BJ8;z0J>e(B)") @@ -177,12 +140,20 @@ pn;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture (assq t egg-conversion-face))))) (if face (cdr face) egg-conversion-face))) +(defvar egg-start-conversion-failure-hook + '(egg-start-conversion-failure-fallback) + "Hook which runs on failure of conversion.") + +;; SAIGO no shudan +(defun egg-start-conversion-failure-fallback (language) + (setq egg-conversion-backend egg-conversion-backend-null)) + ;; (defun egg-convert-region (start end) (interactive "r") (let ((source (buffer-substring start end)) (no-prop-source (buffer-substring-no-properties start end)) - bunsetsu-info-list len result i j s) + len result i j s) (if (>= start end) ;; nothing to do nil @@ -190,11 +161,6 @@ pn;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture (let ((inhibit-read-only t)) (its-define-select-keys egg-conversion-map) (goto-char start) - ;; XXX: Why make OPEN&CLOSE string every time when - ;; this function is invoked? Any Reason? - ;; For me it's matter of user costomization - ;; of setting egg-conversion-open/egg-conversion-close - ;; it can be string of properties at the beginning, isn't it? (setq s (copy-sequence egg-conversion-open) len (length s)) (set-text-properties 0 len @@ -222,18 +188,29 @@ pn;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture (while (< i len) (setq egg-current-language (get-text-property i 'egg-lang source) j (egg-next-single-property-change i 'egg-lang source len)) - (condition-case result - (setq bunsetsu-info-list (egg-start-conversion - (substring no-prop-source i j) - egg-current-language)) - (error ; XXX: catching all error is BADBADBAD - (setq bunsetsu-info-list (egg-start-conversion-other-languages - (substring no-prop-source i j) - egg-current-language)) - (message "egg %s backend: %s" - egg-current-language (nth 1 result)))) - (egg-insert-bunsetsu-list bunsetsu-info-list - (if (< j len) 'contine t)) + (let (bunsetsu-info-list) + (while (null bunsetsu-info-list) + (condition-case err + (setq bunsetsu-info-list (egg-start-conversion + (substring no-prop-source i j) + egg-current-language)) + ;; Don't catch programming error + (lang-not-supported + (message "Language not supported: %s" egg-current-language) + (ding) + (setq bunsetsu-info-list + (egg-start-conversion-null + (substring no-prop-source i j) + egg-current-language))) + (file-error + (message "Error on %s backend: %s" + egg-current-language (nth 1 err)) + (ding) + (sit-for 1) + (run-hook-with-args-until-success + 'egg-start-conversion-failure-hook egg-current-language)))) + (egg-insert-bunsetsu-list bunsetsu-info-list + (if (< j len) 'contine t))) (setq i j)) (goto-char start))))) @@ -369,6 +346,7 @@ pn;;; egg-cnv.el --- Conversion Backend in Egg Input Method Architecture (define-key map [right] 'egg-forward-bunsetsu) (define-key map [left] 'egg-backward-bunsetsu) (define-key map " " 'egg-next-candidate) + (define-key map "/" 'egg-exit-conversion) map) "Keymap for EGG Conversion mode.") diff --git a/egg-mlh.el b/egg-mlh.el index 1c9aefe..e3f8297 100644 --- a/egg-mlh.el +++ b/egg-mlh.el @@ -43,7 +43,7 @@ Or else, execute command that space-bar invokes usually." (let ((henkan-begin nil) (inhibit-henkan t) (its-disable-special-action t)) - (if (null (assq 'Japanese egg-conversion-backend-alist)) + (if (null egg-conversion-backend) (progn (setq egg-mode-preference nil) (activate-input-method (concat "japanese-egg-" mlh-default-backend))) @@ -53,11 +53,7 @@ Or else, execute command that space-bar invokes usually." (if henkan-begin (if (or inhibit-henkan (= henkan-begin (point))) (egg-do-auto-fill) - (progn - (message "Converting...") - (sit-for 0) - (egg-convert-region henkan-begin (point)) - (message "") )) + (egg-convert-region henkan-begin (point))) (setq this-command 'self-insert-command) (call-interactively 'self-insert-command)))) @@ -488,10 +484,7 @@ CHAR. MNEMONIC CONVERSION SCHEME (goto-char end-marker) (forward-char -2) (its-translate-region-internal beg (point)) - (insert (mlh-hira-to-kata - (prog1 - (buffer-substring beg (point)) - (delete-region beg (point))))) + (japanese-katakana-region beg (point)) (delete-region (point) end-marker) (if (null henkan-begin) (setq henkan-begin beg))) @@ -507,15 +500,6 @@ CHAR. MNEMONIC CONVERSION SCHEME (if (null henkan-begin) (setq henkan-begin beg))) -(defun mlh-hira-to-kata (str) - "Convert hiragana to katakana in STR." - (let ((result (copy-sequence str)) - (i 0)) - (while (setq i (string-match "[$B$!(B-$B$s(B]" str i)) - (aset result (1+ i) ?\245) - (setq i (+ i 3))) - result)) - (defun mlh-hangul () (forward-char -1) (skip-chars-backward "a-zEO-RTW,.[]") diff --git a/egg.el b/egg.el index 601c981..474f59b 100644 --- a/egg.el +++ b/egg.el @@ -61,7 +61,6 @@ (if (null (string= (car arg) egg-last-method-name)) (progn (funcall (nth 1 arg)) - (egg-set-conversion-backend nil (list its-current-language) t) (setq egg-default-language its-current-language))) (setq egg-last-method-name (car arg)) (use-local-map (if egg-mode-preference @@ -76,7 +75,8 @@ "Generate modefull keymap for EGG mode." (let ((map (make-sparse-keymap)) (i 33)) - (define-key map "\C-_" 'egg-jis-code-input) + ;; BAD BAD BAD it should be UNDO + ;; (define-key map "\C-_" 'egg-jis-code-input) (while (< i 127) (define-key map (vector i) 'egg-self-insert-char) (setq i (1+ i))) @@ -252,19 +252,11 @@ (require 'egg-mlh) (require 'egg-cnv) (require 'egg-com) -(require 'custom) +(require 'custom) ; Really? (defgroup egg nil "Tamagotchy --- EGG Versio 4.0") -(defvar egg-support-languages nil) - -(defun egg-set-support-languages (langs) - (while langs - (if (null (member (car langs) egg-support-languages)) - (setq egg-support-languages (cons (car langs) egg-support-languages))) - (setq langs (cdr langs)))) - (add-hook 'kill-emacs-hook 'egg-kill-emacs-function) (defun egg-kill-emacs-function () (egg-finalize-backend)) diff --git a/egg/canna.el b/egg/canna.el index 80f04b6..dfa8014 100644 --- a/egg/canna.el +++ b/egg/canna.el @@ -31,8 +31,6 @@ (require 'egg-edep) -(defconst canna-support-languages '(Japanese)) - (eval-when-compile (defmacro CANNA-const (c) (cond ((eq c 'FileNotExist) xxxxxxxxxxxxxx) @@ -182,8 +180,10 @@ (defun canna-start-conversion (yomi lang) "Convert YOMI string to kanji, and enter conversion mode. Return the list of bunsetsu." - (let ((env (canna-get-environment))) - (cannarpc-begin-conversion env yomi))) + (if (eq lang 'Japanese) + (let ((env (canna-get-environment))) + (cannarpc-begin-conversion env yomi)) + (signal 'lang-not-supported))) (defun canna-end-conversion (bunsetsu-list abort) (let* ((env (cannabunsetsu-get-env (car bunsetsu-list))) @@ -267,21 +267,18 @@ Return the list of bunsetsu." (list bunsetsu1)))) ;;;;;;;;;;;;;; MADAMADA -(defun canna-fini (lang) +(defun canna-fini () ) ;;; setup - (require 'egg) -(load "egg/cannarpc") ;;;###autoload (defun egg-activate-canna (&rest arg) "Activate CANNA backend of Tamagotchy." - (egg-set-support-languages canna-support-languages) - (egg-set-conversion-backend canna-conversion-backend - canna-support-languages - nil) + (setq egg-conversion-backend canna-conversion-backend) + (if (not (fboundp 'cannarpc-open)) + (load-library "egg/canna")) (apply 'egg-mode arg)) ;;; egg/canna.el ends here. diff --git a/egg/sj3.el b/egg/sj3.el index 865f42b..0827c33 100644 --- a/egg/sj3.el +++ b/egg/sj3.el @@ -31,8 +31,6 @@ (require 'egg-edep) -(defconst sj3-support-languages '(Japanese)) - (eval-when-compile (defmacro SJ3-const (c) (cond ((eq c 'FileNotExist) 35) @@ -57,7 +55,7 @@ ]) (defvar sj3-server-port 3000 "Port number of SJ3 server") -(defvar sj3-stdy-size 0 "STDYSIZE of SJ3 server") +(defvar sj3-stdy-size 0 "STDYSIZE of SJ3 server (will be set on connection)") (defvar sj3-hostname "localhost" "Hostname of SJ3 server") @@ -65,9 +63,13 @@ (defun sj3-open (hostname) "Establish the connection to SJ3 server. Return process object." - (let* ((buf (generate-new-buffer " *SJ3*")) - (proc (open-network-stream "SJ3" buf hostname sj3-server-port)) - result) + (let ((buf (generate-new-buffer " *SJ3*")) + proc result) + (condition-case err + (setq proc (open-network-stream "SJ3" buf hostname sj3-server-port)) + (error + (kill-buffer buf) + (signal 'file-error (cdr err)))) ; Re-raise the signal with file-error (process-kill-without-query proc) (set-process-coding-system proc 'no-conversion 'no-conversion) (set-marker-insertion-type (process-mark proc) t) @@ -76,76 +78,22 @@ (erase-buffer) (buffer-disable-undo) (set-buffer-multibyte nil)) - ;; Initialize dictionaries - (setq sj3-sys-dict-list nil) - (setq sj3-user-dict-list nil) (setq result (sj3rpc-open proc (system-name) (user-login-name))) (if (< result 0) (let ((msg (sj3rpc-get-error-message (- result)))) (delete-process proc) (kill-buffer buf) - (error "Can't open SJ3 session (%s): %s" hostname msg))) - (setq result (sj3rpc-get-stdy-size proc)) - (if (< result 0) - (let ((msg (sj3rpc-get-error-message (- result)))) - (delete-process proc) - (kill-buffer buf) - (error "Can't get SJ3 STDYSIZE: %s"msg))) - (setq sj3-stdy-size result) - proc)) - -;; (defun sj3-open (hostname-list) -;; "Establish the connection to SJ3 server. Return process object." -;; (let* ((buf (generate-new-buffer " *SJ3*")) -;; (msg-form "SJ3: connecting to sj3serv at %s...") -;; hostname proc result msg) -;; (save-excursion -;; (set-buffer buf) -;; (erase-buffer) -;; (buffer-disable-undo) -;; (setq enable-multibyte-characters nil)) -;; (cond -;; ((null hostname-list) -;; (setq hostname-list '("localhost"))) -;; ((null (listp hostname-list)) -;; (setq hostname-list (list hostname-list)))) -;; (while (and hostname-list (null proc)) -;; (setq hostname (car hostname-list) -;; hostname-list (cdr hostname-list)) -;; (message msg-form hostname) -;; (sit-for 0) -;; (condition-case result -;; (setq proc (open-network-stream "SJ3" buf hostname sj3-server-port)) -;; (error nil)) -;; (if proc -;; (progn -;; (process-kill-without-query proc) -;; (set-process-coding-system proc 'no-conversion 'no-conversion) -;; (set-marker-insertion-type (process-mark proc) t) -;; ;; Initialize dictionaries -;; (setq sj3-sys-dict-list nil) -;; (setq sj3-user-dict-list nil) -;; (setq result (sj3rpc-open proc (system-name) (user-login-name))) -;; (if (< result 0) -;; (progn -;; (delete-process proc) -;; (setq proc nil -;; msg (format "Can't open SJ3 session (%s): %s" -;; hostname msg))) -;; (setq result (sj3rpc-get-stdy-size proc)) -;; (if (< result 0) -;; (progn -;; (delete-process proc) -;; (setq proc nil -;; msg (format "Can't get SJ3 STDYSIZE: %s" -;; (sj3rpc-get-error-message (- result))))) -;; (setq sj3-stdy-size result)))))) -;; (if proc -;; (progn -;; (setq sj3-open-message (format (concat msg-form "done") hostname)) -;; proc) -;; (kill-buffer buf) -;; (error "%s" (or msg "no sj3serv available"))))) + (signal 'file-error + (list (format "Can't open SJ3 session (%s): %s" hostname msg)))) + (setq result (sj3rpc-get-stdy-size proc)) + (if (< result 0) + (let ((msg (sj3rpc-get-error-message (- result)))) + (delete-process proc) + (kill-buffer buf) + (signal 'file-error + (list (format "Can't get SJ3 STDYSIZE: %s" msg))))) + (setq sj3-stdy-size result) + proc))) ;; ::= [ ] (defvar sj3-environment nil @@ -273,8 +221,10 @@ (defun sj3-start-conversion (yomi &optional lang) "Convert YOMI string to kanji, and enter conversion mode. Return the list of bunsetsu." - (let ((env (sj3-get-environment))) - (sj3rpc-begin env yomi))) + (if (eq lang 'Japanese) + (let ((env (sj3-get-environment))) + (sj3rpc-begin env yomi)) + (signal 'lang-not-supported))) (defun sj3-end-conversion (bunsetsu-list abort) (if abort @@ -354,7 +304,7 @@ Return the list of bunsetsu." (list bunsetsu1 bunsetsu2) (list bunsetsu1)))) -(defun sj3-fini (lang) +(defun sj3-fini () (let ((proc (sj3env-get-proc sj3-environment)) (dict-list (sj3env-get-dictionary-list sj3-environment)) dict) @@ -367,16 +317,14 @@ Return the list of bunsetsu." (setq sj3-environment nil)) ;;; setup - (require 'egg) -(load "egg/sj3rpc") ;;;###autoload (defun egg-activate-sj3 (&rest arg) "Activate SJ3 backend of Tamagotchy." - (egg-set-support-languages sj3-support-languages) - (egg-set-conversion-backend sj3-conversion-backend - sj3-support-languages) + (setq egg-conversion-backend sj3-conversion-backend) + (if (not (fboundp 'sj3rpc-open)) + (load-library "egg/sj3rpc")) (apply 'egg-mode arg)) ;;; egg/sj3.el ends here. diff --git a/egg/sj3rpc.el b/egg/sj3rpc.el index 9520e53..4d76603 100644 --- a/egg/sj3rpc.el +++ b/egg/sj3rpc.el @@ -33,7 +33,9 @@ (eval-when-compile (require 'egg-com) -;; (load-library "egg/sj3") + + ;; To get definition of sj3-make-bunsetsu and others + (load-library "egg/sj3") (defmacro sj3-const (c) (cond ((eq c 'OPEN) 1) ((eq c 'CLOSE) 2) @@ -71,7 +73,10 @@ (t (error "No such constant"))))) ;; XXX -(defconst sj3rpc-error-message (vector )) +(defconst sj3rpc-error-message + [ + "Error #0 $B$G$9(B" + ]) (defun sj3rpc-get-error-message (errno) (or (and (>= errno 0) @@ -102,9 +107,9 @@ ;; program name (format "%d.emacs-egg" (emacs-pid))) (comm-unpack (u) result) - (if (= result -2) - 0 - result))) + (if (= result -2) ; negated version number + 0 ; OK + -1))) ; Failure (different version) (defun sj3rpc-close (proc) (comm-call-with-proc proc (result) diff --git a/egg/wnn.el b/egg/wnn.el index 1e8330d..3891e47 100644 --- a/egg/wnn.el +++ b/egg/wnn.el @@ -207,12 +207,14 @@ (defun wnn-start-conversion (yomi &optional language dic-set reverse) "Convert YOMI string to kanji, and enter conversion mode. Return the list of bunsetsu." - (let* ((server-info (wnn-server-get-info language)) - (env (wnn-get-environment server-info dic-set reverse)) - (result (wnnrpc-renbunsetsu-conversion env yomi - (WNN-const BUN_SENTOU) ""))) - (wnnenv-set-daibunsetsu-info env (car result)) - (cdr result))) + (let ((server-info (wnn-server-get-info language))) + (if server-info + (let* ((env (wnn-get-environment server-info dic-set reverse)) + (result (wnnrpc-renbunsetsu-conversion env yomi + (WNN-const BUN_SENTOU) ""))) + (wnnenv-set-daibunsetsu-info env (car result)) + (cdr result)) + (signal 'lang-not-supported)))) (defun wnn-start-reverse-conversion (yomi &optional language dic-set) (wnn-start-conversion yomi language dic-set t)) @@ -369,7 +371,13 @@ Return the list of bunsetsu." ,@body) (setq env-list (cdr env-list)))))) -(defun wnn-fini (lang &optional save-only) +(defun wnn-fini () + (let ((l wnn-support-languages)) + (while l + (wnn-fini-lang (car l)) + (setq l (cdr l))))) + +(defun wnn-fini-lang (lang &optional save-only) (let* ((server-info (wnn-server-get-info lang)) (server-type (wnn-server-type server-info)) (l wnn-environments) @@ -410,7 +418,7 @@ Return the list of bunsetsu." (or (listp lang) (setq lang (list lang))) (while lang - (wnn-fini (car lang)) + (wnn-fini-lang (car lang)) (setq lang (cdr lang)))) (defun wnn-dictionary-save (lang) @@ -418,7 +426,7 @@ Return the list of bunsetsu." (or (listp lang) (setq lang (list lang))) (while lang - (wnn-fini (car lang) t) + (wnn-fini-lang (car lang) t) (setq lang (cdr lang)))) (defun wnn-read-active-lang () @@ -1002,14 +1010,13 @@ REVERSE specifies reverse conversion, if non nil." ;;; setup (require 'egg) -(load "egg/wnnrpc") ;;;###autoload (defun egg-activate-wnn (&rest arg) "Activate Wnn backend of Tamagotchy." - (egg-set-support-languages wnn-support-languages) - (egg-set-conversion-backend wnn-conversion-backend - wnn-support-languages) + (setq egg-conversion-backend wnn-conversion-backend) + (if (not (fboundp 'wnnrpc-open)) + (load-library "egg/wnnrpc")) (apply 'egg-mode arg)) ;;; egg/wnn.el ends here. diff --git a/its.el b/its.el index b01b06b..4f9d71c 100644 --- a/its.el +++ b/its.el @@ -552,23 +552,15 @@ map)) (defmacro define-its-state-machine (map name indicator lang doc &rest exprs) - `(progn - (eval-when (eval compile) - (let ((its-current-map 'its-temporaly-map) - (its-temporaly-map (its-new-map ,name ,indicator ,lang))) - ,@exprs - (setq ,map its-temporaly-map))) - (define-its-compiled-map ,map ,doc))) - -(defmacro define-its-compiled-map (map doc) + (let ((its-current-map map)) + (set map (its-new-map name indicator + (if (eq (car-safe lang) 'quote) (nth 1 lang) lang))) + (eval (cons 'progn exprs))) `(defconst ,map ',(symbol-value map) ,doc)) (defmacro define-its-state-machine-append (map &rest exprs) - (append - `(let ((its-current-map 'its-temporaly-map) - (its-temporaly-map ,map))) - exprs - (list `(setq ,map its-temporaly-map)))) + `(let ((its-current-map ',map)) + ,@exprs)) ;; ;; Construct State Machine @@ -579,27 +571,51 @@ BACK $B$,(B($BIi$N(B)$B@0?t$N;~$O(B, OUTPUT $B$r=PNO$7$?8e(B, BACK $B$N $BLa$C$FF0$/$b$N$H$9$k!#JQ495,B'$O$b$C$H$b:G6a$K(B its-define-state-machine $B$5$l$?JQ49I=$KEPO?$5$l$k!#(B Return last state." - (let ((state (its-goto-state (substring input 0 -1) nil t)) - (key (aref input (1- (length input))))) - (if (and (its-get-next-state state key) (not enable-overwrite)) - (error "Duplicated definition (%s)" input) - (its-make-next-state state key input output back)))) + (let ((state (its-goto-state input (if enable-overwrite t 'dup-check)))) + (its-set-output state output) + (its-set-kst state back) + state)) + +(defun its-defrule* (input output &optional enable-overwrite) + (let* ((state (its-goto-state input (if enable-overwrite t 'dup-check)))) + (its-set-kst state nil) + (its-set-interim-terminal-state state output) + state)) + +(defvar its-parent-states) -(defun its-goto-state (input &optional initial-state build-if-none) +(defun its-goto-state (input &optional build-if-none) (let ((len (length input)) (i 0) - (state (or initial-state - (its-get-start-state (symbol-value its-current-map))))) + (state (its-get-start-state (symbol-value its-current-map))) + brand-new next-state key) + (setq its-parent-states nil) (while (< i len) - (setq state - (or (its-get-next-state state (aref input i)) - (if build-if-none - (let ((keyseq (substring input 0 (1+ i)))) - (its-make-next-state state (aref input i) keyseq keyseq)) - (error "No such state (%s)" input))) - i (1+ i))) + (setq its-parent-states (cons state its-parent-states) + key (aref input i) + i (1+ i) + next-state (its-get-next-state state key)) + (cond + (next-state + (setq state next-state)) + ((null build-if-none) + (error "No such state (%s)" input)) + (t + (if (not (or brand-new (= i 1) (its-get-kst/t state))) + (its-set-interim-terminal-state state)) + (setq state (its-make-next-state state key + (concat (its-get-output state) + (list key))) + brand-new t)))) + (if (and (eq build-if-none 'dup-check) (null brand-new)) + (error "Duplicated definition (%s)" input)) state)) +(defun its-set-interim-terminal-state (state &optional output) + (or output (setq output (its-get-output state))) + (its-make-next-state state -1 output) + (its-defrule-otherwise state output)) + (defun its-defoutput (input display) (let ((state (its-goto-state input))) (its-set-output state display))) @@ -621,12 +637,11 @@ Return last state." (its-define-otherwise state (its-make-otherwise output class+back)))) -(defun its-defrule* (input output) - (let ((state (its-defrule input output))) - (its-defrule-otherwise state output))) - -(defun its-make-next-state (state key keyseq output &optional back) - (let ((next-state (its-new-state output keyseq back)) +(defun its-make-next-state (state key output &optional back) + (let ((next-state (its-new-state output + (concat (its-get-keyseq state) + (if (> key 0) (list key))) + back)) (kst (its-get-kst/t state))) (cond ((null kst) diff --git a/its/erpin.el b/its/erpin.el index 83b1d6f..087c9c0 100644 --- a/its/erpin.el +++ b/its/erpin.el @@ -21,21 +21,13 @@ (defvar its-erpin-tw-close-braket "$(G!W(B" "*]") ; "$(G!c(B" (eval-when-compile - (defsubst its-defoutput* (input display) - (its-set-output (its-goto-state input nil t) display)) - (defun its-define-erpin-qingsheng (shengmu yunmu &optional y) (let ((input (concat (car shengmu) yunmu)) - (output (concat (cdr shengmu) (if y y yunmu) "(0@(B")) - state) - (setq state (its-goto-state input nil t)) - (its-set-output state output) - (its-make-next-state state -1 input output) - (its-make-next-state state ? (concat input " ") output) - (its-make-next-state state ?0 (concat input "0") output) - (its-define-otherwise state (its-make-otherwise output - its-otherwise-back-one)) - state)) + (output (concat (cdr shengmu) (if y y yunmu) "(0@(B"))) + (prog1 + (its-defrule input output) + (its-defrule (concat input " ") output) + (its-defrule (concat input "0") output)))) (defmacro its-do-erpin-table (list) `(progn @@ -50,10 +42,10 @@ (while ss (setq sa (caar ss) sd (cdar ss) state (its-define-erpin-qingsheng (car ss) y y5)) - (its-make-next-state state ?1 (concat sa y 1) (concat sd y1 "(0@(B")) - (its-make-next-state state ?2 (concat sa y 2) (concat sd y2 "(0@(B")) - (its-make-next-state state ?3 (concat sa y 3) (concat sd y3 "(0@(B")) - (its-make-next-state state ?4 (concat sa y 4) (concat sd y4 "(0@(B")) + (its-make-next-state state ?1 (concat sd y1 "(0@(B")) + (its-make-next-state state ?2 (concat sd y2 "(0@(B")) + (its-make-next-state state ?3 (concat sd y3 "(0@(B")) + (its-make-next-state state ?4 (concat sd y4 "(0@(B")) (setq ss (cdr ss))))) (defmacro its-define-erpin-table () @@ -100,9 +92,6 @@ (un '("z" "(01(Bn" "(02(Bn" "(03(Bn" "(04(Bn" "un" )) (uo '("o" "u(0-(B" "u(0.(B" "u(0/(B" "u(00(B" "uo" ))) - (dolist (SHENG (list B C D F G H J K L M N P Q R S T W X Y Z I U V)) - (its-defrule (car SHENG) (cdr SHENG))) - (its-do-erpin-table (((O B C D F G H K L M N P S T W Y Z I U V) . a) ((O B C D G H K L M N P S T W Z I U V) . ai) @@ -152,6 +141,9 @@ ((J Q X) . (cons "t" (cdr ing ))) ((J Q X) . (cons "q" (cdr iu ))))) + (dolist (SHENG (list B C D F G H J K L M N P Q R S T W X Y Z I U V)) + (its-defoutput (car SHENG) (cdr SHENG))) + (its-define-erpin-qingsheng H "m") (its-define-erpin-qingsheng H "n" "ng") (its-define-erpin-qingsheng O "m") @@ -163,7 +155,7 @@ (its-defrule "on4" "(0?@(B")))) (define-its-state-machine its-erpin-cn-map - "erpin-cn" "$A6~(BG" 'Chinese-GB + "erpin-cn" "$A6~(BG" Chinese-GB "Map for Erpin input. (Chinese-GB)" (defconst its-quanjiao-escape "Z") @@ -173,30 +165,30 @@ (its-defrule-select-mode-temporally "Q" quanjiao-downcase-cn) (its-define-erpin-table) - (its-defoutput* "b " "$A2;(B") - (its-defoutput* "c " "$A2E(B") - (its-defoutput* "ch " "$A3v(B") - (its-defoutput* "d " "$A5D(B") - (its-defoutput* "f " "$A74(B") - (its-defoutput* "g " "$A8v(B") - (its-defoutput* "h " "$A:M(B") - (its-defoutput* "i " "$AR;(B") - (its-defoutput* "j " "$A>M(B") - (its-defoutput* "k " "$A?I(B") - (its-defoutput* "l " "$AAK(B") - (its-defoutput* "m " "$AC?(B") - (its-defoutput* "n " "$ADj(B") - (its-defoutput* "p " "$AEz(B") - (its-defoutput* "q " "$AH%(B") - (its-defoutput* "r " "$AHU(B") - (its-defoutput* "s " "$AJG(B") - (its-defoutput* "u " "$AIO(B") - (its-defoutput* "t " "$AK{(B") - (its-defoutput* "w " "$ANR(B") - (its-defoutput* "x " "$AOr(B") - (its-defoutput* "y " "$ASV(B") - (its-defoutput* "z " "$ATZ(B") - (its-defoutput* "v " "$AWE(B") + (its-defrule "b " "$A2;(B") + (its-defrule "c " "$A2E(B") + (its-defrule "ch " "$A3v(B") + (its-defrule "d " "$A5D(B") + (its-defrule "f " "$A74(B") + (its-defrule "g " "$A8v(B") + (its-defrule "h " "$A:M(B") + (its-defrule "i " "$AR;(B") + (its-defrule "j " "$A>M(B") + (its-defrule "k " "$A?I(B") + (its-defrule "l " "$AAK(B") + (its-defrule "m " "$AC?(B") + (its-defrule "n " "$ADj(B") + (its-defrule "p " "$AEz(B") + (its-defrule "q " "$AH%(B") + (its-defrule "r " "$AHU(B") + (its-defrule "s " "$AJG(B") + (its-defrule "u " "$AIO(B") + (its-defrule "t " "$AK{(B") + (its-defrule "w " "$ANR(B") + (its-defrule "x " "$AOr(B") + (its-defrule "y " "$ASV(B") + (its-defrule "z " "$ATZ(B") + (its-defrule "v " "$AWE(B") (dolist (ascii '(("0" . "$A#0(B") ("1" . "$A#1(B") ("2" . "$A#2(B") ("3" . "$A#3(B") ("4" . "$A#4(B") ("5" . "$A#5(B") ("6" . "$A#6(B") ("7" . "$A#7(B") @@ -237,7 +229,7 @@ (its-defrule "!" "$A#!(B")) (define-its-state-machine its-erpin-tw-map - "erpin-tw" "$(GD((BC" 'Chinese-CNS + "erpin-tw" "$(GD((BC" Chinese-CNS "Map for Erpin input." (defconst its-quanjiao-escape "Z") @@ -247,30 +239,30 @@ (its-defrule-select-mode-temporally "Q" quanjiao-downcase-cn) (its-define-erpin-table) - (its-defoutput* "b " "$(GDb(B") - (its-defoutput* "c " "$(GD_(B") - (its-defoutput* "ch " "$(GEx(B") - (its-defoutput* "d " "$(GN{(B") - (its-defoutput* "f " "$(GE0(B") - (its-defoutput* "g " "$(GT6(B") - (its-defoutput* "h " "$(GLO(B") - (its-defoutput* "i " "$(GD!(B") - (its-defoutput* "j " "$(G^s(B") - (its-defoutput* "k " "$(GF+(B") - (its-defoutput* "l " "$(GD'(B") - (its-defoutput* "m " "$(GJd(B") - (its-defoutput* "n " "$(GH!(B") - (its-defoutput* "p " "$(GJG(B") - (its-defoutput* "q " "$(GF*(B") - (its-defoutput* "r " "$(GEJ(B") - (its-defoutput* "s " "$(GQR(B") - (its-defoutput* "u " "$(GD8(B") - (its-defoutput* "t " "$(GEl(B") - (its-defoutput* "w " "$(GJ<(B") - (its-defoutput* "x " "$(GGW(B") - (its-defoutput* "y " "$(GD4(B") - (its-defoutput* "z " "$(GGc(B") - (its-defoutput* "v " "$(Gaa(B") + (its-defrule "b " "$(GDb(B") + (its-defrule "c " "$(GD_(B") + (its-defrule "ch " "$(GEx(B") + (its-defrule "d " "$(GN{(B") + (its-defrule "f " "$(GE0(B") + (its-defrule "g " "$(GT6(B") + (its-defrule "h " "$(GLO(B") + (its-defrule "i " "$(GD!(B") + (its-defrule "j " "$(G^s(B") + (its-defrule "k " "$(GF+(B") + (its-defrule "l " "$(GD'(B") + (its-defrule "m " "$(GJd(B") + (its-defrule "n " "$(GH!(B") + (its-defrule "p " "$(GJG(B") + (its-defrule "q " "$(GF*(B") + (its-defrule "r " "$(GEJ(B") + (its-defrule "s " "$(GQR(B") + (its-defrule "u " "$(GD8(B") + (its-defrule "t " "$(GEl(B") + (its-defrule "w " "$(GJ<(B") + (its-defrule "x " "$(GGW(B") + (its-defrule "y " "$(GD4(B") + (its-defrule "z " "$(GGc(B") + (its-defrule "v " "$(Gaa(B") (dolist (ascii '(("0" . "$(G$!(B") ("1" . "$(G$"(B") ("2" . "$(G$#(B") ("3" . "$(G$$(B") ("4" . "$(G$%(B") ("5" . "$(G$&(B") ("6" . "$(G$'(B") ("7" . "$(G$((B") @@ -330,7 +322,7 @@ (its-defrule "=" "$A#=(B") (its-defrule "`" "$A#`(B") (its-defrule "\\" "$A#\(B") (its-defrule "|" "$A#|(B") (its-defrule "_" "$A#_(B") (its-defrule "+" "$A#+(B") - (its-defrule "{" "$(G!B(B") (its-defrule "}" "$(G!C(B") + (its-defrule "{" "$A#{(B") (its-defrule "}" "$A#}(B") (its-defrule "\"" "$A#"(B") (its-defrule "'" "$A#'(B") (its-defrule "<" "$A#<(B") (its-defrule ">" "$A#>(B")) (progn @@ -372,7 +364,7 @@ (its-defrule "=" "$(G"8(B") (its-defrule "`" "$(G!j(B") (its-defrule "\\" "$(G"b(B") (its-defrule "|" "$(G"^(B") (its-defrule "_" "$(G"%(B") (its-defrule "+" "$(G"0(B") - (its-defrule "{" "$A#{(B") (its-defrule "}" "$(G!a(B") + (its-defrule "{" "$(G!B(B") (its-defrule "}" "$(G!C(B") (its-defrule "\"" "$(G!i(B") (its-defrule "'" "$(G!k(B") (its-defrule "<" "$(G"6(B") (its-defrule ">" "$(G"7(B")) (progn diff --git a/its/hangul.el b/its/hangul.el index 83a7556..714682e 100644 --- a/its/hangul.el +++ b/its/hangul.el @@ -31,7 +31,6 @@ (eval-when-compile (require 'its) - (require 'egg-edep) (require 'cl)) (defvar its-hangul-enable-jeonkak-alphabet @@ -61,13 +60,11 @@ (eval-when-compile (defun its-define-hangul-key (key output) - (let ((out (string-to-char output)) - (state (its-goto-state key nil t))) - (setq its-hangul-key-alist (cons (cons out (string-to-char key)) - its-hangul-key-alist)) - (its-set-output state output) - (its-make-next-state state -1 (its-get-keyseq state) output) - (its-defrule-otherwise state output))) + (setq its-hangul-key-alist + (cons (cons (string-to-char output) + (string-to-char key)) + its-hangul-key-alist)) + (its-defrule key output)) (defun its-define-hangul-successor-list (keyseq) (let ((pair (assq (aref keyseq 0) its-hangul-successor-list))) @@ -80,28 +77,16 @@ (setcdr pair (its-hangul-make-successor (cdr pair) keyseq)))))) (defun its-defrule-hangul (input output) - (let ((state (its-get-start-state (symbol-value its-current-map))) - (len (length input)) (i 0) - keyseq key prev-out out pair) - (while (< i len) - (setq key (aref input i) - next-state (its-get-next-state state key) - i (1+ i)) - (if next-state - (setq prev-out out - out (its-get-output next-state) - state next-state) - (setq keyseq (substring input 0 i) - prev-out out - out (if (= i len) output (concat out (list key))) - state (its-make-next-state state key keyseq out)) - (its-make-next-state state -1 keyseq out) - (its-defrule-otherwise state out))) - (if (and (= (egg-chars-in-period prev-out 0 (length prev-out)) 1) + (let* ((state (its-defrule input output nil nil)) + (prev-out (its-get-output (car its-parent-states))) + pair) + (if (and (= (length (string-to-list prev-out)) 1) (> (string-to-char prev-out) ?\377) - (setq pair (assq (aref keyseq (1- len)) + (setq pair (assq (string-to-char (substring input -1)) its-hangul-successor-list))) - (its-defrule-otherwise state prev-out (cdr pair) -2)))) + (progn + (its-set-interim-terminal-state state) + (its-defrule-otherwise state prev-out (cdr pair) -2))))) (defmacro its-define-hangul (&rest list) (cons 'progn @@ -114,7 +99,7 @@ list)))) (define-its-state-machine its-hangul-map - "hangul" "$(CGQ(B" 'Korean + "hangul" "$(CGQ(B" Korean "Map for Hangul input. (Korean)" (defconst its-jeonkak-escape "Z") diff --git a/its/hankata.el b/its/hankata.el index e701c1a..897ebc1 100644 --- a/its/hankata.el +++ b/its/hankata.el @@ -44,7 +44,7 @@ (defvar its-han-kata-horizontal "(I0(B" "*-") ; "$B!](B" (define-its-state-machine its-han-kata-map - "roma-han-kata" "(I11(B" "Japanese" + "roma-han-kata" "(I11(B" Japanese "Map for Romaji-Hankaku-Katakana translation. (Japanese)" (defconst its-hankaku-escape "~") ;; Escape character to Hankaku inputs @@ -64,12 +64,9 @@ (dolist (q1 '("b" "m" "p")) (its-defrule (concat "m" q1) "(I](B" -1)) - (its-defrule "N" "(I](B") - - (let ((state (its-goto-state "n" nil t))) - (its-make-next-state state -1 "n" "(I](B") - (its-make-next-state state ?' "n" "(I](B") - (its-defrule-otherwise state "(I](B")) + (its-defrule* "n" "(I](B") + (its-defrule "n'" "(I](B") + (its-defrule "N" "(I](B") (let ((small '"x" )) (its-defrule (concat small "a") "(I'(B") @@ -277,8 +274,7 @@ (define-its-state-machine-append its-han-kata-map (if its-han-kata-enable-double-n - (its-defrule "nn" "(I](B") - (its-defrule "nn" "(I](B" -1)) + (its-defrule "nn" "(I](B")) (its-defrule "-" its-han-kata-horizontal) (its-defrule "[" its-han-kata-open-bracket) diff --git a/its/hira.el b/its/hira.el index f899001..5efe895 100644 --- a/its/hira.el +++ b/its/hira.el @@ -50,7 +50,7 @@ (defvar its-hira-horizontal "$B!<(B" "*-") ; "$B!](B" (define-its-state-machine its-hira-map - "roma-kana" "$B$"(B" 'Japanese + "roma-kana" "$B$"(B" Japanese "Map for Romaji-Hiragana translation. (Japanese)" (defconst its-zenkaku-escape "Z") ;; Escape character to Zenkaku inputs @@ -72,12 +72,9 @@ (dolist (q1 '("b" "m" "p")) (its-defrule (concat "m" q1) "$B$s(B" -1)) - (its-defrule "N" "$B$s(B") - - (let ((state (its-goto-state "n" nil t))) - (its-make-next-state state -1 "n" "$B$s(B") - (its-make-next-state state ?' "n" "$B$s(B") - (its-defrule-otherwise state "$B$s(B")) + (its-defrule* "n" "$B$s(B") + (its-defrule "n'" "$B$s(B") + (its-defrule "N" "$B$s(B") (let ((small '"x" )) (its-defrule (concat small "a") "$B$!(B") @@ -440,8 +437,7 @@ (define-its-state-machine-append its-hira-map (if its-hira-enable-double-n - (its-defrule "nn" "$B$s(B") - (its-defrule "nn" "$B$s(B" -1)) + (its-defrule "nn" "$B$s(B")) (its-defrule "-" its-hira-horizontal) (its-defrule "[" its-hira-open-bracket) diff --git a/its/jeonkak.el b/its/jeonkak.el index e81fb7c..e93ce8e 100644 --- a/its/jeonkak.el +++ b/its/jeonkak.el @@ -35,7 +35,7 @@ (require 'its)) (define-its-state-machine its-jeonkak-up-map - "jeonkak-upcase" "$(C#A(B" 'Korean + "jeonkak-upcase" "$(C#A(B" Korean "Map for jeonkak-upcase input." (dolist (ascii '(("1" . "$(C#1(B") ("2" . "$(C#2(B") ("3" . "$(C#3(B") ("4" . "$(C#4(B") @@ -68,7 +68,7 @@ (its-defrule in out)))) (define-its-state-machine its-jeonkak-down-map - "jeonkak-downcase" "$(C#a(B" 'Korean + "jeonkak-downcase" "$(C#a(B" Korean "Map for jeonkak-downcase input." (dolist (ascii '(("1" . "$(C#1(B") ("2" . "$(C#2(B") ("3" . "$(C#3(B") ("4" . "$(C#4(B") diff --git a/its/kata.el b/its/kata.el index 9c11905..69ce3f6 100644 --- a/its/kata.el +++ b/its/kata.el @@ -50,7 +50,7 @@ (defvar its-kata-horizontal "$B!<(B" "*-") ; "$B!](B" (define-its-state-machine its-kata-map - "roma-kata" "$B%"(B" 'Japanese + "roma-kata" "$B%"(B" Japanese "Map for Romaji-Katakana translation. (Japanese)" (defconst its-zenkaku-escape "Z") ;; Escape character to Zenkaku inputs @@ -72,12 +72,9 @@ (dolist (q1 '("b" "m" "p")) (its-defrule (concat "m" q1) "$B%s(B" -1)) - (its-defrule "N" "$B%s(B") - - (let ((state (its-goto-state "n" nil t))) - (its-make-next-state state -1 "n" "$B%s(B") - (its-make-next-state state ?' "n" "$B%s(B") - (its-defrule-otherwise state "$B%s(B")) + (its-defrule* "n" "$B%s(B") + (its-defrule "n'" "$B%s(B") + (its-defrule "N" "$B%s(B") (let ((small '"x" )) (its-defrule (concat small "a") "$B%!(B") @@ -440,8 +437,7 @@ (define-its-state-machine-append its-kata-map (if its-kata-enable-double-n - (its-defrule "nn" "$B%s(B") - (its-defrule "nn" "$B%s(B" -1)) + (its-defrule "nn" "$B%s(B")) (its-defrule "-" its-kata-horizontal) (its-defrule "[" its-kata-open-bracket) diff --git a/its/pinyin.el b/its/pinyin.el index 887f7ca..c6ae5f6 100644 --- a/its/pinyin.el +++ b/its/pinyin.el @@ -41,61 +41,39 @@ (defvar its-pinyin-cn-open-braket "$A!8(B" "*[") ; "$A#[(B" (defvar its-pinyin-cn-close-braket "$A!9(B" "*]") ; "$A#](B" -(defvar its-pinyin-tw-enable-quanjioao-alphabet t "*Enable Quanjiao alphabet") +(defvar its-pinyin-tw-enable-quanjioao-alphabet + (if (boundp 'its-enable-fullwidth-alphabet) + its-enable-fullwidth-alphabet + t) + "*Enable Quanjiao alphabet") + (defvar its-pinyin-tw-open-braket "$(G!V(B" "*[") ; "$(G!b(B " (defvar its-pinyin-tw-close-braket "$(G!W(B" "*]") ; "$(G!c(B" (eval-when-compile - (defconst its-pinyin-term - (char-to-string (make-char 'chinese-sisheng ?@))) - - (defsubst its-defoutput* (input display) - (its-set-output (its-goto-state input nil t) display)) - - (defun its-prev-terminal-state (input) - (let ((len (length input)) - (state (its-get-start-state (symbol-value its-current-map))) - (i 0) (ret nil) kst ks) - (while (and (< i len) - (setq state (its-get-next-state state (aref input i)))) - (if (or (null (its-kst-p (setq kst (its-get-kst/t state)))) - (mapcan (lambda (eob) (if (eq (its-eob-back eob) -1) (list t))) - (cdr kst)) - (and (setq ks (assq -1 (car kst))) - (null (its-get-kst/t (cdr ks))))) - (setq ret state)) - (setq i (1+ i))) - ret)) + (defun its-prev-terminal-state (state-list) + (while (and state-list + (null (its-get-next-state (car state-list) -1))) + (setq state-list (cdr state-list))) + (car state-list)) (defun its-define-qingsheng (shengmu yunmu &optional s y) (let ((input (concat shengmu yunmu)) - (output (concat (if s s (capitalize shengmu)) - (if y y yunmu) - its-pinyin-term)) - state term kst i len c+b) - (setq state (its-goto-state input nil t)) - (its-make-next-state state -1 input output) - (its-make-next-state state ? (concat input " ") output) - (its-make-next-state state ?0 (concat input "0") output) - (its-define-otherwise - state (its-make-otherwise output its-otherwise-back-one)) - (setq term (its-prev-terminal-state (substring input 0 -1))) - (if term - (progn - (setq len (length (its-get-keyseq term)) - i len - output (car (rassoc '(nil . -1) (cdr (its-get-kst/t term))))) - (while (null - (eq (setq term (its-get-next-state term (aref input i))) - state)) - (setq i (1+ i) kst (its-get-kst/t term)) - (if (null (assq -1 (car kst))) - (its-make-next-state term -1 - (its-get-keyseq term) output (- len i))) - (setq c+b (its-make-class+back nil (1- (- len i)))) - (if (null (rassoc c+b (cdr kst))) - (its-define-otherwise term - (its-make-otherwise output c+b)))))) + (output (concat (if s s (capitalize shengmu)) (if y y yunmu) "(0@(B")) + state term-state) + (setq state (its-defrule* input output)) + (its-make-next-state state ? output) + (its-make-next-state state ?0 output) + (setq term-state (its-prev-terminal-state its-parent-states)) + (if term-state + (let ((back (- (length (its-get-keyseq term-state)) (length input))) + (output (its-get-output (its-get-next-state term-state -1))) + (parents its-parent-states)) + (while (null (eq (car parents) term-state)) + (its-make-next-state (car parents) -1 output (1+ back)) + (its-defrule-otherwise (car parents) output nil back) + (setq back (1+ back) + parents (cdr parents))))) state)) (defmacro its-do-sisheng-table (list) @@ -109,15 +87,13 @@ (ss (list ,@shengmu)) s cs state i) (while ss (setq s (car ss) + ss (cdr ss) cs (capitalize s) state (its-define-qingsheng s y cs qing)) - (setq i 1) - (while (<= i 4) - (its-make-next-state state (+ ?0 i) - (concat s y i) - (concat cs (nth i ,yunmu) its-pinyin-term)) - (setq i (1+ i))) - (setq ss (cdr ss))))) + (its-make-next-state state ?1 (concat cs (nth 1 ,yunmu) "(0@(B")) + (its-make-next-state state ?2 (concat cs (nth 2 ,yunmu) "(0@(B")) + (its-make-next-state state ?3 (concat cs (nth 3 ,yunmu) "(0@(B")) + (its-make-next-state state ?4 (concat cs (nth 4 ,yunmu) "(0@(B"))))) (defmacro its-define-pinyin-table () '(let ((- "") (B "b") (C "c") (D "d") (F "f") (G "g") (H "h") @@ -160,6 +136,17 @@ (UN '("un" "(01(Bn" "(02(Bn" "(03(Bn" "(04(Bn" "un" )) (UO '("uo" "u(0-(B" "u(0.(B" "u(0/(B" "u(00(B" "uo" ))) + (its-define-qingsheng "hm" "") + (its-define-qingsheng "hng" "") + (its-defrule* "m" "m(0@(B") + (its-defrule "m0" "m(0@(B") + (its-defrule* "n" "n(0@(B") + (its-defrule "n0" "n(0@(B") + (its-defrule "n2" "(0=@(B") + (its-defrule "n3" "(0>@(B") + (its-defrule "n4" "(0?@(B") + (its-define-qingsheng "" "ng") + (its-do-sisheng-table (((- B C D F G H K L M N P S T W Y Z CH SH ZH ) A) ((- B C D G H K L M N P S T W Z CH SH ZH ) AI) @@ -205,20 +192,10 @@ ((J Q X) (cons "ei" (cdr IE ))) ((J Q X) (cons "en" (cdr IN ))) ((J Q X) (cons "eng" (cdr ING ))) - ((J Q X) (cons "ou" (cdr IU ))))) - - (its-define-qingsheng "hm" "") - (its-define-qingsheng "hng" "") - (its-define-qingsheng "" "ng") - - (its-define-qingsheng "" "m") - (its-define-qingsheng "" "n") - (its-defrule "n2" "(0=@(B") - (its-defrule "n3" "(0>@(B") - (its-defrule "n4" "(0?@(B")))) + ((J Q X) (cons "ou" (cdr IU )))))))) (define-its-state-machine its-pinyin-cn-map - "pinyin-cn" "$AF4(BG" 'Chinese-GB + "pinyin-cn" "$AF4(BG" Chinese-GB "Map for Pinyin input. (Chinese-GB)" (defconst its-quanjiao-escape "Z") @@ -228,30 +205,30 @@ (its-defrule-select-mode-temporally "Q" quanjiao-downcase-cn) (its-define-pinyin-table) - (its-defoutput* "b " "$A2;(B") - (its-defoutput* "c " "$A2E(B") - (its-defoutput* "ch " "$A3v(B") - (its-defoutput* "d " "$A5D(B") - (its-defoutput* "f " "$A74(B") - (its-defoutput* "g " "$A8v(B") - (its-defoutput* "h " "$A:M(B") - (its-defoutput* "i " "$AR;(B") - (its-defoutput* "j " "$A>M(B") - (its-defoutput* "k " "$A?I(B") - (its-defoutput* "l " "$AAK(B") - (its-defoutput* "m " "$AC?(B") - (its-defoutput* "n " "$ADj(B") - (its-defoutput* "p " "$AEz(B") - (its-defoutput* "q " "$AH%(B") - (its-defoutput* "r " "$AHU(B") - (its-defoutput* "s " "$AJG(B") - (its-defoutput* "sh " "$AIO(B") - (its-defoutput* "t " "$AK{(B") - (its-defoutput* "w " "$ANR(B") - (its-defoutput* "x " "$AOr(B") - (its-defoutput* "y " "$ASV(B") - (its-defoutput* "z " "$ATZ(B") - (its-defoutput* "zh " "$AWE(B") + (its-defrule "b " "$A2;(B") + (its-defrule "c " "$A2E(B") + (its-defrule "ch " "$A3v(B") + (its-defrule "d " "$A5D(B") + (its-defrule "f " "$A74(B") + (its-defrule "g " "$A8v(B") + (its-defrule "h " "$A:M(B") + (its-defrule "i " "$AR;(B") + (its-defrule "j " "$A>M(B") + (its-defrule "k " "$A?I(B") + (its-defrule "l " "$AAK(B") + (its-defrule "m " "$AC?(B") + (its-defrule "n " "$ADj(B") + (its-defrule "p " "$AEz(B") + (its-defrule "q " "$AH%(B") + (its-defrule "r " "$AHU(B") + (its-defrule "s " "$AJG(B") + (its-defrule "sh " "$AIO(B") + (its-defrule "t " "$AK{(B") + (its-defrule "w " "$ANR(B") + (its-defrule "x " "$AOr(B") + (its-defrule "y " "$ASV(B") + (its-defrule "z " "$ATZ(B") + (its-defrule "zh " "$AWE(B") (dolist (ascii '(("0" . "$A#0(B") ("1" . "$A#1(B") ("2" . "$A#2(B") ("3" . "$A#3(B") ("4" . "$A#4(B") ("5" . "$A#5(B") ("6" . "$A#6(B") ("7" . "$A#7(B") @@ -292,7 +269,7 @@ (its-defrule "!" "$A#!(B")) (define-its-state-machine its-pinyin-tw-map - "pinyin-tw" "$(GQ;(BC" 'Chinese-CNS + "pinyin-tw" "$(GQ;(BC" Chinese-CNS "Map for Pinyin input." (defconst its-quanjiao-escape "Z") @@ -302,30 +279,30 @@ (its-defrule-select-mode-temporally "Q" quanjiao-downcase-tw) (its-define-pinyin-table) - (its-defoutput* "b " "$(GDb(B") - (its-defoutput* "c " "$(GD_(B") - (its-defoutput* "ch " "$(GEx(B") - (its-defoutput* "d " "$(GN{(B") - (its-defoutput* "f " "$(GE0(B") - (its-defoutput* "g " "$(GT6(B") - (its-defoutput* "h " "$(GLO(B") - (its-defoutput* "i " "$(GD!(B") - (its-defoutput* "j " "$(G^s(B") - (its-defoutput* "k " "$(GF+(B") - (its-defoutput* "l " "$(GD'(B") - (its-defoutput* "m " "$(GJd(B") - (its-defoutput* "n " "$(GH!(B") - (its-defoutput* "p " "$(GJG(B") - (its-defoutput* "q " "$(GF*(B") - (its-defoutput* "r " "$(GEJ(B") - (its-defoutput* "s " "$(GQR(B") - (its-defoutput* "sh " "$(GD8(B") - (its-defoutput* "t " "$(GEl(B") - (its-defoutput* "w " "$(GJ<(B") - (its-defoutput* "x " "$(GGW(B") - (its-defoutput* "y " "$(GD4(B") - (its-defoutput* "z " "$(GGc(B") - (its-defoutput* "zh " "$(Gaa(B") + (its-defrule "b " "$(GDb(B") + (its-defrule "c " "$(GD_(B") + (its-defrule "ch " "$(GEx(B") + (its-defrule "d " "$(GN{(B") + (its-defrule "f " "$(GE0(B") + (its-defrule "g " "$(GT6(B") + (its-defrule "h " "$(GLO(B") + (its-defrule "i " "$(GD!(B") + (its-defrule "j " "$(G^s(B") + (its-defrule "k " "$(GF+(B") + (its-defrule "l " "$(GD'(B") + (its-defrule "m " "$(GJd(B") + (its-defrule "n " "$(GH!(B") + (its-defrule "p " "$(GJG(B") + (its-defrule "q " "$(GF*(B") + (its-defrule "r " "$(GEJ(B") + (its-defrule "s " "$(GQR(B") + (its-defrule "sh " "$(GD8(B") + (its-defrule "t " "$(GEl(B") + (its-defrule "w " "$(GJ<(B") + (its-defrule "x " "$(GGW(B") + (its-defrule "y " "$(GD4(B") + (its-defrule "z " "$(GGc(B") + (its-defrule "zh " "$(Gaa(B") (dolist (ascii '(("0" . "$(G$!(B") ("1" . "$(G$"(B") ("2" . "$(G$#(B") ("3" . "$(G$$(B") ("4" . "$(G$%(B") ("5" . "$(G$&(B") ("6" . "$(G$'(B") ("7" . "$(G$((B") @@ -385,7 +362,7 @@ (its-defrule "=" "$A#=(B") (its-defrule "`" "$A#`(B") (its-defrule "\\" "$A#\(B") (its-defrule "|" "$A#|(B") (its-defrule "_" "$A#_(B") (its-defrule "+" "$A#+(B") - (its-defrule "{" "$(G!B(B") (its-defrule "}" "$(G!C(B") + (its-defrule "{" "$A#{(B") (its-defrule "}" "$A#}(B") (its-defrule "\"" "$A#"(B") (its-defrule "'" "$A#'(B") (its-defrule "<" "$A#<(B") (its-defrule ">" "$A#>(B")) (progn @@ -427,7 +404,7 @@ (its-defrule "=" "$(G"8(B") (its-defrule "`" "$(G!j(B") (its-defrule "\\" "$(G"b(B") (its-defrule "|" "$(G"^(B") (its-defrule "_" "$(G"%(B") (its-defrule "+" "$(G"0(B") - (its-defrule "{" "$A#{(B") (its-defrule "}" "$(G!a(B") + (its-defrule "{" "$(G!B(B") (its-defrule "}" "$(G!C(B") (its-defrule "\"" "$(G!i(B") (its-defrule "'" "$(G!k(B") (its-defrule "<" "$(G"6(B") (its-defrule ">" "$(G"7(B")) (progn diff --git a/its/quanjiao.el b/its/quanjiao.el index d23b881..936de40 100644 --- a/its/quanjiao.el +++ b/its/quanjiao.el @@ -35,7 +35,7 @@ (require 'its)) (define-its-state-machine its-quanjiao-up-cn-map - "quanjiao-upcase-cn" "$A#A(B" 'Chinese-GB + "quanjiao-upcase-cn" "$A#A(B" Chinese-GB "Map for quanjiao-upcase input. (Chinese-GB)" (dolist (ascii '(("0" . "$A#0(B") ("1" . "$A#1(B") ("2" . "$A#2(B") ("3" . "$A#3(B") @@ -68,7 +68,7 @@ (its-defrule in out)))) (define-its-state-machine its-quanjiao-down-cn-map - "quanjiao-downcase-cn" "$A#a(B" 'Chinese-GB + "quanjiao-downcase-cn" "$A#a(B" Chinese-GB "Map for quanjiao-downcase input. (Chinese-GB)" (dolist (ascii '(("0" . "$A#0(B") ("1" . "$A#1(B") ("2" . "$A#2(B") ("3" . "$A#3(B") @@ -101,7 +101,7 @@ (its-defrule in out)))) (define-its-state-machine its-quanjiao-up-tw-map - "quanjiao-upcase-tw" "$(G$A(B" 'Chinese-CNS + "quanjiao-upcase-tw" "$(G$A(B" Chinese-CNS "Map for quanjiao-upcase input. (Chinese-CNS)" (dolist (ascii '(("0" . "$(G$!(B") ("1" . "$(G$"(B") ("2" . "$(G$#(B") ("3" . "$(G$$(B") @@ -134,7 +134,7 @@ (its-defrule in out)))) (define-its-state-machine its-quanjiao-down-tw-map - "quanjiao-downcase-tw" "$(G$[(B" 'Chinese-CNS + "quanjiao-downcase-tw" "$(G$[(B" Chinese-CNS "Map for quanjiao-downcase input. (Chinese-CNS)" (dolist (ascii '(("0" . "$(G$!(B") ("1" . "$(G$"(B") ("2" . "$(G$#(B") ("3" . "$(G$$(B") diff --git a/its/zenkaku.el b/its/zenkaku.el index bfde649..71c4e79 100644 --- a/its/zenkaku.el +++ b/its/zenkaku.el @@ -35,7 +35,7 @@ (require 'its)) (define-its-state-machine its-zenkaku-up-map - "zenkaku-upcase" "$B#A(B" 'Japanese + "zenkaku-upcase" "$B#A(B" Japanese "Map for zenkaku-upcase input." (dolist (ascii '(("0" . "$B#0(B") ("1" . "$B#1(B") ("2" . "$B#2(B") ("3" . "$B#3(B") @@ -68,7 +68,7 @@ (its-defrule in out)))) (define-its-state-machine its-zenkaku-down-map - "zenkaku-downcase" "$B#a(B" 'Japanese + "zenkaku-downcase" "$B#a(B" Japanese "Map for zenkaku-downcase input." (dolist (ascii '(("0" . "$B#0(B") ("1" . "$B#1(B") ("2" . "$B#2(B") ("3" . "$B#3(B") diff --git a/its/zhuyin.el b/its/zhuyin.el index ff7213f..7357dac 100644 --- a/its/zhuyin.el +++ b/its/zhuyin.el @@ -56,33 +56,24 @@ ,@(mapcar (lambda (syl) `(its-define-zhuyin ,@syl)) list))) - (defmacro its-define-zhuyin (shengmu yunmu1 &optional yunmu2 qing-only) + (defmacro its-define-zhuyin (shengmu yunmu1 &optional yunmu2 qingsheng) `(let ((s (list ,@shengmu)) (yi (concat (car ,yunmu1) (car ,yunmu2))) (yo (concat (nth 1 ,yunmu1) (nth 1 ,yunmu2))) - (tone (if ,qing-only "(0A(B" "(0@(B")) + (tone (if ,qingsheng "(0A(B" "(0@(B")) in out out1 state) (while s (setq in (concat (car (car s)) yi) out (concat (nth 1 (car s)) yo) out1 (concat out tone) - state (its-goto-state in nil t)) - (if (and ,qing-only (its-get-kst/t state)) - (its-set-output state out) - (its-set-output state out1)) - (its-make-next-state state -1 in out1) - (its-make-next-state state ? (concat in " ") out1) - (its-define-otherwise state (its-make-otherwise - out1 - its-otherwise-back-one)) - ,(if qing-only - nil - '(progn - (its-make-next-state state ?1 (concat in 1) (concat out "(0A(B")) - (its-make-next-state state ?2 (concat in 2) (concat out "(0B(B")) - (its-make-next-state state ?3 (concat in 3) (concat out "(0C(B")) - (its-make-next-state state ?4 (concat in 4) (concat out "(0D(B")))) - (setq s (cdr s))))) + state (its-defrule in out1) + s (cdr s)) + (its-defrule (concat in " ") out1) + ,@(if (null qingsheng) + '((its-make-next-state state ?1 (concat out "(0A(B")) + (its-make-next-state state ?2 (concat out "(0B(B")) + (its-make-next-state state ?3 (concat out "(0C(B")) + (its-make-next-state state ?4 (concat out "(0D(B"))))))) (defmacro its-define-zhuyin-table () '(let ((- '("" "")) @@ -99,11 +90,13 @@ (ER '("^" "(0f(B")) (OU '("y" "(0a(B")) (I '("e" "(0g(B")) (U '("x" "(0h(B")) (V '("u" "(0i(B"))) - (mapcar (lambda (s) (its-defrule (car s) (nth 1 s))) - (list B P M F D T N L G K H J Q X)) + (its-define-zhuyin (- H) M nil t) + (its-define-zhuyin (- H) '("@" "@") nil t) + (its-define-zhuyin (- ) N nil t) (its-do-zhuyin-table - (((- B P M F D T N L G K H ZH CH SH Z C S ) A) + ((( ZH CH SH R Z C S ) -) + ((- B P M F D T N L G K H ZH CH SH Z C S ) A) ((- B P M F L ) O) ((- M D T N L G K H ZH CH SH R Z C S ) e) ((- B P M D T N L G K H ZH CH SH Z C S ) AI) @@ -115,7 +108,6 @@ ((- B P M F D T N L G K H ZH CH SH R Z C S ) ENG) ((- ) ER) ((- P M F D T N L G K H ZH CH SH R Z C S ) OU) - (( ZH CH SH R Z C S ) -) ((- B P M D T N L J Q X ) I) ((- D L J Q X ) I A) ((- ) I O) @@ -139,18 +131,17 @@ ((- N L J Q X ) V E) ((- J Q X ) V AN) ((- J Q X ) V EN) - ((- J Q X ) V ENG) + ((- J Q X ) V ENG))) - ((- H) M nil t) - ((- H) '("@" "@") nil t) - ((- ) N nil t))) + (mapcar (lambda (s) (its-defoutput (car s) (nth 1 s))) + (list B P M F D T N L G K H J Q X)) - (its-defrule (concat (car N) 2) (concat (nth 1 N) "(0B(B")) - (its-defrule (concat (car N) 3) (concat (nth 1 N) "(0C(B")) - (its-defrule (concat (car N) 4) (concat (nth 1 N) "(0D(B"))))) + (its-defrule (concat (car N) 2) (concat (nth 1 N) "(0B(B")) + (its-defrule (concat (car N) 3) (concat (nth 1 N) "(0C(B")) + (its-defrule (concat (car N) 4) (concat (nth 1 N) "(0D(B"))))) (define-its-state-machine its-zhuyin-cn-map - "zhuyin-cn" "$AW"(BG" 'Chinese-GB + "zhuyin-cn" "$AW"(BG" Chinese-GB "Map for Zhuyin input. (Chinese-GB)" (defconst its-quanjiao-escape "Z") @@ -195,7 +186,7 @@ (its-defrule "?" "$A!"(B")) (define-its-state-machine its-zhuyin-tw-map - "zhuyin-tw" "$(GNC(BC" 'Chinese-CNS + "zhuyin-tw" "$(GNC(BC" Chinese-CNS "Map for Zhuyin input." (defconst its-quanjiao-escape "Z") @@ -251,9 +242,9 @@ (its-defrule "(" "$A#((B") (its-defrule ")" "$A#)(B") (its-defrule "~" "$A!+(B") (its-defrule "=" "$A#=(B") (its-defrule "`" "$A#`(B") - (its-defrule "\\" "$(G"`(B") (its-defrule "|" "$A#|(B") + (its-defrule "\\" "$A#\(B") (its-defrule "|" "$A#|(B") (its-defrule "_" "$A#_(B") (its-defrule "+" "$A#+(B") - (its-defrule "{" "$(G!B(B") (its-defrule "}" "$(G!C(B") + (its-defrule "{" "$A#{(B") (its-defrule "}" "$A#}(B") (its-defrule "\"" "$A#"(B") (its-defrule "'" "$A#'(B")) (progn (its-defrule "#" "#") (its-defrule "$" "$") @@ -279,9 +270,9 @@ (its-defrule "(" "$(G!>(B") (its-defrule ")" "$(G!?(B") (its-defrule "~" "$(G"D(B") (its-defrule "=" "$(G"8(B") (its-defrule "`" "$(G!j(B") - (its-defrule "\\" "$(G"b(B") (its-defrule "|" "$(G"^(B") + (its-defrule "\\" "$(G"`(B") (its-defrule "|" "$(G"^(B") (its-defrule "_" "$(G"%(B") (its-defrule "+" "$(G"0(B") - (its-defrule "{" "$A#{(B") (its-defrule "}" "$(G!a(B") + (its-defrule "{" "$(G!B(B") (its-defrule "}" "$(G!C(B") (its-defrule "\"" "$(G!i(B") (its-defrule "'" "$(G!k(B")) (progn (its-defrule "#" "#") (its-defrule "$" "$")