%%%%%%%%%%%%%%%%%%%%%%%%%%% ascan.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ascan.sty
% ArabTeX
% Scanner 10.07.94
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (c) Klaus Lagally
%     Institut fuer Informatik
%     Universitaet Stuttgart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version = {3.02}  		\datum = {10.07.94}
\message {\the\version }	\message {(\the\datum )}

\edef \arabtexconfig {\arabtexconfig 
ascan.sty \the\version \space (\the\datum) }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% dynamic definitions for Arabic
{\catcode `\ =9 \catcode `\^^M=9 \catcode `\^^I=9
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef \seta@codes {% define standard \ArabTeX input coding
\globaldefs=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def \sc@@ {@}   % illegal character
\def \sc@a {a}  \def \sc@b {b} 	\def \sc@c {\ift@rk G\else c\fi }  
\def \sc@d {d} 	\def \sc@e {e} 
\def \sc@f {\ifmagh@ \n@xp \a@F \else f\fi }
\def \sc@g {\ifpasht@ \n@xp \a@g \else g\fi }	\def \sc@h {h}	
\def \sc@i {i}  \def \sc@j {\ift@rk j\else G\fi }  
\def \sc@k {\ifk@fs \n@xp \a@k \else k\fi } 	\def \sc@l {l}
\def \sc@m {m}  \def \sc@n {n}  \def \sc@o {o}  \def \sc@p {p}
\def \sc@q {\ifmagh@ \n@xp \a@Q \else q\fi }
\def \sc@r {r}  \def \sc@s {s}  \def \sc@t {t}	\def \sc@u {u}  
\def \sc@v {\ifmagh@ \n@xp \a@V \else \ift@rk w\else v\fi\fi }
\def \sc@w {w}	\def \sc@x {X}	\def \sc@y {y}  \def \sc@z {z}
\def \sc@A {A}  \def \sc@B {B} 	\def \sc@C {@} 	\def \sc@D {@}
\def \sc@E {\ifpasht@ \n@xp \a@Y \else E\fi }
\def \sc@F {@} 	\def \sc@G {@}  \def \sc@H {\n@xp \a@H }
\def \sc@I {I}  \def \sc@J {@} 	\def \sc@K {@}  \def \sc@L {@}
\def \sc@M {@}  \def \sc@N {N}  \def \sc@O {O}  \def \sc@P {@}
\def \sc@Q {@}  \def \sc@R {@}  \def \sc@S {\n@xp \a@S }  
\def \sc@T {T}  \def \sc@U {U}  \def \sc@V {v}  \def \sc@W {W}  
\def \sc@X {@}	\def \sc@Y {Y}  \def \sc@Z {@}
\a@digits = {0123456789}     	\a@paren  = {()[]}
\a@first  = {.^_-'`~,|"=:}
\globaldefs=0 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}% end of dynamic definitions for Arabic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% additional internal codings; must be distinct!

\def \a@a {a} \def \a@b {b} \def \a@c {c} \def \a@d {d} \def \a@e {e} 
\def \a@f {f} \def \a@g {g} \def \a@h {h} \def \a@i {i} \def \a@j {j} 
\def \a@k {k} \def \a@l {l} \def \a@m {m} \def \a@n {n} \def \a@o {o} 
\def \a@p {p} \def \a@q {q} \def \a@r {r} \def \a@s {s} \def \a@t {t} 
\def \a@u {u} \def \a@v {v} \def \a@w {w} \def \a@y {y} \def \a@z {z}

\def \a@A {A} 		    \def \a@C {C} \def \a@D {D} \def \a@E {E} 
\def \a@F {F} \def \a@G {G} \def \a@H {H} \def \a@I {I} \def \a@J {J} 
\def \a@K {K} \def \a@L {L} \def \a@M {M} \def \a@N {N} \def \a@O {O} 
\def \a@P {P} \def \a@Q {Q} \def \a@R {R} \def \a@S {S} \def \a@T {T} 
\def \a@U {U} \def \a@V {V} \def \a@W {W} \def \a@Y {Y} \def \a@Z {Z} 

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

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

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

