summaryrefslogtreecommitdiff
path: root/language/arabic/arabtex/texinput/isiri.sty
blob: b4664d9b3ef7cbcc306d481e6e64daa0a32f5dfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
%%%%%%%%%%%%%%%%%%%%%%%%%%% isiri.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% isiri.sty
% Scanner for ISIRI 3342 Code 
% to install it, include it as a LaTeX package or style option "isiri"
% with Plain TeX, say "\input isiri.sty"
% to activate it, say "\setcode {isiri3342}" or "\setcode {isiri}"
% 26.04.2003
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (c) Klaus Lagally
%     Institut fuer Formale Methoden der Informatik
%     Universitaet Stuttgart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifx \isiriatcode \undefined \else \expandafter \endinput
\fi % load only once

\chardef \isiriatcode = \catcode`\@  \catcode`\@ = 11

\a@ident {isiri.sty} {3.11 ISIRI 3342 input encoding } {26.04.2003}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \isiri@catcodes {% assignments for ISIRI 3342
\countdef \is@m=2	\countdef \is@n=4       
\is@m = 160        \is@n = 32
\loop \ifnum \catcode \is@m = 11 \else \catcode \is@m = 11 \fi
\global\lccode \is@m = \is@n
\ifnum 255 > \is@m \advance \is@m 1 \advance \is@n 1 \repeat
\is@m=0 \is@n=0 \catcode `\^ 7 \catcode `\^^a0 12 }

