1%%%%%%%%%%%%%%%%%%%%%%%%%%% asmo449.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2% asmo449.sty
3% Scanner for ASMO 449 Code (ISO 9036) (table driven)
4% to install it, include it as a LaTeX package or style option "asmo449"
5% with Plain TeX, say "\input asmo449.sty"
6% to activate it, say "\setcode {asmo449}" or "\setcode {iso9036}"
7% 26.04.2003
8%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9% (c) Klaus Lagally
10%     Institut fuer Formale Methoden der Informatik
11%     Universitaet Stuttgart
12%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13
14\ifx \asmoatcode \undefined \else \expandafter \endinput
15\fi % load only once
16
17\chardef \asmoatcode = \catcode`\@  \catcode`\@ = 11
18
19\a@ident {asmo449.sty} {3.11 ASMO449 input encoding (table)} {26.04.2003}
20
21%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22% dynamic definitions for Arabic
23%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24\gdef \setasmo@codes {% activate and change some codes
25\a@digits = {0123456789}%
26\a@paren  = {"'([}%
27\a@first = {}%
28}% end of dynamic definitions for Arabic
29%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30
31\def \asmo@tbli {% ASMO re-encoding table
32\\AQ|\\BQA\\CQa\\DQw\\EQi\\FQy\\GA\\Hb\\IT%
33\\Jt\\KC\\LG\\MH\\NX\\Od\\PF\\Qr\\Rz%
34\\Ss\\Tx\\US\\VD\\WV\\XZ\\YP\\ZR%
35\\af\\bq\\ck\\dl\\em\\fn\\gh\\hw\\iY%
36\\jy\\k"aN\\l"uN\\m"iN\\n"a\\o"u\\p"i\\q@\\r""%
37\\s@\\t@\\u@\\v@\\w@\\x@\\y@\\z@\\`B\\@@}
38
39\def \asmo@tblii {% shadda + harakaat
40\\q\\sk\\tl\\um\\vn\\wo\\xp}
41
42\def \asmo@tbliii {% medial special characters
43\\\@\sc@endscan\\-\asmo@minus\\"\asmo@rquote}
44
45\def \asmo@tbliv {% initial special characters
46\\\@\sc@endscan\\G\asmo@alif\\"\asmo@lquote\\'\asmo@lquote}
47
48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49
50\newif \ifa@quote
51
52\def \asmo@beg #1#2{% start ASMO 449 scanner
53	\h@mzafalse  \iz@fetfalse \novocalize % because of explicit quoting
54	\@ssimfalse
55	\def \next {\asmo@word #1#2}%
56	\def \l@@kup ##1\\#1##2\\##3\@@ {% look for special chars
57		\ifx *##2\relax\xpa\xpa\xpa\iffalse\fi\fi % not found; else
58		\def \next {##2#2}}%
59\iftrue \xpa \l@@kup \asmo@tbliv \\#1*\\\@@ \else
60\ifx #1/\global \a@tokens ={#1}\def \next {\asmo@word #2}% /x
61\fi\fi \next }
62
63{\catcode `\^ 7 \catcode `\^^M=13
64\gdef \asmo@word #1#2{% transform input into internal notation
65	\def \l@@kup ##1\\#1##2\\##3\@@ {% look for special chars
66		\ifx *##2\relax\xpa\xpa\xpa\iffalse\fi\fi %
67		\def \next {##2#2}}%
68\iftrue \xpa \l@@kup \asmo@tbliii \\#1*\\\@@ \else %
69\ifx #1/\def \next {\sc@back #1#2}\else %
70\if \nxp ^^M\nxp #1\def \next {\asmo@par #2}\else %
71\ifx #1#2\def \next {\asmo@word #1-#2}\else %
72	\def \l@@kup ##1\\#1##2\\##3\@@ {% reencode char
73		\def \sc@char {##2}}%
74	\xpa \l@@kup \asmo@tbli \\#1\nxp #1\\\@@ % reencode
75	\sc@put %
76	\def \l@@kup ##1\\#2##2\\##3\@@ {% look for shadda variants
77		\ifx *##2\relax\def \next {\asmo@word #2}%
78		\else \def \next {\asmo@word #1##2}\fi }%
79	\xpa \l@@kup \asmo@tblii \\#2*\\\@@ % double 1st char
80\fi\fi\fi\fi \next }%
81} % catcode 13
82
83%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84
85\def \asmo@alif {% alif at the beginning of a word
86\def \sc@char {a}\sc@put \asmo@word }
87
88\def \asmo@minus {% hyphen between words
89\def \sc@char {-}\sc@put \asmo@beg }
90
91\def \asmo@lquote {% left quote
92\ifa@quote \def \sc@char {'}\global\a@quotefalse
93\else \def \sc@char {`}\global\a@quotetrue
94\fi
95\sc@put \asmo@beg }
96
97\def \asmo@rquote {% right quote
98\global\a@quotefalse
99\def \sc@char {'}\sc@put \asmo@word }
100
101\def \asmo@par #1\@ \@@ {% new line, push back the rest
102\sc@back \\#1\@ \@@ }
103
104%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105
106\def \set@asmo {% select the ASMO 449 scanner
107\let \sc@beg \asmo@beg 		\let \sc@word \asmo@word
108\let \sc@back \sc@@back		\let \sc@endscan \sc@@endscan
109\global\let \a@scan \a@@scan   	\setasmo@codes		\a@quotefalse
110\a@message {input encoding set to ASMO 449 (ISO 9036) conventions}}
111
112\xpa \def \xpa \sc@table \xpa {\sc@table % add the ASMO449 encoding
113asmo449\set@asmo	iso9036\set@asmo }
114
115%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116
117\a@message {scanner for code ASMO 449 (ISO 9036) installed.}
118
119\catcode `\@ = \asmoatcode
120\endinput
121%%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122
123