{\arab@codes % because of special characters

\gdef \sc@b@g #1#2{% start \ArabTeX scanner
  \def \next {\sc@word #1#2}%
\ifx #1>\let \next \relax \else
\ifx #1'\def \next {\sc@rquote #2}\else
\ifx #1`\def \next {\sc@lquote #2}\else
\ifcat \nxp #1a\else
\ifx #2>\global\a@tokens ={#1}\def \next {\sc@word #2}% x>
\fi\fi\fi\fi\fi \next }

\gdef \sc@w@rd #1#2{% transform input into internal notation
\ifx #1>\let \next \relax \else
     \def \next {\sc@word #2}%
\ifx #1a\def \next {\sc@aa #2}\else
\ifcat \nxp #1\relax \def \next {\sc@cs #1#2}\else
\ifcat \nxp #1a\edef \sc@char {\csname sc@#1\endcsname }%
	\ifx \sc@char \relax \def \sc@char {#1}%
	\fi \sc@put
\else
   \ifx #1.\def \next {\sc@dot #2}\else
   \ifx #1^\def \next {\sc@up #2}\else
   \ifx #1_\def \next {\sc@down #2}\else
   \ifx #1-\def \next {\sc@minus #2}\else
   \ifx #1'\def \next {\sc@hamza #2}\else
   \ifx #1`\def \next {\sc@ain #2}\else
   \ifx #1"\def \next {\sc@quote #2}\else
   \ifx #1,\def \next {\sc@comma #2}\else
   \ifx #1=\def \sc@char {#1}\def \next {\sc@eq #2}\else
   \ifx #1:\def \sc@char {#1}\def \next {\sc@eq #2}\else
   \ifx #1~\def \next {\sc@tie #2}\else
   \ifx #1\@ldtie \def \next {\sc@tie #2}\else
       \def \sc@char {#1}\sc@put
   \fi\fi\fi\fi\fi\fi
   \fi\fi\fi\fi\fi\fi
\fi\fi\fi\fi \next }

} % \arab@codes

\def \sc@cs #1#2>>{% control sequence within a word
\global\sc@next = {#1}\global\sc@rest = {#1#2}%
\global\def \a@rest {#1#2}%
\let \test@token \test@rest
\errhelp {A control sequence must be preceded by blank space or newline.}%
\errmessage {Unexpected control sequence \the\sc@next;
may lead to more errors in \the\sc@rest.}}

\def \sc@put {% deposit a symbol
  \edef \sc@toks {\the\a@tokens \sc@char }%
  \global \a@tokens =\xpa {\sc@toks }}

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

\def \sc@quote #1{% verbatim
\ifx #1'\def \sc@char {Q}\let \next \sc@word
  \global \a@tokens =\xpa {\the\a@tokens "QQ}%
\else \def \sc@char {"}\def \next {\sc@word #1}%
  \global \a@tokens =\xpa {\the\a@tokens "}%
\fi \next }

\def \sc@hamza #1{% context \sc@char ' #1
\ifh@mza \def \next {\sc@word #1}%
\ifx #1'\let \next \sc@hamza@ii \else
\ifcat -\sc@char \def \sc@char {Q}%
  \global \a@tokens =\xpa {\the\a@tokens QQ}%
\else \edef \sc@toks {\the\a@tokens Q\sc@char }\def \sc@char {Q}%
  \global \a@tokens =\xpa {\sc@toks }%
\fi\fi \else
  \def \sc@char {Q}\def \next {\sc@word #1}\sc@put
\fi \next }

\def \sc@hamza@ii #1#2{% context \sc@char '' #1 #2
\ifcat \nxp #1a%
  \edef \sc@toks {\the\a@tokens Q\sc@char QQ}%
  \global \a@tokens =\xpa {\sc@toks }\def \sc@char {Q}%
\else
\ifcat \nxp #2a%
  \edef \sc@toks {\the\a@tokens Q\sc@char QQ}%
  \global \a@tokens =\xpa {\sc@toks }\def \sc@char {Q}%
\else
  \global \a@tokens =\xpa {\the\a@tokens '}\def \sc@char {'}%
\fi\fi \sc@word #1#2}

\def \sc@ain {% ` = `ain
\global \a@tokens =\xpa {\the\a@tokens P}%
\def \sc@char {P}\sc@word }

\def \sc@rquote #1#2{% context '#1#2 , initial
\ifh@mza \def \sc@char {Q}\global \a@tokens ={QQ}% '>
\ifx #1>\def \next {\sc@word #1#2}\else
\ifx #1'\ifx #2>\global \a@tokens ={'}\def \next {\sc@word #2}% ''>
        \else \def \next {\sc@word '#2}% ''x
        \fi
   \else \def \next {\sc@word #1#2}% 'xy
\fi\fi \else 
  \def \sc@char {Q}%\global \a@tokens ={Q}% '>
  \def \next {\sc@word #1#2}\sc@put
\fi \next }

\def \sc@lquote #1#2{% context `#1#2 at the beginning of a word
\ifx #1`\def \sc@char {`}\global \a@tokens ={`}%
         \def \next {\sc@word #2}% ``x
\else \def \sc@char {P}\global \a@tokens ={P}% `>
   \def \next {\sc@word #1#2}% `xy
\fi \next }

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

\def \sc@aa #1{% aa = A
   \def \next {\sc@word }\def \sc@char {a}%
\ifx #1a\def \sc@char {A}\else \def \next {\sc@word #1}%
\fi \sc@put \next }

\def \sc@comma #1{% after ,
   \def \next {\sc@word }\def \sc@char {@}%
\ifx #1>\def \next {\sc@word #1}\def \sc@char {,}\else
\ifx #1a\def \sc@char {a\nxp \a@H }\else
\ifx #1A\def \sc@char {\nxp \a@a \nxp \a@H }\else
\ifx #1c\def \sc@char {\ift@rk J\else \nxp \a@c \fi }\else
\ifx #1d\def \sc@char {\ifpasht@ \nxp \a@e \else \nxp \a@d \fi }\else
\ifx #1e\def \sc@char {e\nxp \a@H }\else
\ifx #1g\def \sc@char {\nxp \a@L }\else
\ifx #1h\def \sc@char {\nxp \a@h }\else
\ifx #1n\def \sc@char {\nxp \a@M }\else
\ifx #1r\def \sc@char {\ifpasht@ \nxp \a@q \else \nxp \a@r \fi }\else
\ifx #1s\def \sc@char {\ift@rk x\else \nxp \a@s \fi }\else
\ifx #1t\def \sc@char {\ifpasht@ \nxp \a@v \else \nxp \a@t \fi }\else
\ifx #1z\def \sc@char {\ift@rk D\else \nxp \a@z \fi }\else
   \def \next {\sc@word #1}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \sc@put \next }

\def \sc@tie #1{% after ~
   \def \next {\sc@word }\def \sc@char {^}%
\ifx #1l\def \sc@char {\nxp \a@l }\else
\ifx #1g\def \sc@char {\nxp \a@m }\else
\ifx #1n\def \sc@char {K}\else
   \def \next {\sc@word #1}%
\fi\fi\fi \sc@put \next }

\def \sc@dot #1{% after .
   \def \next {\sc@word }\def \sc@char {.}%
\ifx #1>\def \next {\sc@word #1}\def \sc@char {.}\else
\ifx #1a\def \sc@char {\nxp \a@A }\else
\ifx #1b\def \sc@char {\nxp \a@b }\else
\ifx #1d\def \sc@char {D}\else
\ifx #1e\def \sc@char {\nxp \a@I }\else
\ifx #1f\def \sc@char {\nxp \a@f }\else
\ifx #1g\def \sc@char {R}\else
\ifx #1h\def \sc@char {H}\else
\ifx #1i\def \sc@char {\nxp \a@j }\else
\ifx #1k\def \sc@char {\ift@rk q\else \nxp \a@k \fi }\else
\ifx #1l\def \sc@char {\nxp \a@l }\else
\ifx #1n\def \sc@char {\ifpasht@ \nxp \a@N \else \nxp \a@n \fi }\else
\ifx #1o\def \sc@char {\nxp \a@O }\else
\ifx #1r\def \sc@char {\nxp \a@R }\else
\ifx #1s\def \sc@char {S}\else
\ifx #1t\def \sc@char {V}\else
\ifx #1z\def \sc@char {Z}\else
   \def \next {\sc@word #1}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \sc@put \next }

\def \sc@up #1{% after ^
   \def \next {\sc@word }\def \sc@char {@}%
\ifx #1c\def \sc@char {J}\else
\ifx #1d\def \sc@char {\nxp \a@D }\else
\ifx #1e\def \sc@char {\nxp \a@E }\else
\ifx #1g\def \sc@char {\ifk@rd R\else G\fi }\else
\ifx #1s\def \sc@char {x}\else
\ifx #1u\def \sc@char {U}\else
\ifx #1z\def \sc@char {j}\else
   \def \next {\sc@word #1}%
\fi\fi\fi\fi\fi\fi\fi \sc@put \next }

\def \sc@minus #1{% after -
   \def \next {\sc@word }\def \sc@char {-}%
\ifx #1-\def \sc@char {B}\else \def \next {\sc@word #1}%
\fi \sc@put \next }

\def \sc@down #1{% after _
   \def \next {\sc@word }\def \sc@char {@}%
\ifx #1a\def \sc@char {\nxp \a@a }\else
\ifx #1A\def \sc@char {Y}\else
\ifx #1d\def \sc@char {F}\else
\ifx #1e\def \sc@char {\nxp \a@E }\else
\ifx #1h\def \sc@char {X}\else
\ifx #1i\def \sc@char {\nxp \a@i }\else
\ifx #1k\def \sc@char {R}\else
\ifx #1o\def \sc@char {\nxp \a@o }\else
\ifx #1s\def \sc@char {C}\else
\ifx #1t\def \sc@char {C}\else
\ifx #1u\def \sc@char {\nxp \a@u }\else
\ifx #1U\def \sc@char {\nxp \a@o }\else
\ifx #1z\def \sc@char {F}\else
   \def \next {\sc@word #1}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \sc@put \next }

\def \sc@eq #1{% after = or :
\ifx #1>\def \next {\sc@word #1}\else
   \def \next {\sc@word }\def \sc@char {@}%
\ifx #1a\def \sc@char {\nxp \a@A}\else
\ifx #1e\def \sc@char {\nxp \a@I}\else
\ifx #1g\def \sc@char {\nxp \a@J}\else
\ifx #1i\def \sc@char {\nxp \a@I}\else
\ifx #1I\def \sc@char {\nxp \a@j}\else
\ifx #1o\def \sc@char {\nxp \a@O}\else
\ifx #1O\def \sc@char {\nxp \a@P}\else
\ifx #1u\def \sc@char {\nxp \a@U}\else
\ifx #1U\def \sc@char {\nxp \a@w}\else
   \def \next {\sc@word #1}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \sc@put \next }

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

% preparations for additional scanners

\def \a@arabtex {arabtex}	\def \a@standard {standard} 

\def \setcode #1{\def \next {#1}% switch input coding
\let \vocalize \v@calize    \let \fullvocalize \fullv@calize  
\let \sc@word \sc@w@rd      \let \sc@beg \sc@b@g
\let \a@scan \a@@scan       \seta@codes
\ifx \next \a@arabtex
      \message {input coding set to ArabTeX conventions.}\else 
\ifx \next \a@standard
      \message {input coding set to ArabTeX conventions.}\else 
  \message {unknown input coding `\next'; ArabTeX coding is assumed.}%
\fi\fi }

\def \endsetcode {\message {input coding reset.}}

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

\message {scanner for code `arabtex' installed.}
\setcode {standard}	% default

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