{\isiri@catcodes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% dynamic definitions for Arabic
{\catcode `\^ 7 \catcode `\ =9 \catcode `\^^M=9 \catcode `\^^I=9
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef \setisi@codes {% activate and change some codes
\globaldefs=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def \sc@^^a0 {@}  \def \sc@^^a1 {||}  \def \sc@^^a2 {-}   \def \sc@^^a3 {!}
\def \sc@^^a4 {\a@dlr}                 \def \sc@^^a5 {\a@pct}   
\def \sc@^^a6 {\a@amp}                 \def \sc@^^a7 {\a@qt}
\def \sc@^^a8 {(}  \def \sc@^^a9 {)}   \def \sc@^^aa {*}   \def \sc@^^ab {+}
\def \sc@^^ac {,}  \def \sc@^^ad {-}   \def \sc@^^ae {.}   \def \sc@^^af {/}

\def \sc@^^b0 {0}  \def \sc@^^b1 {1}   \def \sc@^^b2 {2}   \def \sc@^^b3 {3}
\def \sc@^^b4 {4}  \def \sc@^^b5 {5}   \def \sc@^^b6 {6}   \def \sc@^^b7 {7}
\def \sc@^^b8 {8}  \def \sc@^^b9 {9}   \def \sc@^^ba {:}   \def \sc@^^bb {;}
\def \sc@^^bc {\a@lab}                 \def \sc@^^bd {=}   
\def \sc@^^be {\a@rab}                 \def \sc@^^bf {?}

\def \sc@^^c0 {QA} \def \sc@^^c1 {A}   \def \sc@^^c2 {Q|}  \def \sc@^^c3 {b}
\def \sc@^^c4 {p}  \def \sc@^^c5 {t}   \def \sc@^^c6 {C}   \def \sc@^^c7 {G}
\def \sc@^^c8 {J}  \def \sc@^^c9 {H}   \def \sc@^^ca {X}   \def \sc@^^cb {d}
\def \sc@^^cc {F}  \def \sc@^^cd {r}   \def \sc@^^ce {z}   \def \sc@^^cf {j}

\def \sc@^^d0 {s}  \def \sc@^^d1 {x}   \def \sc@^^d2 {S}   \def \sc@^^d3 {D}
\def \sc@^^d4 {V}  \def \sc@^^d5 {Z}   \def \sc@^^d6 {P}   \def \sc@^^d7 {R}
\def \sc@^^d8 {f}  \def \sc@^^d9 {q}   \def \sc@^^da {\n@xp \a@k}   
\def \sc@^^db {g}
\def \sc@^^dc {l}  \def \sc@^^dd {m}   \def \sc@^^de {n}   \def \sc@^^df {w}

\def \sc@^^e0 {h}  \def \sc@^^e1 {Y}   \def \sc@^^e2 {[}   \def \sc@^^e3 {]}
\def \sc@^^e4 {\a@lbc}                 \def \sc@^^e5 {\a@rbc}   
\def \sc@^^e6 {'}  \def \sc@^^e7 {`}
\def \sc@^^e8 {*}  \def \sc@^^e9 {B}   
\def \sc@^^ea {\a@bar}                 \def \sc@^^eb {\a@bsl}
\def \sc@^^ec {@}  \def \sc@^^ed {@}   \def \sc@^^ee {@}   \def \sc@^^ef {@}

\def \sc@^^f0 {"a} \def \sc@^^f1 {"i}  \def \sc@^^f2 {"u}  \def \sc@^^f3 {"aN}
\def \sc@^^f4 {"iN}\def \sc@^^f5 {"uN} \def \sc@^^f6 {@}   \def \sc@^^f7 {""}
\def \sc@^^f8 {Qa} \def \sc@^^f9 {Qw}  \def \sc@^^fa {Qi}  \def \sc@^^fb {QY}
\def \sc@^^fc {T}  \def \sc@^^fd {k}   \def \sc@^^fe {y}   \def \sc@^^ff {E}
\a@digits = {0123456789^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9}     	
\a@paren  = {()[]^^a8^^a9^^e2^^e3}
\a@first = {"`^^e6}
\globaldefs=0 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}% end of dynamic definitions for Arabic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\gdef \isi@scan #1>{% standard scanner call: token sequence -> \a@tokens
\iftest@scan \tracingmacros = 1 
\ifshow \else \lowercase{\a@verb #1>}\fi\fi
\global\def \a@rest {}\global\a@tokens = {}\sc@beg #1\@ \@@ 
\iftest@scan \tracingmacros = 0 %
\xpa \a@verb \xpa (\the\a@tokens )>\fi }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

{\catcode `\^ 7
\gdef \isi@beg #1#2{% start ISIRI 3342 scanner
\h@mzafalse  \iz@fetfalse \yahdots \novocalize % because of explicit quoting
	\@ssimfalse
\case #1\of 
{      \@{\sc@endscan #2}                % finished
     ^^c1{\isi@alif@beg #2} 
     ^^e6{\isi@lquote #2}
\default {\isi@word #1#2}
}\endcase }

{\catcode `\^^M=13 \endlinechar = -1
\gdef \isi@word #1#2{% transform input into internal notation
\ifx #1\@ \def \next {\sc@endscan #2}\else % finished
\if \nxp ^^M\nxp #1\def \next {\isi@par #1#2}% active character
\else \def \next {\isi@w@rd #1#2}%
\fi\fi \next }%
} % catcode 13

\gdef \isi@w@rd #1#2{% special cases
\case #1\of 
{   	  #2{\isi@word #1-#2}
	   -{\isi@minus #2} 
	^^a0{\sc@back #2} 
	^^ad{\isi@minus #2} 
	^^c1{\isi@alif #2} 
	^^c2{\isi@hamza #2}
	^^df{\isi@waw #2} 
	^^e0{\isi@hah #2} 
	^^e1{\isi@Yah #2} 
	^^e7{\isi@rquote #2} 
	^^fe{\isi@yah #2} 
\default {\isi@@word #1#2}
}\endcase }

\gdef \isi@@word #1#2{% default branch
\ifcat a\nxp #1\edef \sc@char {\csname sc@#1\endcsname }%
\else \def \sc@char {\nxp #1}%
\fi \sc@put 
\ifx #2^^f6\def \next {\isi@word #1}% shadda
\else \def \next {\isi@word #2}%
\fi \next }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\gdef \isi@alif@beg #1{% alif 
\ifx #1^^a2\def \next {\isi@alif@P }\else
\def \next {\isi@word #1}\def \sc@char {a}\sc@put 
\fi \next }

\gdef \isi@alif #1{% alif 
\ifx #1^^a2\def \next {\isi@alif@P }\else
\def \next {\isi@word #1}\def \sc@char {A}\sc@put 
\fi \next }

\gdef \isi@alif@P #1{% alif PCN hamza ? 
\ifx #1^^c2\def \sc@char {Qa}\def \next {\isi@word }\else
\def \sc@char {A-}\def \next {\isi@word #1}%
\fi \sc@put \next }

\gdef \isi@waw #1{% waw
\ifx #1^^a2\def \next {\isi@waw@P }\else
\def \next {\isi@word #1}\def \sc@char {w}\sc@put 
\fi \next }

\gdef \isi@waw@P #1{% waw PCN hamza ? 
\ifx #1^^c2\def \sc@char {Qw}\def \next {\isi@word }\else
\def \sc@char {w-}\def \next {\isi@word #1}%
\fi \sc@put \next }

\gdef \isi@yah #1{% yah
\ifx #1^^a2\def \next {\isi@yah@P }\else
\def \next {\isi@word #1}\def \sc@char {y}\sc@put 
\fi \next }

\gdef \isi@Yah #1{% Yah
\ifx #1^^a2\def \next {\isi@yah@P }\else
\def \next {\isi@word #1}\def \sc@char {Y}\sc@put 
\fi \next }

\gdef \isi@yah@P #1{% yah PCN hamza ? 
\ifx #1^^c2\def \sc@char {QY}\def \next {\isi@word }\else
\def \sc@char {y-}\def \next {\isi@word #1}%
\fi \sc@put \next }

\gdef \isi@hah #1{% hah
\ifx #1^^a2\def \next {\isi@hah@P }\else
\def \next {\isi@word #1}\def \sc@char {h}\sc@put 
\fi \next }

\gdef \isi@hah@P #1{% hah PCN hamza ? 
\ifx #1^^c2\def \sc@char {Qh}\def \next {\isi@word }\else
\def \sc@char {h-}\def \next {\isi@word #1}%
\fi \sc@put \next }

\gdef \isi@hamza #1{% hamza
\ifx #1^^a2\def \sc@char {QY}\def \next {\isi@word }%
\else \def \sc@char {Q|}\def \next {\isi@word #1}%
\fi \sc@put \next }

\gdef \isi@minus {% hyphen between words
\def \sc@char {-}\sc@put \isi@beg }

\gdef \isi@lquote {% left quote
\def \sc@char {`}\sc@put \isi@beg }

\gdef \isi@rquote {% right quote
\def \sc@char {'}\sc@put \isi@word }

\gdef \isi@par #1\@ \@@ {% new line, push back the rest
\sc@back \\ #1\@ \@@ }

\gdef \isi@endscan \@@ {\global\let \a@scan \isi@scan }
}% catcode ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} % \isiri@catcodes

\def \set@isiri {% select the ISIRI 3342 scanner
\let \sc@beg \isi@beg 		\let \sc@word \isi@word  
\let \sc@back \sc@@back		\let \sc@endscan \isi@endscan
\global\let \a@scan \isi@scan   \setisi@codes	
\isiri@catcodes 		\yahdots
\a@message {input encoding set to ISIRI 3342 conventions}}

\xpa \def \xpa \sc@table \xpa {\sc@table % add the ASMO449 encoding
isiri\set@isiri		isiri3342\set@isiri	}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\a@message {scanner for code ISIRI 3342 installed.}

\catcode `\@ = \isiriatcode
\endinput
%%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%