%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % aparse.sty % Parser 19.03.96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % (c) Klaus Lagally % Institut fuer Informatik % Universitaet Stuttgart %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \a@ident {aparse.sty} {3.04 get syllables } {19.03.96} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % dynamic definitions for Arabic {\catcode `\ =9 \catcode `\^^M=9 \catcode `\^^I=9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \gdef \def@arabvoc {% define vowel parsing routines for Arabic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%% short vowels \def \sv@a {% short a \ifk@rd \put@syl \put@con \a@H \put@syl \let \next \syl@endvoc \else \let \next \sv@aInt \fi \next } \def \sv@e {% short e \ifk@rd \let \next \sv@a \else \ift@rk \let \next \sv@a \else \let \next \sv@eInt \fi\fi \next } \def \sv@i {\sv@iInt }% short i \def \sv@o {% ammad in Pashto, otherwise short u \ifk@rd \put@syl \put@con \a@W \put@syl \let \next \syl@con \else \ifpasht@ \add@ammad \else \ifiz@fet \else \add@damma \fi \fi \put@syl \let \next \syl@endvoc \fi \next } \def \sv@u {% short u \ifk@rd \let \next \sv@ukurd \else \let \next \sv@uInt \fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% long vowels, plene \def \sv@A {% long a \ifk@rd \else \add@fatha \fi \put@syl \put@con a\sv@Aa } \def \sv@E {% long e \ift@rk \let \next \sv@I \else \let \next \sv@EInt \fi \next } \def \sv@I {\sv@IInt }% long i \def \sv@O {% long o \ifpasht@ \add@ammad \else \ifiz@fet \else \add@damma \fi\fi \put@syl \put@con w\put@syl \syl@con } \def \sv@U {% long u \ifk@rd \put@syl \put@con w\put@syl \put@con w\put@syl \let \next \syl@con \else \let \next \sv@UInt \fi \next } \def \sv@Y {% alif maqsura \add@fatha \put@syl \put@con Y\put@syl \syl@con } %%%%%%%%%%%%%%%%%%%%%%%%%% long vowels, defective writing \sv@def \a@a {\sv@aspec }% Qur'an alif \sv@def \a@i {% defective long i \add@kasraspec \put@syl \syl@con } \sv@def \a@j {\sv@I }% Turkish "I \sv@def \a@o {\sv@U }% special short u \sv@def \a@u {% defective long u \add@ammad \put@syl \syl@con } %%%%%%%%%%%%%%%%%%%%%%%%%% special vowels \sv@def \a@A {\sv@a }% Turkish "a \sv@def \a@E {% kurdish ^e \put@syl \put@con \a@E \put@syl \syl@con } \sv@def \a@I {\sv@i }% Turkish "i \sv@def \a@O {% Kurdish and Turkish "o \ifk@rd \put@syl \put@con w\put@syl \put@con \a@E\put@syl \let \next \syl@con \else \let \next \sv@o \fi \next } \sv@def \a@P {\sv@U }% Turkish "O \sv@def \a@U {\sv@u }% Turkish "u \sv@def \a@w {\sv@U }% Turkish "U %%%%%%%%%%%%%%%%%%%%%%%%%% hamza handling \def \syl@hamzabeg ##1##2{% initial hamza \ifk@rd \ifx ##2i\def \next {\syl@con }\put@con a% alif \add@hamza \add@hamzalow \put@syl \else \put@con Y\add@hamza \def \next {\syl@voctest ##2}% \fi \else \ifh@mza \def \next {\syl@beghamza ##1##2}\else \def \next {\syl@hamzaverb ##1##2}% verbatim mode \fi\fi \next } \def \syl@hamza ##1{% non-initial hamza, context #1' \ifx ##1-\def \next {\syl@hamzabeg ##1}\else \ifh@mza \def \next {\syl@arabhamza ##1}\else \def \next {\syl@hamzaverb ##1}% verbatim mode \fi\fi \next } \def \syl@test@voc ##1{% vowel or sukun ? \xpa \ifx \csname sv@\string ##1\endcsname \relax % non-vowel follows \ifurd@ \ifx ##1h\else \add@sukun \fi \else \add@sukun \fi \put@syl \def \next {\syl@con ##1}% \else \def \next {\syl@voc ##1}% test for vowel \fi \next } \def \add@wasla {\if@suk \last@voc \c@wasla \fi } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% }% end of dynamic definitions for Arabic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % static definitions for Arabic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def \sv@def #1#2{% define \tr@#1 as {#2} \xpa \def \csname sv@\string #1\endcsname {#2}} \newtoks \a@revwd \newtoks \last@con \newcount \last@mod \newcount \last@voc \newif \ifsyl@wdend \newif \ifm@dda \def \a@parse #1>{% parse token sequence into syllables \iftest@parse \iftest@scan \else \a@verb (#1)>\fi \tracingmacros = 1 \fi \last@con ={.}\last@mod = 0 \last@voc = 0 \global\@highfalse \gdef \sv@wd {}\global \a@revwd ={}\syl@beg #1<<<>% \iftest@parse \tracingmacros = 0 % \xpa \a@verb \xpa (\the\a@revwd )>\fi } \def \test@wdend #1#2#3{% test for end of word: k #1 #2 #3 \syl@wdendfalse \ifx #1<\syl@wdendtrue \else \ifx #1"\test@wdend #2#3t\else \ifcat -\nxp #1\syl@wdendtrue \else \ifx #1N\syl@wdendtrue \else \test@in@list #1aeiou>% \ifin@list \test@wdend #2#3t% \fi \fi\fi\fi\fi } \def \syl@end #1>{% kill the rest \relax } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% start of word \def \syl@beg #1#2{% start new word \global\@highfalse \ifx #1<\let \next \syl@end \else % not done \ifx #1Q\def \next {\syl@hamzabeg #2}\else % no Hamza \ifx #1^\def \next {\syl@hamzabeg A#2}\else % no Hamza \ifx #1B\def \next {\syl@tatwilbeg #2}\else % no Tatwil \ifx #1"\def \next {\syl@quote@beg #2}\else % no quoting \ifx #1|\def \next {\syl@bar #2}\else % no | \ifx #1Y\def \next {\syl@con #1#2}\else % no Y \ifcat a#1\xpa % letter after expansion ! \ifx \csname sv@\string #1\endcsname \relax % consonant \def \next {\syl@con #1#2}% start syllable \else \def \next {\syl@wasla #1#2}% vowel: put wasla \fi \else \def \next {\syl@spec #1#2}% special character \fi\fi\fi\fi\fi\fi\fi\fi \next } \def \syl@bar #1{% check for || as "| \ifx #1|\def \next {\syl@quote@beg #1}\else % \ifx #1B\def \next {\syl@con |B}\else \put@con W\v@cfalse \@sukfalse \def \next {\syl@voctest #1}% \fi\fi \next } \def \syl@wasla #1{% start word with vowel without hamza \put@con a% deposit alif \ifx #1A\ifiz@fet \add@madda \def \next {\syl@con }\put@syl \else \def \next {\syl@voctest }% \fi \else \def \next {\syl@voc #1}% prepare for vowel % no wasla in Urdu \ifurd@ \else \ifh@mza \test@in@list #1aiueo>% short vowel ? \ifin@list \if@wasla \add@wasla \put@syl \def \next {\syl@con }% next syllable \fi\fi\fi \fi\fi \next } \def \syl@tatwilbeg #1{% start word with tatwIl: -- #1 \put@con B% \xpa \ifx \csname sv@\string #1\endcsname \relax % consonant follows \put@syl \def \next {\syl@con #1}% join \else \def \next {\syl@voc #1}% harakat on tatwil \fi \next } \def \syl@spec #1#2{% deposit special character \ifx #1<\let \next \syl@end \else \put@spec #1% deposit character \ifx #1-\def \next {\syl@con #2}\else % create joining form \ifx #2<\let \next \syl@end \else % isolated character \def \next {\syl@beg #2}% % start new word \fi\fi \fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% start of syllable \def \syl@con #1#2{% start a new syllable \ifx #1<\let \next \syl@end \else % not done \ifx #1Q\def \next {\syl@hamza #2}\else % no Hamza \ifx #1B\put@con B\put@syl \def \next {\syl@con #2}\else \ifx #1W\put@con w\def \next {\syl@Wspec #2}\else % no ending wA or w- \ifx #1"\def \next {\syl@quote@con #2}\else \ifx #1|% test for || \ifx #2|\def \next {\syl@quote@con #2}\else \ifx #2B\def \next {\syl@tatwil }\else \put@con |\@sukfalse \def \next {\syl@voctest #2}% \fi \fi \else % no | \ifcat a#1% letter after expansion ! \ifx #2-\def \next {\syl@assim #1}\else % assimilate? \put@con #1% deposit consonant \ifx #1#2\add@shadda \def \next {\syl@shadd@voctest #2}\else \def \next {\syl@voctest #2}% \ifiz@fet\ifx #1X\ifx #2w\put@syl \def \next {\syl@con #2}% waw-e-ma`dul \fi\fi \fi\fi\fi \else \def \next {\syl@spec #1#2}% special character \ifx #1-\ifx #2<% hyphen at the end: joining form \else \def \next {\syl@beg #2}% ignore hyphen, tie \fi \fi \fi\fi\fi\fi\fi\fi\fi \next } \def \syl@tatwil #1{% test for 2 tatwils \put@con B% \ifx #1B\add@shadda \def \next {\syl@voctest }\else \def \next {\syl@voctest #1}% \fi \next } \def\syl@shadd@voctest #1#2{% hyphen after shadda ? context #1#1 #2 \ifx #2-\def \next {\syl@hyphen #1}\else \def \next {\syl@voctest#2}% \fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% hyphen \def \syl@hyphen #1#2#3{% hyphen after consonant, #1 - #2 #3 \ifx #2<% hyphen at the end ? k - || \add@sukun \put@syl \def \next {\syl@con -#2#3}\else \ifx #3<% connecting vowel ? k - x || \def \next {\syl@contie #1#2#3}\else \ifcat -#3% connecting vowel ? k - x - \def \next {\syl@contie #1#2#3}\else \ifx #1\a@H% silent hah ? H - x \put@syl \put@spec W\def \next {\syl@beg #2#3}\else \ifiz@fet \def \next {\syl@voctest #2#3}\else % Persian suffix \ifx #1l% article ? l - #2 #3 \def \next {\syl@art #2#3}\else \add@sukun \put@syl \def \next {\syl@con #2#3}% ignore hyphen \fi\fi\fi\fi\fi\fi \next } \def \syl@art #1#2#3{% article, (a)l-#1#2#3 \def \next {\syl@beg #1#2#3}% ought to test for sun letter ! \ifx #1#2% no sukun before double (sun) letter \ifx #2#3\def \next {\syl@beg #2#3}% special case l-ll \fi \else \add@sukun % moon letter \fi \put@syl \next } \def \syl@assim #1#2{% test for assimilation #1 - #2 \ifh@mza \ifx #1#2% ought to test for sun letter ! \put@con l\def\next {\syl@art #1#2}% substitute l - #1 #2 \else \put@con #1\def \next {\syl@hyphen #1#2}% #1 - #2 \fi \else \put@con #1\def \next {\syl@hyphen #1#2}% #1 - #2 \fi \next } \def \syl@contie #1#2#3{% connecting vowel, #1 - #2#3 \def \next {\syl@voctest #2#3}% \ifiz@fet \sv@test@izafet #1#2#3% \fi \next } \def \syl@voctie #1#2#3{% hyphen after vowel, #1 - #2 #3 \def \next {\syl@con -#2#3}% \ifiz@fet \ifx #3<\sv@test@izafet #1#2#3\else \ifcat -#3\sv@test@izafet #1#2#3\else \ifx #1a\put@syl \put@con \a@H % supply final silent H \def \next {\syl@hyphen \a@H #2#3}\else \ifx #1e\put@syl \put@con \a@H % supply final silent H \def \next {\syl@hyphen \a@H #2#3}\else \put@syl \fi\fi\fi\fi \else \put@syl \fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% special cases for Persian \def \syl@hahtie #1#2#3{% connecting vowel, H - #2#3 \def \next {\syl@hah #2#3}% \ifx #2I\else \ifx #2E\else \sv@test@izafet #1#2#3% \fi\fi \next } \def \syl@hah{% H at the end, ha-ye hawwaz-e ma.hfi \put@syl \put@spec W\syl@beg } \def \sv@izafet #1#2{% #1 - i/e/_i \ifx #1\a@H \add@hamza \else \ifx #1A\put@syl \put@con y\else \ifx #1U\put@syl \put@con y\else \ifx #1I\add@hamza \else \fi\fi\fi\fi \ifx #2\a@i \add@kasraspec \else \add@kasra % long izafet ? \fi \put@syl \syl@con } \def \sv@wahdat #1#2{% #1 - I/E \ifx #1\a@H \put@syl \put@spec W\put@con a\else \ifx #1I\put@syl \put@spec W\put@con a\else \ifx #1A\put@syl \put@con Y\add@hamza \else \ifx #1U\put@syl \put@con Y\add@hamza \else \fi\fi\fi\fi \ifx #2I\add@kasra \fi \put@syl \put@con y\put@syl \syl@con } \def \sv@test@izafet #1#2#3{% special cases for -e, -i, -_i, -I, -E \ifx #2i\def \next {\sv@izafet #1#2#3}\else \ifx #2e\def \next {\sv@izafet #1#2#3}\else \ifx #2\a@i \def \next {\sv@izafet #1#2#3}\else \ifx #2I\def \next {\sv@wahdat #1#2#3}\else \ifx #2E\def \next {\sv@wahdat #1#2#3}\else \fi\fi\fi\fi\fi } \def \syl@endvoc #1#2{% test for H \def \next {\syl@con #1#2}% \ifiz@fet \ifx #1\a@H \put@con \a@H \ifx #2-\def \next {\syl@hahtie #1}\else \ifx #2Q\add@hamza \add@kasraspec \put@syl \let \next \syl@end \else \put@syl \ifx #2<\let \next \syl@end \else \ifx #2"\let \next \syl@quote@beg \else \ifx #2|\let \next \syl@bar \else \ifcat ,#2\let \next \syl@end \else \def \next {\syl@beg #2}% start a new word \fi\fi\fi\fi\fi\fi \fi\fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% quoting \def \syl@quote@beg #1#2{% start word with quote: " #1 #2 \ifx #1'\put@con Q\def \next {\syl@voctest #2}\else \ifx #1Q\put@con Q\def \next {\syl@voctest }\else \ifx #1|\put@spec W\def \next {\syl@beg #2}\else % start new word \put@con a% alif implied \xpa \ifx \csname sv@\string #1\endcsname \relax % consonant follows \togglev@c \add@wasla \put@syl \def \next {\syl@con #1#2}% wasla \else \if@wasla \v@ctrue \else \add@wasla \togglev@c \fi \def \next {\syl@voc #1#2}% explicit vowel \fi \fi\fi\fi \next } \def \syl@quote@con #1#2{% start syllable with quote: " #1 #2 \ifx #1'\put@con Q\def \next {\syl@voctest #2}\else \ifx #1Q\put@con Q\def \next {\syl@voctest }\else \ifx #1|\put@spec W\def \next {\syl@con #2}\else \def \next {\syl@con #2}\togglev@c \fi\fi\fi \next } \def \syl@quote@voc #1#2{% continue syllable with quote: " #1 #2 \ifx #1'\add@hamza \def \next {\syl@voctest #2}\else \ifx #1Q\add@hamza \def \next {\syl@voctest }\else \ifx #1B\togglev@c \add@sukun \put@syl \def \next {\syl@con #1#2}\else \ifx #1"\togglev@c \add@sukun \put@syl \def \next {\syl@beg #2}\else \ifx #1|\put@syl \put@spec W% \xpa \ifx \csname sv@\string #2\endcsname \relax % consonant \def \next {\syl@con #2}% consonant \else \def \next {\syl@wasla #2}% vowel: wasla \fi \else \def \next {\syl@voctest #1#2}\togglev@c % vowel: sukun \fi\fi\fi\fi\fi \next } \def \togglev@c {% toggle diacritic \ifv@c \v@cfalse \else \v@ctrue \fi % toggle vowel indicator \if@suk \@sukfalse \else \@suktrue \fi % toggle sukun, wasla } %%%%%%%%%%%%%%%%%%%%%%%%%% vowel or end of syllable \def \syl@voctest #1#2{% continue open syllable \ifx #1"\def \next {\syl@quote@voc #2}\else % no quoting \ifx #1^\m@ddatrue \def \next {\syl@voctest #2}\else % no madda \ifx #1|% test for || \ifx #2|\def \next {\syl@quote@voc #2}\else \put@syl \put@con |\def \next {\syl@voctest #2}% \fi \else % no | \ifx #1B\put@syl \put@con B\def \next {\syl@voctest #2}\else % no Tatwil \def \next {\syl@test@voc #1#2}% \fi\fi\fi\fi \next } \def \syl@voc #1{% test for vowel \ifx #1<\def \next {\syl@end }\else % this cannot happen! or can it? \ifx #1-\def \next {\syl@voc }\else % ignore hyphen here \def \next {\csname sv@\string #1\endcsname}% switch on vowel \fi\fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % auxiliary vowel routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%% short vowels \def \sv@aInt #1{% short a \def \next {\syl@endvoc #1}% test for H \ifx #1N\def \next {\syl@Nspec }\else % tanwin alif \add@fatha \put@syl \ifx #1e\ifurd@ \put@con E\else \put@con Y\add@hamza \fi \put@syl \def \next {\syl@con }\else \ifx #1o\put@con w\put@syl \def \next {\syl@con }\else \def \next {\syl@endvoc #1}% test for H \fi\fi\fi \next } \def \sv@eInt #1{% zwarakay in Pashto, otherwise short a \def \next {\syl@endvoc #1}% test for H \ifpasht@ \add@zwarakay \put@syl \ifx #1e\def \next {\syl@con }\put@con Y\add@hamza \put@syl \fi \else \add@kasra \put@syl \ifiz@fet \test@in@list #1aeiuoAEIUO>% provisions for preposition be- \ifin@list \def \next {\syl@beg #1}% \fi\fi \fi \next } \def \sv@iInt #1{% short i \ifx #1N\add@kasratan \put@syl \def \next {\syl@ignore }% tanwin yah \else \add@kasra \ifx #1-\def \next {\syl@voctie i}\else \put@syl \def \next {\syl@con #1}% next syllable \fi\fi \next } \def \sv@ukurd #1{% short u, for Kurdish \ifx #1Q\put@syl \def \next {\syl@hamza }\else \def \next {\syl@con #1}\put@syl \put@con w\put@syl \fi \next } \def \sv@uInt #1{% short u, otherwise \ifx #1N\add@dammatan \put@syl \def \next {\syl@ignore }% tanwin waw \else \add@damma \put@syl \def \next {\syl@con #1}% next syllable \fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% long vowels \def \sv@Aa #1{% long a + a ? \def \next {\syl@con #1}% next syllable \ifm@dda \add@madda \m@ddafalse \fi \ifx #1-\def \next {\syl@voctie A}\else \ifx #1a\def \next {\sv@AaN }\else \ifx #1"\def \next {\sv@Aa }\v@ctrue \@suktrue \else \put@syl \fi\fi\fi \next } \def \sv@AaN #1{% long a + aN ? \def \next {\syl@con a#1}% next syllable \ifx #1N\def \next {\syl@aN}\else \put@syl \fi \next } \def \sv@aspec #1{% Qur'an alif \add@fathaspec \put@syl \def \next {\syl@con }% \ifx #1U\put@con w\put@syl \else \ifx #1Y\put@con Y\put@syl \else \ifx #1I\put@con y\put@syl \else \def \next {\syl@con #1}% \fi\fi\fi \next } \def \sv@EInt #1{% long E \def \next {\syl@con #1}% next syllable \ifpasht@ \add@zwarakay \else \ifiz@fet \else \add@kasra \fi\fi \put@syl \ifx #1e\put@con L\put@syl \def \next {\syl@con }% ey \else \ifpasht@ \put@con E\else \ifurd@ \put@con E\else \put@con y% \fi\fi \put@syl \fi \next } \def \sv@IInt #1{% long i \def \next {\syl@con #1}% next syllable \add@kasra \put@syl \put@con y% -I becomes -iy, -Iy becomes -iyy \ifm@dda \add@madda \m@ddafalse \fi \ifx #1y\add@shadda \def \next {\syl@voctest }\else \ifx #1-\def \next {\syl@voctie I}\else \put@syl \fi\fi \next } \def \sv@UInt #1{% long u \def \next {\syl@con }% next syllable \add@damma \put@syl \put@con w% % -U becomes -uw \ifm@dda \add@madda \m@ddafalse \fi \ifx #1w\add@shadda \let \next \syl@voctest \else % -Uw becomes -uww \ifx #1a\put@syl \put@con a\put@syl \else % not -Ua \ifx #1A\put@syl \put@con a\put@syl \else % not -UA \ifx #1-\def \next {\syl@voctie U}\else % not -U- \ifiz@fet \ifx #1Q\let \next \sv@UQ \else % not -U' \put@syl \def \next {\syl@con #1}% next syllable \fi \else \put@syl \def \next {\syl@con #1}% next syllable \fi\fi\fi\fi\fi \next} \def \sv@UQ #1#2#3#4{% UQU#2#3#4, U' in Farsi \test@wdend #2#3#4% final hamza on waw ? \ifsyl@wdend \add@hamza \ifx #2-\def \next {\syl@hyphen Q#3#4}% ezafe ? \else \def \next {\syl@voctest #2#3#4}% vowel ? \fi \else \put@syl \def \next {\syl@hamza U#2#3#4}% next syllable \fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% Nunation \def \syl@Nspec {% tanwin fatha \ifh@mza \ifaN@alif \let \next \syl@aN@alif \else \let \next \syl@aN \fi \else \add@fathatan \put@syl \let \next \syl@ignore \fi \next } \def \syl@aN #1{% tanwin fatha on actual character, alif required ? \add@fathatan \put@syl \def \next {\syl@ignore #1}% \ifcat a#1\def \next {\syl@ignore #1}\else \if \the\last@con T\else % tah marbuta: no alif \if \the\last@con a\else % hamza on alif: no alif \if \the\last@con B\else % tatwil: no alif \put@con a\put@syl % deposit alif \fi\fi\fi\fi \next } \def \syl@aN@alif #1{% tanwin fatha at the end, alif required ? \def \next {\syl@ignore #1}% \ifcat a#1\ifv@c \put@syl \v@ctrue \else \put@syl \fi \put@con #1% deposit character \def \next {\syl@ignore }\else \if \the\last@con T\else % tah marbuta: no alif \if \the\last@con a\else % hamza on alif: no alif \if \the\last@con B\else % tatwil: no alif \ifv@c \put@syl \v@ctrue \else \put@syl \fi \put@con a% deposit alif \fi\fi\fi\fi \add@fathatan \put@syl \next } \def \syl@Wspec #1{% final w with silent alif ? \def \next {\syl@con }% \ifx #1-\def \next {\syl@Wspec }% ignore hyphen \else \ifx #1u\add@damma % ending w-u \else \add@sukun % ending w \fi \put@syl \put@con a\put@syl \fi \next } \def \syl@ignore #1{% kill the rest after Tanwin except U, A, a, and Y \let \next \syl@ignore \ifx #1-\else \ifx #1U\put@con w\put@syl \else \ifx #1A\put@con a\put@syl \else \ifx #1a\put@con a\put@syl \else % allow aNa \ifx #1Y\put@con Y\put@syl \else \ifcat a#1\else % tie \def \next {\syl@con #1}% \fi\fi\fi\fi\fi\fi \next } %%%%%%%%%%%%%%%%%%%%%%%%%% Hamza \newif \if@ay \def \syl@hamzaverb #1{% verbatim hamza, #1 = carrier \put@con #1\def \next {\syl@voctest }% \ifx #1|\put@con Q\else \ifx #1A\put@con a\add@madda \@sukfalse \else \add@hamza \ifx #1y\put@con Y\else \ifx #1u\put@con w\else \ifx #1i\put@con a\add@hamzalow \else \fi\fi\fi\fi\fi \next } \def \syl@beghamza #1#2{% start word with hamza, context '#2 \ifx #2"\def \next {\syl@beghamza #1}\togglev@c % toggle vowel \else \def \next {\syl@con }\put@con a% alif \ifx #2A\add@madda \else \add@hamza \test@in@list #2a\a@a\a@A>% \ifin@list \add@fatha \else \test@in@list #2i\a@i\a@I>% \ifin@list \add@kasra \add@hamzalow \else \test@in@list #2ou\a@O\a@U>% \ifin@list \add@damma \else \test@in@list #2eE\a@E>% \ifin@list \ifpasht@ \add@zwarakay \else \add@kasra \fi \else \test@in@list #2I\a@j>% \ifin@list \add@kasra \add@hamzalow \put@syl \put@con y\else \test@in@list #2OU\a@o\a@p\a@w>% \ifin@list \add@damma \put@syl \put@con w\else \add@sukun \def \next {\syl@con #2}% \fi\fi\fi\fi\fi\fi \fi \put@syl \fi \next } \def \syl@arabhamza #1#2#3#4{% non-initial hamza, context #1'#2#3#4 \def \next {\syl@hamzamid #1#2#3#3#4}% \ifx #2"\def \next {\syl@hamza #1#3#4}\togglev@c % toggle vowel \else \test@in@list #2AIUYEO>% arabic rules \ifin@list \else \test@wdend #2#3#4% test for hamza as last consonant \ifsyl@wdend \ifiz@fet \else \def \next {\syl@hamzaend #1#2#3#4}\fi \fi\fi\fi \next } \def \syl@hamzamid #1#2#3{% intermediate hamza, context #1'#2#3 \@ayfalse \def \next {\syl@voctest #2}% \ifx #2a\ifx #3y\@aytrue \fi\fi \ifx #1I\ifqur@n \put@con B\else \put@con Y\fi \add@hamza \else \test@in@list #1iy>% \ifin@list \put@con Y\add@hamza \else \test@in@list #2iIE>% \ifin@list \put@con Y\add@hamza \ifqur@n \add@hamzalow \fi \else \test@in@list #1uo>% \ifin@list \put@con w\add@hamza \else \test@in@list #2uo>% \ifin@list \put@con w\add@hamza \else \test@in@list #2UO>% \ifin@list \ifqur@n \put@Q #1\else \put@con w\add@hamza \fi \else \test@in@list #1AUO>% \ifin@list \put@Q #1\else \test@in@list #2A>% \ifin@list \put@con a\add@madda \put@syl \def \next {\syl@con }\else \ifx #1a\put@con a\add@hamza \else \ifx #2a\ifqur@n \put@Q #1\else \put@con a\add@hamza \fi \else \put@Q #1% deposit Hamza \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \ifx #2Q\def \next {\syl@doublehamza }% \fi \next } \def \syl@hamzaend #1#2#3{% final hamza, context #1'#2#3 \def \next {\syl@voctest #2#3}% \ifx #1i\put@con Y\add@hamza \else \ifx #1u\put@con w\add@hamza \else \ifx #1a\put@con a\add@hamza \else \put@con Q% deposit Hamza \ifx #3N\ifx #2a% aN \def \next {\syl@hamza@Nspec #1}% \fi\fi \fi\fi\fi \next } \def \syl@hamza@Nspec #1#2{% #1'aN , put alif ? \ifx #1A\else \ifx #1U\else \test@end@char #1% \ifend@char \else \ifqur@n \put@con B\else \put@con Y\fi \add@hamza \fi\fi\fi \add@fathatan \put@syl \ifx #1A\else \ifx #2Y\put@con Y% put alif maqsoura \else \put@con a% put alif \fi \put@syl \fi \syl@ignore #2} \def \syl@doublehamza #1{% double Hamza \add@shadda \syl@voctest } \def \put@Q #1{% deposit isolated hamza after #1 \ifqur@n \test@end@char #1% \ifend@char \put@con Q\else \put@con B\add@hamza \fi \else\put@con Q% \fi } %%%%%%%%%%%%%%%%%%%%%% deposit characters \def \put@con #1{% start syllable \last@con ={#1}} \def \put@syl {% deposit syllable \if@high \advance \last@mod \c@high \fi \xdef \rev@wd {\the\last@con \number \the\last@mod +\number \the\last@voc *}% \global \a@revwd =\xpa \xpa \xpa {\xpa \rev@wd \the\a@revwd }% \xdef \sv@wd {\sv@wd \rev@wd }% \xpa \check@high \the\last@con \global \@waslatrue \let \ifv@c \if@vocals \let \if@suk \if@sukun \last@mod = 0 \last@voc = 0 } \def \put@spec #1{% deposit special character \last@con={#1}\gdef \rev@wd {#10+0*}% \global \a@revwd =\xpa \xpa \xpa {\xpa \rev@wd \the\a@revwd }% \xdef \sv@wd {\sv@wd \rev@wd }% \global \@waslafalse \last@mod = 0 \last@voc = 0 } \def \check@high #1{% long form for tooth ? \test@in@list #1sxSD>% sxSD : force high \ifin@list \global\@hightrue \else \test@in@list #1YntCbyp>% YntCbyp : toggle \ifin@list \if@high \global\@highfalse \else \global\@hightrue \fi \else \global\@highfalse % otherwise : force low \fi\fi } %%%%%%%%%%%%%%%%%%%%%% deposit .harakAt \def \add@shadda {\advance \last@mod \c@shadda } \def \add@hamza {\advance \last@mod \c@hamza } \def \add@hamzalow {\advance \last@mod \c@hamzalow } \def \add@madda {\advance \last@mod \c@madda } \def \add@wasla {\if@suk \last@voc \c@wasla \fi } \def \add@sukun {\if@suk \last@voc \c@sukun \fi } \def \add@fatha {\ifv@c \last@voc \c@fatha \fi } \def \add@kasra {\ifv@c \last@voc \c@kasra \fi } \def \add@damma {\ifv@c \last@voc \c@damma \fi } \def \add@zwarakay {\ifv@c \last@voc \c@zwarakay \fi } \def \add@fathatan {\ifv@c \last@voc \c@fathatan \fi } \def \add@kasratan {\ifv@c \last@voc \c@kasratan \fi } \def \add@dammatan {\ifv@c \last@voc \c@dammatan \fi } \def \add@fathaspec {\ifv@c \last@voc \c@fathaspec \fi } \def \add@kasraspec {\ifv@c \last@voc \c@kasraspec \fi } \def \add@ammad {\ifv@c \last@voc \c@ammad \fi } %%%%%%%%%%%%%%%%%%%%% output codings \chardef \c@shadda = 1 \chardef \c@hamza = 2 \chardef \c@hamzalow = 3 \chardef \c@madda = 4 \chardef \c@high = 10 \chardef \c@sukun = 1 \chardef \c@fatha = 2 \chardef \c@kasra = 3 \chardef \c@damma = 4 \chardef \c@fathatan = 5 \chardef \c@kasratan = 6 \chardef \c@dammatan = 7 \chardef \c@zwarakay = 8 \chardef \c@wasla = 9 \chardef \c@fathaspec = 10 \chardef \c@kasraspec = 11 \chardef \c@ammad = 12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endinput %%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%