--- /dev/null
+;;; its/aynu.el --- Aynu Katakana Input in Egg Input Method Architecture
+
+;; Copyright (C) 1999,2000 PFU LIMITED
+
+;; Author: KATAYAMA Yoshio <kate@pfu.co.jp>
+
+;; Maintainer: TOMURA Satoru <tomura@etl.go.jp>
+
+;; Keywords: mule, multilingual, input method
+
+;; This file is part of EGG.
+
+;; EGG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; EGG is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+
+;;; Code:
+
+(require 'its)
+
+(eval-when (compile)
+ (defconst its-compaction-enable t))
+
+(defvar its-aynu-enable-zenkaku-alphabet
+ (if (boundp 'its-enable-fullwidth-alphabet)
+ its-enable-fullwidth-alphabet
+ t)
+ "*Enable Zenkaku alphabet")
+
+(defvar its-aynu-horizontal "\e$(O!<\e(B" "*-") ; "-" "\e$(O!=\e(B"
+(defvar its-aynu-period "\e$(O!#\e(B " "*.") ; "." "\e$(O!#\e(B"
+(defvar its-aynu-comma "\e$(O!$\e(B " "*,") ; "," "\e$(O!$\e(B"
+(defvar its-aynu-open-bracket "\e$(O!V\e(B" "*[") ; "\e$(O!N\e(B"
+(defvar its-aynu-close-bracket "\e$(O!W\e(B" "*]") ; "\e$(O!O\e(B"
+
+(defvar its-aynu-enable-double-n nil "*Enable \"nn\" input for \"\e$(O%s\e(B\"")
+
+(defvar its-aynu-kick-conversion-on-space nil "*Start conversion on SPACE")
+
+(eval-when-compile
+ (defun its-define-state-aynu (input i-tail output o-tail otherwise)
+ "Define following rules:
+INPUT + I-TAIL --> OUTPUT + O-TAIL
+INPUT + I-TAIL + ' --> OUTPUT + O-TAIL
+INPUT + I-TAIL + vowel --> (translate INPUT) + I-tail + vowel
+INPUT + I-TAIL + OTHERWISE (see `its-defrule-otherwise')."
+ (let ((out (concat output o-tail))
+ state)
+ (setq state (its-defrule (concat input i-tail) out))
+ (its-defrule (concat input i-tail "'") out)
+ (its-defrule-otherwise state nil "[aiueo]" -2)
+ (while otherwise
+ (its-defrule-otherwise state (concat output (caar otherwise))
+ (nth 1 (car otherwise)) (nth 2 (car otherwise)))
+ (setq otherwise (cdr otherwise)))
+ (setq state (its-defrule (concat input i-tail "y") (concat out "\e$(O%#\e(B")))
+ (its-make-next-state state -1 out -1)
+ (its-defrule-otherwise state out nil -2)
+ (its-defrule-otherwise state nil "[u]" -3)
+))
+
+ (defconst its-aynu-tail-alist
+ (let ((common '(("k" "\e$(O&n\e(B" (("\e$(O%C\e(B" "[k]" -1)))
+ ("s" "\e$(O&o\e(B" (("\e$(O%C\e(B" "[s]" -1) (nil "[h]" -2)))
+ ("p" "\e$(O&x\e(B" (("\e$(O%C\e(B" "[p]" -1)))
+ ("m" "\e$(O&y\e(B" (("\e$(O%s\e(B" "[mp]" -1)))
+ ("t" "\e$(O%C\e(B") ("y" "\e$(O%#\e(B") ("w" "\e$(O%%\e(B"))))
+ `((?a ("h" "\e$(O&s\e(B") ("x" "\e$(O&s\e(B") ("r" "\e$(O&z\e(B") ,@common)
+ (?i ("h" "\e$(O&t\e(B") ("x" "\e$(O&t\e(B") ("r" "\e$(O&{\e(B") ,@common)
+ (?u ("h" "\e$(O&u\e(B") ("x" "\e$(O&u\e(B") ("r" "\e$(O&|\e(B") ,@common)
+ (?e ("h" "\e$(O&v\e(B") ("x" "\e$(O&v\e(B") ("r" "\e$(O&}\e(B") ,@common)
+ (?o ("h" "\e$(O&w\e(B") ("x" "\e$(O&w\e(B") ("r" "\e$(O&~\e(B") ,@common))))
+
+ (defun its-defrule-aynu (conso vowel output)
+ (let ((input (concat conso vowel))
+ (tails (and vowel (cdr (assq (aref vowel 0) its-aynu-tail-alist)))))
+ (its-defrule input output)
+ (while tails
+ (its-define-state-aynu input (caar tails) output (nth 1 (car tails))
+ (nth 2 (car tails)))
+ (setq tails (cdr tails)))))
+
+ (defmacro its-define-aynu (&rest rules)
+ (let ((defs (list 'progn))
+ conso vowels output)
+ (while rules
+ (setq vowels '(nil "a" "i" "u" "e" "o")
+ conso (caar rules)
+ output (cdar rules)
+ rules (cdr rules))
+ (while output
+ (when (car output)
+ (setq defs (cons `(its-defrule-aynu ,conso ,(car vowels)
+ ,(car output))
+ defs)))
+ (setq output (cdr output)
+ vowels (cdr vowels))))
+ (nreverse defs)))
+
+ (defun its-defrule-aynu-override-yu (conso)
+ (let ((output (its-get-output (its-goto-state conso)))
+ state)
+ (its-defrule (concat conso "yu")
+ (concat (its-get-output (its-goto-state (concat conso "i")))
+ "\e$(O%e!<\e(B"))
+ (setq state (its-goto-state (concat conso "y")))
+ (its-set-output state (concat output "\e$(O%#\e(B"))
+ (its-make-next-state state -1 output -1)
+ (its-defrule-otherwise state output nil -2))))
+
+(define-its-state-machine its-aynu-map
+ "roma-aynu-kata" "\e$(O%"\e(B" Aynu
+ "Map for Romaji-Aynu-Katakana translation. (Japanese)"
+
+ (defconst its-zenkaku-escape "Z") ;; Escape character to Zenkaku inputs
+ (defconst its-hankaku-escape "~") ;; Escape character to Hankaku inputs
+
+ (its-defrule-select-mode-temporally "q" downcase)
+ (its-defrule-select-mode-temporally "Q" zenkaku-downcase)
+
+ (dolist (small '(("a" "\e$(O%!\e(B") ("i" "\e$(O%#\e(B") ("u" "\e$(O%%\e(B") ("e" "\e$(O%'\e(B") ("o" "\e$(O%)\e(B")
+ ("ka" "\e$(O%u\e(B") ("ku" "\e$(O&n\e(B") ("ke" "\e$(O%v\e(B")
+ ("si" "\e$(O&o\e(B") ("su" "\e$(O&p\e(B")
+ ("tu" "\e$(O%C\e(B") ("to" "\e$(O&q\e(B")
+ ("nu" "\e$(O&r\e(B")
+ ("ha" "\e$(O&s\e(B") ("hi" "\e$(O&t\e(B") ("hu" "\e$(O&u\e(B") ("he" "\e$(O&v\e(B") ("ho" "\e$(O&w\e(B")
+ ("pu" "\e$(O&x\e(B")
+ ("mu" "\e$(O&y\e(B")
+ ("ya" "\e$(O%c\e(B") ("yu" "\e$(O%e\e(B") ("yo" "\e$(O%g\e(B")
+ ("ra" "\e$(O&z\e(B") ("ri" "\e$(O&{\e(B") ("ru" "\e$(O&|\e(B") ("re" "\e$(O&}\e(B") ("ro" "\e$(O&~\e(B")
+ ("wa" "\e$(O%n\e(B")))
+ (its-defrule (concat "x" (car small)) (cadr small)))
+
+ (its-define-aynu
+ ("" nil "\e$(O%"\e(B" "\e$(O%$\e(B" "\e$(O%&\e(B" "\e$(O%(\e(B" "\e$(O%*\e(B")
+ ("k" "\e$(O&n\e(B" "\e$(O%+\e(B" "\e$(O%-\e(B" "\e$(O%/\e(B" "\e$(O%1\e(B" "\e$(O%3\e(B")
+ ("g" "\e$(O%0\e(B" "\e$(O%,\e(B" "\e$(O%.\e(B" "\e$(O%0\e(B" "\e$(O%2\e(B" "\e$(O%4\e(B")
+ ("s" "\e$(O&p\e(B" "\e$(O%5\e(B" "\e$(O%7\e(B" "\e$(O%9\e(B" "\e$(O%;\e(B" "\e$(O%=\e(B")
+ ("z" nil "\e$(O%6\e(B" "\e$(O%8\e(B" "\e$(O%:\e(B" "\e$(O%<\e(B" "\e$(O%>\e(B")
+ ("vs" nil nil nil nil "\e$(O%|\e(B" nil)
+ ("sh" "\e$(O%7%c\e(B" "\e$(O%7%c\e(B" "\e$(O%7\e(B" "\e$(O%7%e\e(B" "\e$(O%7%'\e(B" "\e$(O%7%g\e(B")
+ ("j" nil "\e$(O%8%c\e(B" "\e$(O%8\e(B" "\e$(O%8%e\e(B" "\e$(O%8%'\e(B" "\e$(O%8%g\e(B")
+ ("t" "\e$(O%C\e(B" "\e$(O%?\e(B" "\e$(O%A\e(B" "\e$(O%H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olist (yu '("k" "g" "s" "z" "sh" "j" "t" "d"
+ "c" "ch" "n" "h" "b" "p" "m" "r"))
+ (its-defrule-aynu-override-yu yu))
+
+ (its-defrule "kk" "\e$(O%C\e(B" -1)
+ (its-defrule "ss" "\e$(O%C\e(B" -1)
+ (its-defrule "pp" "\e$(O%C\e(B" -1)
+ (its-defrule "vv" "\e$(O%C\e(B" -1)
+
+;; SYMBOL Input
+ (its-defrule "z1" "\e$(O!{\e(B") (its-defrule "z!" "\e$(O!|\e(B")
+ (its-defrule "z2" "\e$(O"&\e(B") (its-defrule "z@" "\e$(O"'\e(B")
+ (its-defrule "z3" "\e$(O"$\e(B") (its-defrule "z#" "\e$(O"%\e(B")
+ (its-defrule "z4" "\e$(O""\e(B") (its-defrule "z$" "\e$(O"#\e(B")
+ (its-defrule "z5" "\e$(O!~\e(B") (its-defrule "z%" "\e$(O"!\e(B")
+ (its-defrule "z6" "\e$(O!y\e(B") (its-defrule "z^" "\e$(O!z\e(B")
+ (its-defrule "z7" "\e$(O!}\e(B") (its-defrule "z&" "\e$(O!r\e(B")
+ (its-defrule "z8" "\e$(O!q\e(B") (its-defrule "z*" "\e$(O!_\e(B")
+ (its-defrule "z9" "\e$(O!i\e(B") (its-defrule "z(" "\e$(O!Z\e(B")
+ (its-defrule "z0" "\e$(O!j\e(B") (its-defrule "z)" "\e$(O![\e(B")
+ (its-defrule "z-" "\e$(O!A\e(B") (its-defrule "z_" "\e$(O!h\e(B")
+ (its-defrule "z=" "\e$(O!b\e(B") (its-defrule "z+" "\e$(O!^\e(B")
+ (its-defrule "z\\" "\e$(O!@\e(B") (its-defrule "z|" "\e$(O!B\e(B")
+ (its-defrule "z`" "\e$(O!-\e(B") (its-defrule "z~" "\e$(O!/\e(B")
+
+ (its-defrule "zq" "\e$(O!T\e(B") (its-defrule "zQ" "\e$(O!R\e(B")
+ (its-defrule "zw" "\e$(O!U\e(B") (its-defrule "zW" "\e$(O!S\e(B")
+ ; e
+ (its-defrule "zr" "\e$(O!9\e(B") (its-defrule "zR" "\e$(O!8\e(B")
+ (its-defrule "zt" "\e$(O!:\e(B") (its-defrule "zT" "\e$(O!x\e(B")
+ ; y u i o
+ (its-defrule "zp" "\e$(O")\e(B") (its-defrule "zP" "\e$(O",\e(B")
+ (its-defrule "z[" "\e$(O!X\e(B") (its-defrule "z{" "\e$(O!L\e(B")
+ (its-defrule "z]" "\e$(O!Y\e(B") (its-defrule "z}" "\e$(O!M\e(B")
+ ; a
+ (its-defrule "zs" "\e$(O!3\e(B") (its-defrule "zS" "\e$(O!4\e(B")
+ (its-defrule "zd" "\e$(O!5\e(B") (its-defrule "zD" "\e$(O!6\e(B")
+ (its-defrule "zf" "\e$(O!7\e(B") (its-defrule "zF" "\e$(O"*\e(B")
+ (its-defrule "zg" "\e$(O!>\e(B") (its-defrule "zG" "\e$(O!=\e(B")
+ (its-defrule "zh" "\e$(O"+\e(B")
+ (its-defrule "zj" "\e$(O"-\e(B")
+ (its-defrule "zk" "\e$(O",\e(B")
+ (its-defrule "zl" "\e$(O"*\e(B")
+ (its-defrule "z;" "\e$(O!+\e(B") (its-defrule "z:" "\e$(O!,\e(B")
+ (its-defrule "z\'" "\e$(O!F\e(B") (its-defrule "z\"" "\e$(O!H\e(B")
+ ; z
+ (its-defrule "zx" ":-") (its-defrule "zX" ":-)")
+ (its-defrule "zc" "\e$(O!;\e(B") (its-defrule "zC" "\e$(O!n\e(B")
+ (its-defrule "zv" "\e$(O"(\e(B") (its-defrule "zV" "\e$(O!`\e(B")
+ (its-defrule "zb" "\e$(O!k\e(B") (its-defrule "zB" "\e$(O"+\e(B")
+ (its-defrule "zn" "\e$(O!l\e(B") (its-defrule "zN" "\e$(O"-\e(B")
+ (its-defrule "zm" "\e$(O!m\e(B") (its-defrule "zM" "\e$(O".\e(B")
+ (its-defrule "z," "\e$(O!E\e(B") (its-defrule "z<" "\e$(O!e\e(B")
+ (its-defrule "z." "\e$(O!D\e(B") (its-defrule "z>" "\e$(O!f\e(B")
+ (its-defrule "z/" "\e$(O!&\e(B") (its-defrule "z?" "\e$(O!g\e(B")
+ )
+
+(define-its-state-machine-append its-aynu-map
+ (if its-aynu-enable-double-n
+ (its-defrule "nn" "\e$(O%s\e(B"))
+
+ (its-defrule "-" its-aynu-horizontal)
+ (its-defrule "." its-aynu-period)
+ (its-defrule "," its-aynu-comma)
+ (its-defrule "[" its-aynu-open-bracket)
+ (its-defrule "]" its-aynu-close-bracket)
+
+ (unless its-aynu-kick-conversion-on-space
+ (its-defrule " " " "))
+
+ (if its-aynu-enable-zenkaku-alphabet
+ (progn
+ (its-defrule "1" "\e$(O#1\e(B") (its-defrule "2" "\e$(O#2\e(B")
+ (its-defrule "3" "\e$(O#3\e(B") (its-defrule "4" "\e$(O#4\e(B")
+ (its-defrule "5" "\e$(O#5\e(B") (its-defrule "6" "\e$(O#6\e(B")
+ (its-defrule "7" "\e$(O#7\e(B") (its-defrule "8" "\e$(O#8\e(B")
+ (its-defrule "9" "\e$(O#9\e(B") (its-defrule "0" "\e$(O#0\e(B")
+ (its-defrule "!" "\e$(O!*\e(B") (its-defrule "@" "\e$(O!w\e(B")
+ (its-defrule "#" "\e$(O!t\e(B") (its-defrule "$" "\e$(O!p\e(B")
+ (its-defrule "%" "\e$(O!s\e(B") (its-defrule "^" "\e$(O!0\e(B")
+ (its-defrule "&" "\e$(O!u\e(B") (its-defrule "*" "\e$(O!v\e(B")
+ (its-defrule "(" "\e$(O!J\e(B") (its-defrule ")" "\e$(O!K\e(B")
+ (its-defrule "=" "\e$(O!a\e(B") (its-defrule "`" "\e$(O!.\e(B")
+ (its-defrule "\\" "\e$(O!o\e(B") (its-defrule "|" "\e$(O!C\e(B")
+ (its-defrule "_" "\e$(O!2\e(B") (its-defrule "+" "\e$(O!\\e(B")
+ (its-defrule "{" "\e$(O!P\e(B") (its-defrule "}" "\e$(O!Q\e(B")
+ (its-defrule ":" "\e$(O!'\e(B") (its-defrule ";" "\e$(O!(\e(B")
+ (its-defrule "\"" "\e$(O!I\e(B") (its-defrule "'" "\e$(O!G\e(B")
+ (its-defrule "<" "\e$(O!c\e(B") (its-defrule ">" "\e$(O!d\e(B")
+ (its-defrule "?" "\e$(O!)\e(B") (its-defrule "/" "\e$(O!?\e(B"))
+ (progn
+ (its-defrule "1" "1") (its-defrule "2" "2")
+ (its-defrule "3" "3") (its-defrule "4" "4")
+ (its-defrule "5" "5") (its-defrule "6" "6")
+ (its-defrule "7" "7") (its-defrule "8" "8")
+ (its-defrule "9" "9") (its-defrule "0" "0")
+ (its-defrule "!" "!") (its-defrule "@" "@")
+ (its-defrule "#" "#") (its-defrule "$" "$")
+ (its-defrule "%" "%") (its-defrule "^" "^")
+ (its-defrule "&" "&") (its-defrule "*" "*")
+ (its-defrule "(" "(") (its-defrule ")" ")")
+ (its-defrule "=" "=") (its-defrule "`" "`")
+ (its-defrule "\\" "\\") (its-defrule "|" "|")
+ (its-defrule "_" "_") (its-defrule "+" "+")
+ (its-defrule "{" "{") (its-defrule "}" "}")
+ (its-defrule ":" ":") (its-defrule ";" ";")
+ (its-defrule "\"" "\"") (its-defrule "'" "'")
+ (its-defrule "<" "<") (its-defrule ">" ">")
+ (its-defrule "?" "?") (its-defrule "/" "/"))))
+
+(provide 'its/aynu)
+;;; its/aynu.el ends here.