%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% awrite.sty
% ArabTeX
% Version 19.03.96
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (c) Klaus Lagally
%     Institut fuer Informatik
%     Universitaet Stuttgart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\a@ident {awrite.sty} {3.04 build output word } {19.03.96}

\UsePackage {arabsymb}	% character definitions
\UsePackage {aboxes}	% deposit output boxes

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% dynamic definitions for Arabic
{\catcode `\ =9 \catcode `\^^M=9 \catcode `\^^I=9
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef \def@arabskel {% define Arabic character skeletons
\globaldefs 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def \sk@a   {\chr@cls 10 \chr@cd \a@alif  \@confalse }	% alif
\def \sk@b   {\chr@cls  1 \chr@cd \a@bah }      	% bah without dot
\def \sk@b@p {\chr@cls  9 \chr@cd \a@bah@p }      	% bah with loop
\def \sk@d   {\chr@cls 10 \chr@cd \a@dal   \@confalse }	% dal
\def \sk@d@p {\chr@cls 10 \chr@cd \a@dal@p \@confalse }	% dal with loop
\def \sk@dd  {\chr@cls  2 \chr@cd \a@dad }		% ddad
\def \sk@f   {\chr@cls  6 \chr@cd \a@fah }      	% fah 
\def \sk@f@s {\chr@cls  6 \chr@cd \a@fah@s }    	% fah without dot
\def \sk@g@p {\chr@cls  5 \chr@cd \a@kaf@p@s }  	% gaf with loop
\def \sk@g@s {\chr@cls  5 \chr@cd \a@gaf@s }    	% gaf with bar
\def \sk@h   {\chr@cls 10 \chr@cd \a@hah }      	% hah
\def \sk@h@s {\chr@cls 10 \chr@cd \a@hah@spec }		% urdu hah
\def \sk@hh  {\chr@cls  3 \chr@cd \a@hhah }		% hhah
\def \sk@j   {\chr@cls  3 \chr@cd \a@gim }		% gim
\def \sk@k   {\chr@cls  5 \chr@cd \a@kaf }      	% kaf
\def \sk@k@s {\chr@cls  5 \chr@cd \a@kaf@s }    	% kaf without mark
\def \sk@kh  {\chr@cls  3 \chr@cd \a@khah }		% khah
\def \sk@l   {\chr@cls  0 \chr@cd \a@lam }      	% lam
\def \sk@m   {\chr@cls 10 \chr@cd \a@mim }      	% mim
\def \sk@n   {\chr@cls  1 \chr@cd \a@nun }      	% nun without dot
\def \sk@n@p {\chr@cls  9 \chr@cd \a@nun@p }		% nun with loop
\def \sk@q   {\chr@cls  6 \chr@cd \a@qaf } 		% qaf
\def \sk@r   {\chr@cls  8 \chr@cd \a@rah   \@confalse }	% rah
\def \sk@r@p {\chr@cls  8 \chr@cd \a@rah@p \@confalse }	% rah with loop
\def \sk@r@s {\chr@cls  8 \chr@cd \a@rah@s \@confalse }	% rah with two dots
\def \sk@s   {\chr@cls  2 \chr@cd \a@sin }      	% sin
\def \sk@s@p {\chr@cls  2 \chr@cd \a@sin@p }      	% sin with two dots
\def \sk@sh  {\chr@cls  2 \chr@cd \a@shin }     	% shin
\def \sk@ss  {\chr@cls  2 \chr@cd \a@sad }		% ssad
\def \sk@ts  {\chr@cls  3 \chr@cd \a@tsah }		% tchah
\def \sk@tt  {\chr@cls  7 \chr@cd \a@ttah }		% ttah
\def \sk@v   {\chr@cls  6 \chr@cd \a@vah }		% vah
\def \sk@w   {\chr@cls 10 \chr@cd \a@waw   \@confalse }	% waw
\def \sk@y   {\chr@cls  1 \chr@cd \a@yah } 		% yah
\def \sk@y@h {\chr@cls  1 \chr@cd \a@yah@h }  		% yah with stroke
\def \sk@y@p {\chr@cls  1 \chr@cd \a@yah@p } 		% yah bari
\def \sk@z   {\chr@cls  8 \chr@cd \a@zay   \@confalse }	% zay
\def \sk@zh  {\chr@cls  8 \chr@cd \a@zhah  \@confalse }	% zhah
\def \sk@zz  {\chr@cls  7 \chr@cd \a@zzah }		% zzah

\def \sk@B   {\chr@cls 10 \chr@cd \a@tatwil }		% tatwil
\def \sk@P   {\chr@cls  4 \chr@cd \a@ain }		% `ain
\def \sk@Q   {\chr@cls 10 \chr@cd \a@hamza@iso \@confalse}% hamza
\def \sk@W   {\chr@cls 10 \chr@cd \a@break \@confalse }	% small space

\def \sk@@   {\chr@cls 10 \chr@cd `* }			% star
\globaldefs 0 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef \def@arabchars {% define character macros for Arabic
\globaldefs 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def \tc@a {\sk@a }			% alif
\def \tc@b {\sk@b 	\chr@mod    4 }	% bah
\def \tc@c {\sk@hh 	\chr@mod    7 }	% gim with hamza
\def \tc@d {\sk@d }    			% dal
\def \tc@f {\sk@f 	\chr@mod    1 }	% fah
\def \tc@g {\sk@g@s }			% gaf with bar
\def \tc@h {\sk@h }                 	% hah
\def \tc@j {\sk@zh }    		% zhah
\def \tc@k {\sk@k }			% kaf
\def \tc@l {\sk@l }                 	% lam
\def \tc@m {\sk@m }                 	% mim
\def \tc@n {\sk@n 	\chr@mod    1 }	% nun
\def \tc@p {\sk@b 	\chr@mod    6 } % pah
\def \tc@q {\sk@q	\chr@mod    2 }	% qaf
\def \tc@r {\sk@r }    			% rah
\def \tc@s {\sk@s }                 	% sin
\def \tc@t {\sk@b 	\chr@mod    2 } % tah
\def \tc@v {\sk@v	\chr@mod    3 }	% vah
\def \tc@w {\sk@w }    			% waw
\def \tc@x {\sk@sh }                	% shin
\def \tc@y {\sk@y 	\chr@mod    5 } % yah
\def \tc@z {\sk@z }    			% zay

\def \tc@A {\sk@a }			% alif also
\def \tc@B {\sk@B }              	% tatwil
\def \tc@C {\sk@b 	\chr@mod    3 }	% thah
\def \tc@D {\sk@dd }                 	% ddad
\def \tc@E {\sk@y@p	\chr@mod    5 }	% yah bari
\def \tc@F {\sk@d 	\chr@mod    1 }	% dhal
\def \tc@G {\sk@j 	\chr@mod    4 }	% gim
\def \tc@H {\sk@hh }  			% hhah
\def \tc@J {\sk@ts 	\chr@mod    6 } % tchah
\def \tc@K {\sk@k@s 	\chr@mod    3 } % kaf-i-nun
\def \tc@L {\sk@y@h }  			% yah with stroke
\def \tc@M {\sk@n 	\chr@mod    6 } % nya (Malay)
\def \tc@P {\sk@P }			% `ain
\def \tc@Q {\sk@Q }			% hamza
\def \tc@R {\sk@P 	\chr@mod    1 }	% ghain
\def \tc@S {\sk@ss }                 	% ssad
\def \tc@T {\sk@h 	\chr@mod    2 }	% tah marbuta
\def \tc@V {\sk@tt }                	% ttah
\def \tc@W {\sk@W }    			% small space
\def \tc@X {\sk@kh 	\chr@mod    1 } % khah
\def \tc@Y {\sk@y }  			% alif maqsura
\def \tc@Z {\sk@zz }                	% zzah

\tc@def \a@b {\sk@b }			% bah without dot
\tc@def \a@c {\sk@hh	\chr@mod    3 }	% gim with three dots
\tc@def \a@d {\sk@d	\chr@mod    8 }	% dal with ttah
\tc@def \a@e {\sk@d@p }			% dal with loop
\tc@def \a@f {\sk@f@s }			% fah without dot
\tc@def \a@g {\sk@g@p }		  	% gaf with loop
\tc@def \a@h {\sk@h@s	\chr@mod   11 } % urdu hah
\tc@def \a@k {\sk@k@s }			% kaf without mark
\tc@def \a@l {\sk@l 	\chr@mod   12 }	% kurdish lam
\tc@def \a@m {\sk@k }			% kaf
\tc@def \a@n {\sk@n }			% nun without dot
\tc@def \a@p {\sk@P	\chr@mod    3 }	% `ain with three dots
\tc@def \a@q {\sk@r@p }			% rah with loop
\tc@def \a@r {\sk@r	\chr@mod    8 }	% rah with ttah
\tc@def \a@s {\sk@s@p	\chr@mod   10 }	% sin with two dots
\tc@def \a@t {\sk@b 	\chr@mod    8 }	% tah with ttah
\tc@def \a@v {\sk@b@p 	\chr@mod    2 }	% tah with loop
\tc@def \a@x {\sk@w 	\chr@mod    1 }	% waw with dot (Malay)
\tc@def \a@y {\sk@y	\chr@mod    6 }	% yah with three dots below
\tc@def \a@z {\sk@r@s }       		% rah with two dots

\tc@def \a@C {\sk@hh 	\chr@mod    2 }	% hhah with two dots above
\tc@def \a@D {\sk@d	\chr@mod    4 }	% dal with dot below
\tc@def \a@E {\sk@y	\chr@mod   14 }	% kurdish yah
\tc@def \a@F {\sk@f@s 	\chr@mod    4 }	% fah with dot below
\tc@def \a@G {\sk@hh 	\chr@mod    5 }	% hhah with two dots below
\tc@def \a@H {\sk@h \@confalse }	% hah marbuta !
\tc@def \a@J {\sk@P 	\chr@mod    1 }	% ghain
\tc@def \a@K {\sk@k@s	\chr@mod    1 }	% kaf with dot
\tc@def \a@L {\sk@k }			% kaf
\tc@def \a@M {\sk@k }			% kaf
\tc@def \a@N {\sk@n@p }			% nun with loop
\tc@def \a@Q {\sk@f@s 	\chr@mod    1 }	% fah with one dot above
\tc@def \a@R {\sk@r	\chr@mod   13 }	% kurdish rah
\tc@def \a@S {\sk@s	\chr@mod    2 }	% sin with two dots
\tc@def \a@T {\sk@b	\chr@mod   15 }	% tah with two vert. dots above
\tc@def \a@V {\sk@f@s 	\chr@mod    6 }	% fah with three dots below
\tc@def \a@W {\sk@w	\chr@mod   12 }	% kurdish waw
\tc@def \a@Y {\sk@y 	\chr@mod    9 } % yah with two vert. dots below
\tc@def \a@Z {\sk@s	\chr@mod   15 }	% sin with two dots vertical

\iffalse
\def \tc@e {\sk@@ }	\def \tc@N {\sk@@ }	% reserved
\def \tc@i {\sk@@ }	\def \tc@I {\sk@@ }	% reserved
\def \tc@o {\sk@@ }	\def \tc@O {\sk@@ }	% reserved
\def \tc@u {\sk@@ }	\def \tc@U {\sk@@ }	% reserved

\tc@def \a@a {\sk@@ }	\tc@def \a@i {\sk@@ }	% reserved
\tc@def \a@o {\sk@@ }	\tc@def \a@u {\sk@@ }	% reserved
\tc@def \a@A {\sk@@ }	\tc@def \a@I {\sk@@ }	% reserved
\tc@def \a@O {\sk@@ }	\tc@def \a@U {\sk@@ }	% reserved
\fi
\globaldefs 0 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}% end of dynamic definitions for Arabic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \a@@write #1>{% Arabic output
\iftest@write \iftest@parse \else
\a@verb (#1 )>\fi
\tracingmacros   1 \fi
\a@write@hook
\ifa@@write \aw@beg #1>0+0*>0+0*>\fi
\iftest@write \tracingmacros   0 \fi }

\let \a@write \a@@write		\let \a@write@hook \relax

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

\def \aw@beg #1#2*#3#4*#5{% start output
% c m * c m * c
%   \global\@highfalse \@raisefalse \@tiefalse 
   \a@norm \leavevmode
   \test@chr #1\def \next {\aw@end #1#2*#3#4*#5}%
\ifx #1-\test@chr #3\chr@fam #3%
   \def \next {\aw@mid #3#4*#5}%
   \ifx #3>\ac@other #1#3%
\fi\fi \next }

\def \aw@end #1#2*#3#4*#5{% character is not joined to the left
% c m * c m * c
\ifx #1>\let \next \relax \else
\ifx #1-\test@chr #3\chr@fam #3%
	\def \next {\aw@end #3#4*#5}%
\else \a@shift \test@chr #3%
	\ifcat -\nxp #1\ac@other #1#3\def \next {\aw@end #3#4*#5}\else 
	\ifcat \nxp ~\nxp #1\def \next {\aw@end #3#4*#5}\else 
      			\ifx #1Q\@confalse \fi
      			\ifx #1W\@confalse \fi
      		\a@kern \chr@fam #3%
      		\ifx #1a\def \next {\alif@lig #2*#3#4*#5}\else
		\ifx #1A\def \next {\alif@lig #2*#3#4*#5}\else 
	    		\ifx #1h\hah@end #3#4*#5\else
            		\ifx #1T\hah@end #3#4*#5\else
               			\aw@endligs #1#2*#3#5%
            		\fi\fi
            		\ifx #1w\under@cut #2*\else
            		\ifnum \act@cls = \rah@cls \under@cut #2*\else 
            		\ifnum \act@cd = \a@hah \a@kern
            		\fi\fi\fi
         		\put@end #2*#3#4*#5<%
      		\fi\fi
	\fi\fi
\fi\fi \next }

\def \aw@mid #1#2*#3#4*#5{% character is joined to the left
% c m * c m * c
\ifx #1>\let \next \relax \else
\ifx #1-\test@chr #3\chr@fam #3%
   \def \next {\aw@mid #3#4*#5}%
\else
   \a@shift \old@cls   \act@cls \test@chr #3%
      \chr@fam #3%
          \aw@midligs #1#2*#3#5%
   \put@mid #2*#3#4*#5<%
   \if@con \else % initial shape
      \ifnum \old@cls = \kaf@cls % kaf etc.
      \ifx #3a\else \ifx #3l\else
         \unkern \a@mkern
      \fi\fi\fi
   \fi
\fi\fi \next }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif \if@updia % \ifa@kern kann weg	!!!

\def \test@updia #1+#2*{% test for upper diacritic		
% m21 + m22 *
\global\red@mod   #1 \relax
	\ifnum #1 > 9 \global\advance \red@mod -10 \fi
\@updiafalse
\ifnum \red@mod = 0 \else \ifnum \red@mod = 5 \else \@updiatrue
\fi\fi
\if@updia \else
	\ifnum #2 = 0 \else \ifnum #2 = 3 \else
	\ifnum #2 = 6 \else \ifnum #2 = 11 \else \@updiatrue 
	\fi\fi\fi\fi
\fi }

\def \under@cut #1*{% if no upper diacritic		
% m2 *
\ifdim \a@dp > .5ex \@updiafalse \else \test@updia #1*\fi 
\if@updia \unkern \a@mkern \fi }

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

\def \put@end #1*#2<{% deposit non-joining character, set new state
% m * c m * c <
\if@con \ac@end #1*\def \next {\aw@mid #2}%
 \else  \ac@iso #1*\def \next {\aw@end #2}%
\fi }

\def \put@mid #1*#2<{% deposit joining character, set new state
% m * c m * c <
\if@con \ac@mid #1*\def \next {\aw@mid #2}%
 \else  \ac@beg #1*\def \next {\aw@end #2}%
\fi }

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

\iffalse
\def \ac@other #1#2{% punctuation mark			
% c1 c2
\ifx #1)(\else \ifx #1][\else 
\ifx #1`\char \a@lquotes \else 
\ifx #1()\else \ifx #1[]\else
\ifx #1'\char \a@rquotes \else
\if #1\f@sila {\rm \bf ,}\else
#1\a@kern
\fi\fi\fi\fi\fi\fi\fi }

{\catcode `\& 12 \gdef \a@amp {&}}

\def \ac@other #1#2{% punctuation mark			
% c1 c2
\ifx #1)(\else \ifx #1][\else 
\ifx #1`\char \a@lquotes \else 
\ifx #1()\else \ifx #1[]\else
\ifx #1'\char \a@rquotes \else
\if #1\f@sila {\rm \bf ,}\else
\if #1\a@amp {\rm \bf \a@amp}\else
#1\a@kern
\fi
\fi\fi\fi\fi\fi\fi\fi }
\fi

\def \ac@high #1{\raise.5ex\hbox{#1}}

{\catcode `\C 12	\catcode `\^ 12		\catcode `\_ 12
\catcode `\- 11		\catcode `\" 12 	\catcode `\& 12 
%\gdef \f@sila {"}	
\gdef \a@amp {&}
\xpa\gdef \csname sc@-\endcsname {C}
\xpa\gdef \csname sc@=\endcsname {=}

\gdef \ac@other #1#2{% punctuation mark			
% c1 c2
\ifx #1)\ac@high{(}\else \ifx #1(\ac@high{)}\else 
\ifx #1]\ac@high{[}\else \ifx #1[\ac@high{]}\else 
\ifx #1`\char \a@lquotes \else \ifx #1'\char \a@rquotes \else
\if #1\f@sila {\rm \bf ,}\else \if #1\a@amp {\rm \bf \a@amp}\else
\ifx #1^{\rm \tt ^}\else \ifx #1_{\rm \tt _}\else
\ifx #1C\ac@high{-}\else
\ac@high{#1}\a@kern
\fi\fi\fi\fi
\fi\fi\fi\fi\fi\fi\fi }
}

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

\def \ac@iso #1*{% isolated shape			% m *
\put@chr \put@mod #1*\a@norm } % Grundstellung

\def \ac@beg #1*{% initial shape			% m *
\advance \act@cd \a@f@beg \put@chr \put@mod #1*\a@norm }

\def \ac@mid #1*{% medial shape				% m *
\advance \act@cd \a@f@mid \put@chr \put@mod #1*}

\def \ac@end #1*{% final shape  			% m *
\advance \act@cd \a@f@end \put@chr \put@mod #1*}

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

\def \a@shift {% go to next position
\act@cd \chr@cd \act@mod \chr@mod \act@cls \chr@cls \act@tie \chr@tie
  \if@raisetie \@uptietrue \@raisetiefalse \else \@uptiefalse \fi
\ifnum \act@tie = 0 \@tiefalse
\else \advance \act@tie \a@f@mid \@tietrue
\fi
\if@mod \@modfalse % deposit character from family
      \def \put@chr
%      {\put@box {\char \the\act@cd }\put@dot \act@mod \global\@highfalse }%
      {\put@b@x \act@cd \put@d@t \act@mod \global\@highfalse }%
%\else \def \put@chr {\put@box {\char \the\act@cd }}% 
\else \def \put@chr {\put@b@x \act@cd }% 
\fi }

\def \set@high@chr {% raise actual character
\advance \a@disp \a@dsp \@high@chrtrue }

\def \set@mod@chr {% aktuelles Zeichen aus Familie setzen
% \def \put@chr {\put@box {\char \the\act@cd }\put@dot \act@mod }}
 \def \put@chr {\put@b@x \act@cd \put@d@t \act@mod }}

\def \put@b@x #1{% evaluate argument
\edef \t@mp {\nxp\put@box {\char \the #1}}\t@mp }

\def \put@d@t #1{% evaluate argument
\edef \t@mp {\nxp\put@dot {\the #1}}\t@mp }

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

\def \test@chr #1{% get character attributes
\chr@cd 0 \chr@mod 0 \chr@cls \other@cls 
\chr@tie 0 \@confalse
\ifx #1-\chr@cd   \a@tatwil \@contrue \else
\ifx #1|\chr@cd   \a@space@spec \@contrue \else
\if \relax \nxp #1\a@test #1\else
\ifcat a\nxp #1\a@test #1%
\fi\fi\fi\fi }

\def \a@test #1{% switch to character routine
\xpa \ifx \csname tc@\string #1\endcsname \relax
    \chr@cls   \other@cls \chr@cd   \a@block
\else \@contrue \csname tc@\string #1\endcsname \relax % numbers!
\fi }

\def \tc@def #1#2{% define \tc@#1 as {#2}
\xpa \gdef \csname tc@\string #1\endcsname {#2}}

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

\chardef \bah@cls   1	\chardef \gim@cls   3	\chardef \kaf@cls   5  
\chardef \rah@cls   8  	\chardef \other@cls   10

\chardef \a@zwarakay   \a@e@dia

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
