<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tengtex.sty  (TengTeX for LaTeX)
% 22 September 1994
% Version 1.00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ivan A Derzhanski
% Centre for Cognitive Science
% University of Edinburgh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \TengTeX {T\ama@tehta {\char19}{\~g}\TeX }


%%%%%%%%%%%%%%%%%%%%%%%%%%% fount selection %%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif \if@nofount

\def \@jcb{\jcb} \def \@mpu{\mpu}

\def \mere@tengwanda{%
  \loop
    \ifx \@tengwanda \undefined
      \message{Choose a tengwar fount (\string\jcb\space or \string\mpu): }%
      \read-1 to\@answer
      \ifx \@answer \@jcb \jcb \else \ifx \@answer \@mpu \mpu%
      \else \message{None of these Orkish jokes, please.^^J}\fi\fi
  \repeat}


%%%%%%%%%%%%% character definitions common to both founts %%%%%%%%%%%%%

\def\l@p#1#2{\setbox0=\hbox{#2}\ooalign{\box0\crcr\hidewidth#1\hidewidth}}%

\chardef \tanta@Oman="80

\chardef \@tinco=`t  \chardef \@TUle=`T   \chardef \@Ore=`R
\chardef \@ando=`d   \chardef \@anto=`D   \chardef \@nUmen=`n

\chardef \@parma=`p  \chardef \@formen=`f \chardef \@vala=`w
\chardef \@umbar=`b  \chardef \@ampa=`v   \chardef \@malta=`m

\chardef \@quesse=`k \chardef \@hwesta=`K \chardef \@Noldo=`Y
\chardef \@ungwe=`g  \chardef \@unque=`G  \chardef \@Nwalme=`N

\chardef \@lambe=`l  \chardef \@alda=`L   \chardef \@rOmen=`r
\chardef \@anga=`j   \chardef \@silme=`s  \chardef \@esse=`z

\chardef \@quessiEva="80 % Quenya:  _q_ expecting _u_
\chardef \@unquiEva="81  % Quenya: _nq_ expecting _u_

\chardef \@phormen="82   % Sindarin: _ph_

\chardef \i@iEva="83     % Beleriandic Sindarin: sentence-initial _i_


%%%%%%%%%%%%%%%%%%%%% Julian Bradfield's  tengwar %%%%%%%%%%%%%%%%%%%%%

\def \jcb{\globaldefs=1%
\font \jcb@tengwar=teng10\let \@tengwanda \jcb@tengwar
\hyphenchar\jcb@tengwar=-1 % hyphenation in tengwar suppressed
\emergencystretch=2em % but we can do some extra stretching
%
\chardef \a@tehta=`a
\chardef \e@tehta=`e \let \@E@tehta \tanta@Oman
\chardef \i@tehta=`i
\chardef \o@tehta=`o \let \@O@tehta \tanta@Oman
\chardef \u@tehta=`u \let \@U@tehta \tanta@Oman
%
\def \E@tehta {e\kern-.15eme}%
\def \O@tehta {o\kern-.25emo}%
\def \U@tehta {u\kern-.35emu}%
%
\chardef \sinta@kolindo=`@
\chardef \anda@kolindo=`*
%
\chardef \@calma=`c
\chardef \@Harma=`C  \chardef \@anna=`y
\chardef \@anca=`J   \chardef \@wilya=`W
%
\chardef \@arda=`\&amp;  \chardef \@hyarmen=`h
\chardef \@silme@nuquerna=`S \chardef \@esse@nuquerna=`Z
\chardef \@yanta=`I  \chardef \@Ure=`U
\chardef \@hwesta@sindarinwa=`H
\chardef \@halla=`|
%
\def \uOman@tehta ##1##2{% no following vowel
  \ifx ##2\@lambe {\l@p {\raise.5ex\hbox{^^E}}{##1}}\else {\l@p ^^E{##1}}\fi}%
%
\def \T@nun@tehta ##1{{\l@p ^^B{##1}}}% doubling a narrow tengwa
\let \D@nun@tehta \T@nun@tehta % doubling a wide tengwa
\def \L@nun@tehta ##1{##1\raise.75ex\hbox to 0pt{\hss^^B}}% doubling _l_
%
\def \y@nun@tehta ##1{{\l@p ^^Y{##1}}}% _y_ following something
\def \l@nun@tehta ##1{##1\raise.75ex\hbox to 0pt{\hss^^Y}}% _y_ following _l_
\def \r@nun@tehta ##1{\raise.2ex\hbox to 0pt{^^Y\hss}##1}%  _y_ following _r_
%
\def \s@nun@tehta ##1{##1\kern-0.3em^^T}%  _s_ following something
\def \x@nun@tehta ##1{##1\kern-0.05em^^T}% _s_ following _c_ or _l_
%
\chardef \y@tehta="22
%
\chardef \arka@ama@falma="0F % prenasalisation for a narrow tengwa
\chardef \landa@ama@falma="0F %  prenasalisation for a wide tengwa
\chardef \w@tehta="16
%
\chardef \a@tengwa=`A  \chardef \o@tengwa=`y  \chardef \y@tengwa=`S
%
\chardef \@andaith=`e
%
\globaldefs=0}


%%%%%%%%%%%%%%%%%%%%%%% Michael Urban's tengwar %%%%%%%%%%%%%%%%%%%%%%%

\def \mpu{\globaldefs=1%
\font \mpu@tengwar=tengwar\global \let \@tengwanda \mpu@tengwar
\hyphenchar\mpu@tengwar=-1 % hyphenation in tengwar suppressed
\emergencystretch=2em % but we can do some extra stretching
%
\chardef \a@tehta="5E
\chardef \e@tehta="13
\chardef \i@tehta="5F
\chardef \o@tehta="14
\chardef \u@tehta="15
\chardef \E@tehta="7D
\chardef \O@tehta="16
\chardef \U@tehta="17
%
\chardef \sinta@kolindo=`i
\chardef \anda@kolindo="10
%
\chardef \@calma=`C  \chardef \@Harma=`S  \chardef \@anna=`O
\chardef \@anca=`Z   \chardef \@wilya=`A
%
\chardef \@arda="12  \chardef \@hyarmen=`h
\chardef \@silme@nuquerna="03 \chardef \@esse@nuquerna="1A
\chardef \@yanta=`e  \chardef \@Ure=`u
\chardef \@hwesta@sindarinwa="0F
\chardef \@halla="11
%
\def \uOman@tehta ##1##2{\l@p ^^Y{##1}}% no following vowel
%
\def \T@nun@tehta ##1{\l@p ^^H{##1}}% doubling a narrow tengwa
\def \D@nun@tehta ##1{\l@p {\char9}{##1}}% doubling a wide tengwa
\def \L@nun@tehta ##1{##1\llap ^^H}% doubling lambe
%
\def \y@nun@tehta ##1{\l@p ^^X{##1}}% _y_ following something
\let \l@nun@tehta \y@nun@tehta
\def \r@nun@tehta ##1{##1\lower.2ex\hbox to1.5pt{\hss^^X}}% _y_ following _r_
%
\def \s@nun@tehta ##1{##1\kern-0.3em\char28}%  _s_ following something
\def \x@nun@tehta ##1{##1\kern-0.05em\char28}% _s_ following _c_ or _l_
%\def \s@nun@tehta ##1{##1\lower1.5ex\hbox to3pt{\hss^^U}}% _s_ after something
%\def \x@nun@tehta ##1{##1\lower1.5ex\hbox to3pt{\hss^^U}}% _s_ after _c_ or _l_
%
\chardef \y@tehta="7F
%
\chardef \arka@ama@falma="0A % prenasalisation for a narrow tengwa
\chardef \landa@ama@falma="0B % prenasalisation for a wide tengwa
\chardef \w@tehta="1E
%\def\w@tehta##1{##1\raise .9ex\hbox to 0pt{\hss\char"2D}}
%
\chardef \a@tengwa=`a  \chardef \o@tengwa=`o  \chardef \y@tengwa=`y
%
\chardef \@andaith="13
%
\globaldefs=0}


%%%%%%%%%%%%%%%% macro definitions common to all modes %%%%%%%%%%%%%%%%

\long \def \kara@Ukerta #1{%
    \ifcase \nato@nostale \or \quetto@metta \or \m@m \fi
    \ifx \@sptoken \hilde@kerta \space \fi
    #1\nato@nostale=0}

\newcount \nato@nostale % class of input token
                        % 0: waiting, 1: word, 2: number

\long \def \tUva@kerta #1{%
  \ifx #1\end\relax
    \ifcase \nato@nostale \or \quetto@metta \or \m@m \fi
    \let \next \end
  \else \ifcat z\noexpand#1\relax
    \ifnum 1=\nato@nostale
      \ifx \@sptoken \hilde@kerta
        \quetto@metta \space \vinya@quetta
      \fi
    \else
      \ifnum 2=\nato@nostale \m@m \fi
      \ifx \@sptoken \hilde@kerta \space \fi
      \vinya@quetta
    \fi
    \expandafter \kara@kerta \m@m &gt;#1%
    \nato@nostale=1%
  \else \ifcat .\noexpand#1\relax
    \chardef \@ch=`#1\relax
    \ifnum \@ch&lt;48 \kara@Ukerta #1%
    \else \ifnum \@ch&lt;58
      \ifnum 2=\nato@nostale
        \ifx \@sptoken \hilde@kerta
          \m@m \space \def \m@m {}%
        \fi
      \else
        \ifnum 1=\nato@nostale \quetto@metta \fi
        \ifx \@sptoken \hilde@kerta \space \fi
        \def \m@m {}%
      \fi
      \edef \m@m {#1\m@m}%
      \nato@nostale=2%
    \else \kara@Ukerta #1%
    \fi\fi
  \else \kara@Ukerta #1%
  \fi\fi
  \def \next {\futurelet \hilde@kerta \tUva@kerta}%
  \fi
  \next}

\def \elvish {% Elvish environment
  \mere@tengwanda%
  \@tengwanda%
  \nato@nostale=0%
  \tUva@kerta }
\def \endelvish {}

\def \quetta #1{\begin{elvish}#1 \end{elvish}} % short quotation

\def \ama@tehta #1#2{% allocate superscript tehta
  \leavevmode \vbox \bgroup
  \baselineskip 0pt\lineskip 0pt%
  \halign {\hss ##\unskip \hss \cr #1\vadjust {\vskip -1ex}\cr #2\cr }%
  \egroup }

\def \Oman@tengwa #1#2{% put vowel tehta over tengwa, inverting silme and esse
  \ifx #1\@silme \@Oman@tengwa #2\@silme@nuquerna
  \else \ifx #1\@esse \@Oman@tengwa #2\@esse@nuquerna
  \else \@Oman@tengwa #2#1%
  \fi\fi}

\def \@Oman@tengwa #1#2{% put vowel tehta over tengwa
  \expandafter \ifx \csname @#1@tehta\endcsname \tanta@Oman
    \expandafter \ama@tehta \csname #1@tehta\endcsname #2%
  \else \expandafter \accent \csname #1@tehta\endcsname #2\fi}

\def \tehta@tengwa #1#2{% put consonant tehta over tengwa,
                        % inverting silme and esse
  \ifx #1\@silme \accent #2\@silme@nuquerna
  \else \ifx #1\@esse \accent #2\@esse@nuquerna
  \else \accent #2#1%
  \fi\fi}

\def \nun@tehta #1#2{% allocate subscript consonant tehta
  \ifx #2:#1\else \expandafter \csname #2@nun@tehta\endcsname {#1}\fi}


%%%%%%%%%%%%%%%%%%%% macro definitions  for Quenya %%%%%%%%%%%%%%%%%%%%

\newif \if@light
\let \heavyvocalise \@lightfalse
\let \lightvocalise \@lighttrue

\def \quenya {%
  \let \kara@kerta \q@kerta
  \def \vinya@quetta {\def \m@m {\sinta@kolindo ::}}%
  \def \quetto@metta {\expandafter \@@teka \m@m&gt;}}

\def \@@teka #1#2#3#4&gt;{%
  \ifx #1\sinta@kolindo \ifx #3:\ifx \relax #4\relax \else \@teka #4&lt;&gt;\fi
  \else \@teka #4#1#2#3&lt;&gt;\fi \else \@teka #4#1#2#3&lt;&gt;\fi}

\def \@teka #1#2#3#4#5&gt;{%
  \ifx #3:%
    \ifx #1\@halla \@halla
    \else \ifx #4\anda@kolindo \nun@tehta #1#2%
    \else \ifx #4\@yanta \nun@tehta #1#2%
    \else \ifx #4\@Ure \nun@tehta #1#2%
    \else
      \def \q@c@n {\ifx #1\@rOmen \@Ore \else #1\fi}%
      \if@light \expandafter \uOman@tehta {\nun@tehta \q@c@n #2}#1%
      \else \nun@tehta \q@c@n #2\fi
    \fi\fi\fi\fi
  \else \ifx #1\@rOmen
    \ifx #2s\s@nun@tehta {\q@c@v \@Ore #3}%
    \else \nun@tehta {\q@c@v \@rOmen #3}#2%
    \fi
  \else \ifx #1\@quessiEva \nun@tehta {\q@c@v \@quesse #3}#2%
  \else \ifx #1\@unquiEva \nun@tehta {\q@c@v \@unque #3}#2%
  \else \nun@tehta {\q@c@v #1#3}#2%
  \fi\fi\fi\fi
  \ifx &lt;#4\let \next \relax \else \def \next {\@teka #4#5&gt;}\fi
  \next}

\def \q@c@v #1#2{% choosing whether to use vowel tehta
                 % depending on vocalisation
  \ifx #2a\if@light #1\else \Oman@tengwa #1a\fi
  \else \Oman@tengwa #1#2%
  \fi}

%%%%%%%%%%%%%%%%%%%%%%%%%%% Quenya  scanner %%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \q@kerta #1&gt;#2{%
  \ifcat #2a\csname #2@q\endcsname #1&gt;%
  \else \ifcat #2.\expandafter \@@teka \m@m&gt;#2\def \m@m {\sinta@kolindo ::}%
  \fi\fi}

\def \a@q #1#2#3#4&gt;{%
  \ifx #3:\def \m@m {#1#2a#4}%
  \else \def \m@m {\sinta@kolindo :a#4#1#2#3}%
  \fi}

\def \e@q #1&gt;{\q@quanta@Oman #1&gt;eE}
\def \o@q #1&gt;{\q@quanta@Oman #1&gt;oO}

\def \q@quanta@Oman #1#2#3#4&gt;#5#6{%
  \ifx #3:\def \m@m {#1#2#5#4}%
  \else \ifx #3#5\def \m@m  {#1#2#6#4}%
  \else \def \m@m {\sinta@kolindo :#5#4#1#2#3}%
  \fi\fi}

\def \i@q #1#2#3#4&gt;{%
  \ifx #3:\def \m@m {#1#2i#4}%
  \else
    \edef \m@m {%
      \sinta@kolindo ::#4\ifx #1\sinta@kolindo \else #1::\fi \@yanta :#3}%
  \fi}

\def \u@q #1#2#3#4&gt;{%
  \ifx #3:%
    \ifx #1\@quessiEva \def \m@m {\@quesse #2#3#4}%
    \else \ifx #1\@unquiEva \def \m@m {\@unque #2#3#4}%
    \else \def \m@m {#1#2u#4}%
    \fi\fi
  \else \ifx #3u\def \m@m  {#1#2U#4}%
  \else
    \edef \m@m
     {\sinta@kolindo ::#4\ifx #1\sinta@kolindo \else #1::\fi \@Ure :#3}%
  \fi\fi}

\def \A@q #1&gt;{\q@anda@Oman #1&gt;a}
\def \E@q #1&gt;{\q@anda@Oman #1&gt;e}
\def \I@q #1&gt;{\q@anda@Oman #1&gt;i}
\def \O@q #1&gt;{\q@anda@Oman #1&gt;o}
\def \U@q #1&gt;{\q@anda@Oman #1&gt;u}

\def \q@anda@Oman #1#2#3#4&gt;#5{%
  \edef \m@m
   {\sinta@kolindo ::#4%
    \ifx #1\sinta@kolindo
      \ifx #3:\else ::#3\fi
    \else #1#2#3\fi \anda@kolindo :#5}}

\def \b@q #1#2#3#4&gt;{\edef \m@m {\@umbar ::#4\ifx #1\@lambe l::\fi}}

\def \d@q #1#2#3#4&gt;{%
  \edef \m@m
   {\ifx #1\@lambe \@alda
    \else \ifx #1\@rOmen \@arda
    \else \@ando \fi\fi ::#4}}

\def \g@q #1#2#3#4&gt;{\def \m@m {\@anga ::#4}}

\def \h@q #1#2#3#4&gt;{%
  \ifx #3:%
    \ifx #1\sinta@kolindo \def \m@m {\@hyarmen ::#4}%
    \else \edef \m@m {\@hyarmen ::#4#1::}%
    \fi
  \else \def \m@m {\hyarmen ::#4#1#2#3}%  
  \fi}

\def \f@q #1&gt;{\q@Upunta #1&gt;\@formen T}
\def \G@q #1&gt;{\q@Upunta #1&gt;\@anna T}
\def \H@q #1&gt;{\q@Upunta #1&gt;\@Harma T}
\def \l@q #1&gt;{\q@Upunta #1&gt;\@lambe L}
\def \m@q #1&gt;{\q@Upunta #1&gt;\@malta D}
\def \n@q #1&gt;{\q@Upunta #1&gt;\@nUmen D}
\def \N@q #1&gt;{\q@Upunta #1&gt;\@Noldo D}
\def \r@q #1&gt;{\q@Upunta #1&gt;\@rOmen T}
\def \R@q #1&gt;{\q@Upunta #1&gt;\@Ore T}
\def \S@q #1&gt;{\q@Upunta #1&gt;\@TUle T}
\def \v@q #1&gt;{\q@Upunta #1&gt;\@vala T}
\def \z@q #1&gt;{\q@Upunta #1&gt;\@esse T}

\def \q@Upunta #1#2#3#4&gt;#5#6{%
  \ifx #3:%
    \ifx #1\sinta@kolindo \def \m@m {#5::#4}%
    \else \ifx #1#5\def \m@m {#5#6:#4}%
    \else \edef \m@m {#5::#4\ifx #1\@hyarmen \@halla \else #1\fi ::}%
    \fi\fi
  \else \def \m@m {#5::#4#1#2#3}%  
  \fi}

\def \s@q #1#2#3#4&gt;{%
  \ifx #3:%
    \ifx #1\sinta@kolindo \def \m@m {\@silme ::#4}%
    \else \ifx #1\@silme \def \m@m {\@esse ::#4}%
    \else
      \edef \m@m
       {#1\ifx #1\@calma x\else \ifx #1\@lambe x\else s\fi\fi :#4}%
    \fi\fi
  \else \def \m@m {\@silme ::#4#1#2#3}%
  \fi}

\def \w@q #1#2#3#4&gt;{%
  \ifx #3:%
    \ifx #1\sinta@kolindo \def \m@m {\@wilya ::#4}%
    \else \ifx #1\@anga \def \m@m {\@ungwe ::#4}%
    \else \ifx #1\@harma \def \m@m {\@hwesta ::#4}%
    \else \ifx #1\@hyarmen \def \m@m {\@hwesta ::#4}%
    \else \ifx #1\@Noldo \def \m@m {\@Nwalme ::#4}%
    \else \def \m@m {\@wilya ::#4#1::}%
    \fi\fi\fi\fi\fi
  \else \def \m@m {\@wilya ::#4#1#2#3}%  
  \fi}

\def \x@q #1#2#3#4&gt;{%
  \edef \m@m{%
    \@calma x:#4%
    \ifx #3:\ifx #1\sinta@kolindo \else #1::\fi\else #1#2#3\fi }}    

\def \y@q #1#2#3#4&gt;{%
  \ifx #3:%
    \edef \m@m {%
      \ifx #1\sinta@kolindo \@anna \else #1\fi
      \ifx #1\@rOmen r\else \ifx #1\@lambe l\else y\fi\fi :#4}%
  \else \def \m@m {\@anna y:#4#1#2#3}%
  \fi}

\def \c@q #1&gt;{\q@punta #1&gt;\@calma \@nUmen \@anca}
\let \k@q \c@q
\def \p@q #1&gt;{\q@punta #1&gt;\@parma \@malta \@ampa}
\def \q@q #1&gt;{\q@punta #1&gt;\@quessiEva \@nUmen \@unquiEva}

\def \q@punta #1#2#3#4&gt;#5#6#7{%
  \ifx #3:%
    \ifx #1\sinta@kolindo \def \m@m {#5::#4}%
    \else \ifx #1#5\def \m@m {#5T:#4}%
    \else \ifx #1#6\def \m@m {#7::#4}%
    \else \def \m@m {#5::#4#1::}%
    \fi\fi\fi
  \else \def \m@m {#5::#4#1#2#3}%
  \fi}

\def \t@q #1#2#3#4&gt;{%
  \ifx #3:%
    \ifx #1\sinta@kolindo \def \m@m {\@tinco ::#4}%
    \else \ifx #1\@hyarmen \def \m@m {\@tinco ::#4\@Harma ::}%
    \else \ifx #1\@tinco \def \m@m {\@tinco T:#4}%
    \else \ifx #1\@nUmen \def \m@m {\@anto ::#4}%
    \else \def \m@m {\@tinco ::#4#1::}%
    \fi\fi\fi\fi
  \else \def \m@m {\@tinco ::#4#1#2#3}%
  \fi}


%%%%%%%%%%%%%%%%%%% macro definitions  for Sindarin %%%%%%%%%%%%%%%%%%%

\def \oright {\def \o@sind {o}\def \u@sind {u}\def \O@sind {O}\def \U@sind {U}}
\def \oleft  {\def \o@sind {u}\def \u@sind {o}\def \O@sind {U}\def \U@sind {O}}

\newif \if@ninOre
\def \ninnUmen {%
  \@ninOrefalse
  \let \n@sind \@nUmen \let \m@sind \@malta \def \n@gem {N}}
\def \ninOre {%
  \@ninOretrue
  \let \n@sind \@Ore   \let \m@sind \@vala  \def \n@gem {:}}

\def \vinquesse{% use only the quessetEma
  \let \c@sind \@quesse  \let \k@sind \@quesse  \let \g@sind \@ungwe
  \let \ch@sind \@hwesta \let \kh@sind \@hwesta \let \gh@sind \@unque
  \let \N@sind \@Nwalme}
\def \vaswestron{% use both the calmatEma and the quessetEma
  \let \c@sind \@calma   \let \k@sind \@quesse  \let \g@sind \@ungwe
  \let \ch@sind \@hwesta \let \kh@sind \@hwesta \let \gh@sind \@unque
  \let \N@sind \@Nwalme}
\def \vincalma{% use only the calmatEma
  \let \c@sind \@calma   \let \k@sind \@calma   \let \g@sind \@anga
  \let \ch@sind \@Harma  \let \kh@sind \@Harma  \let \gh@sind \@anca
  \let \N@sind \@Noldo}

\def \sindarin {%
  \let \kara@kerta \s@kerta
  \oright \ninnUmen \vinquesse
  \def \vinya@quetta {\def \m@m {::\sinta@kolindo :}}%
  \def \quetto@metta {\expandafter \@@teitho \m@m&gt;}}

\def \@@teitho #1#2#3#4#5&gt;{%
  \ifx #1:\ifx #3\sinta@kolindo \ifx \relax #5\relax \else \@teithoi #5&lt;&gt;\fi
  \else \@teithoi #5#1#2#3#4&lt;&gt;\fi \else \@teithoi #5#1#2#3#4&lt;&gt;\fi}

\def \@teithoi #1#2#3#4#5#6&gt;{%
  \ifx #3\@phormen
    \ifx #5&lt;\s@v@t@c@t #1#2\@formen #4%
    \else \ifx #1:\s@v@t@c@t #1#2\@formen #4%
    \else \s@v@t@c@t #1#2\@formen T%
    \fi\fi
  \else \ifx #3\sinta@kolindo
    \ifx #5&lt;\@Oman@tengwa #1\sinta@kolindo
    \else \ifx #1i\@yanta
    \else \@Oman@tengwa #1\sinta@kolindo
    \fi\fi
  \else \@teithoo #1#2#3#4#5%
  \fi\fi
  \ifx &lt;#5\let \next \relax \else \def \next {\@teithoii #5#6&gt;}\fi
  \next}

\def \@teithoii #1#2#3#4#5#6&gt;{%
  \ifx #3\@phormen
    \ifx #5&lt;\s@v@t@c@t #1#2\@formen #4\else \s@v@t@c@t #1#2\@formen T\fi
  \else \@teithoo #1#2#3#4#5%
  \fi
  \ifx &lt;#5\let \next \relax \else \def \next {\@teithoii #5#6&gt;}\fi
  \next}

\def \@teithoo #1#2#3#4#5{%
  \ifx #3\@formen
    \ifx #5&lt;\s@v@t@c@t #1#2\@ampa #4\else \s@v@t@c@t #1#2\@formen #4\fi
  \else \ifx #3\@rOmen
    \if@ninOre
      \s@v@t@c@t #1#2#3#4%
    \else
      \ifx #5&lt;\s@v@t@c@t #1#2\@Ore #4%
      \else \s@v@t@c@t #1#2\@rOmen #4%
      \fi
    \fi
  \else \s@v@t@c@t #1#2#3#4%
  \fi\fi}

\def \s@v@t@c@t #1#2#3#4{%
  \nun@tehta {%
    \ifx #1:\ifx #2:#3%
      \else \tehta@tengwa #3#2%
      \fi 
    \else\ifx #2:\Oman@tengwa #3#1%
      \else
        \expandafter \ama@tehta \csname #1@tehta\endcsname
         {\tehta@tengwa #3#2}%
      \fi 
    \fi}%
  #4}

%%%%%%%%%%%%%%%%%%%%%%%%%% Sindarin  scanner %%%%%%%%%%%%%%%%%%%%%%%%%%

\def \s@kerta #1&gt;#2{%
  \ifcat #2a\csname #2@s\endcsname #1&gt;%
  \else \ifcat #2.%
    \expandafter \@@teitho \m@m&gt;#2\def \m@m {::\sinta@kolindo :}%
  \fi\fi}

\def \a@s #1&gt;{\s@quanta@Oman #1&gt;a}
\def \y@s #1&gt;{\s@quanta@Oman #1&gt;y}

\def \s@quanta@Oman #1#2#3#4#5&gt;#6{%
  \ifx #3\sinta@kolindo
    \edef \m@m {#6:\sinta@kolindo :#5\ifx #1:\else #1:\sinta@kolindo :\fi}%
  \else \def \m@m {#6:\sinta@kolindo :#5#1#2#3#4}%
  \fi}

\def \e@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo
    \ifx #1a\def \m@m {::\sinta@kolindo :#5a:\@yanta :}%
    \else \ifx #1o\def \m@m {::\sinta@kolindo :#5o:\@yanta :}%
    \else \ifx #1e\def \m@m {E:\sinta@kolindo :#5}%
    \else
      \edef \m@m {e:\sinta@kolindo :#5\ifx #1:\else #1:\sinta@kolindo :\fi}%
    \fi\fi\fi
  \else \def \m@m {e:\sinta@kolindo :#5#1#2#3#4}%
  \fi}

\def \i@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo
    \ifx #1:\def \m@m {i:\sinta@kolindo :#5}%
    \else \def \m@m{::\sinta@kolindo :#5#1:\@anna :}%
    \fi
  \else \def \m@m {i:\sinta@kolindo :#5#1#2#3#4}%
  \fi}

\def \o@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo
    \ifx #1\o@sind \edef \m@m {\O@sind:\sinta@kolindo :#5}%
    \else
      \edef \m@m
       {\o@sind :\sinta@kolindo :#5\ifx #1:\else #1:\sinta@kolindo :\fi}%
    \fi
  \else \edef \m@m {\o@sind :\sinta@kolindo :#5#1#2#3#4}%
  \fi}

\def \u@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo
    \ifx #1:\def \m@m {\u@sind :\sinta@kolindo :#5}%
    \else \ifx #1\u@sind \edef \m@m {\U@sind:\sinta@kolindo :#5}%
    \else \def \m@m{::\sinta@kolindo :#5#1:\@Ure :}%
    \fi\fi
  \else \def \m@m {\u@sind :\sinta@kolindo :#5#1#2#3#4}%
  \fi}

\def \A@s #1&gt;{\s@anda@Oman #1&gt;a}
\def \E@s #1&gt;{\s@anda@Oman #1&gt;e}
\def \I@s #1&gt;{\s@anda@Oman #1&gt;i}
\def \O@s #1&gt;{\s@anda@Oman #1&gt;o}
\def \U@s #1&gt;{\s@anda@Oman #1&gt;u}
\def \Y@s #1&gt;{\s@anda@Oman #1&gt;y}

\def \s@anda@Oman #1#2#3#4#5&gt;#6{%
  \edef \m@m
   {::\sinta@kolindo :#5%
    \ifx #1:\ifx #3\sinta@kolindo \else :#2#3:\fi \else #1#2#3#4\fi
    #6:\anda@kolindo :}}

\def \f@s #1&gt;{\s@surya #1&gt;\@formen T}
\def \l@s #1&gt;{\s@surya #1&gt;\@lambe L}
\def \r@s #1&gt;{\s@surya #1&gt;\@rOmen T}
\def \R@s #1&gt;{\if@ninOre \s@surya #1&gt;\@rOmen T\else \s@surya #1&gt;\@Ore T\fi}
\def \v@s #1&gt;{\s@surya #1&gt;\@ampa D}

\def \s@surya #1#2#3#4#5&gt;#6#7{%
  \ifx #3\sinta@kolindo \def \m@m {#1:#6:#5}%
  \else \ifx #3#6\def \m@m {#1#2#6#7#5}%
  \else \def \m@m {::#6:#5#1#2#3#4}%
  \fi\fi}

\def \b@s #1&gt;{\s@punta #1&gt;\@umbar \m@sind \landa@ama@falma D}
\def \c@s #1&gt;{\s@punta #1&gt;\c@sind \n@sind \arka@ama@falma T}
\def \d@s #1&gt;{\s@punta #1&gt;\@ando \n@sind \landa@ama@falma D}
\def \g@s #1&gt;{\s@punta #1&gt;\g@sind \n@sind \landa@ama@falma D}
\def \j@s #1&gt;{\s@punta #1&gt;\@anca \n@sind \landa@ama@falma D}
\def \k@s #1&gt;{\s@punta #1&gt;\k@sind \n@sind \arka@ama@falma T}
\def \p@s #1&gt;{\s@punta #1&gt;\@parma \m@sind \arka@ama@falma T}
\def \t@s #1&gt;{\s@punta #1&gt;\@tinco \n@sind \arka@ama@falma T}

\def \s@punta #1#2#3#4#5&gt;#6#7#8#9{%
  \ifx #3\sinta@kolindo \def \m@m {#1:#6:#5}%
  \else \ifx #3#6\def \m@m {#1#2#6#9#5}%
  \else \ifx #3#7\def \m@m {#1#8#6:#5}%
  \else \def \m@m {::#6:#5#1#2#3#4}%
  \fi\fi\fi}

\def \m@s #1&gt;{\s@nengwea #1&gt;\m@sind \@malta }
\def \n@s #1&gt;{\s@nengwea #1&gt;\n@sind \@nUmen }

\def \s@nengwea #1#2#3#4#5&gt;#6#7{%
  \ifx #3\sinta@kolindo \def \m@m {#1:#6:#5}%
  \else \ifx #3#6\edef \m@m {#1\if@ninOre :\else \landa@ama@falma \fi #7:#5}%
  \else \def \m@m {::#6:#5#1#2#3#4}%
  \fi\fi}

\def \N@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo \def \m@m {#1:\N@sind :#5}%
  \else \ifx #3\N@sind \edef \m@m {#1\landa@ama@falma \N@sind :#5}%
  \else \def \m@m {::\N@sind :#5#1#2#3#4}%
  \fi\fi}

\def \h@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo \def \m@m {#1:\@hyarmen :#5}%
  \else \ifx #3\@tinco \def \m@m {#1#2\@TUle :#5}%
  \else \ifx #3\@ando \def \m@m {#1#2\@anto :#5}%
  \else \ifx #3\@parma \def \m@m {#1#2\@phormen :#5}%
  \else \ifx #3\@umbar \def \m@m {#1#2\@ampa :#5}%
  \else \ifx #3\@malta \def \m@m {#1\landa@ama@falma \@ampa :#5}%
  \else \ifx #3\c@sind \def \m@m {#1#2\ch@sind :#5}%
  \else \ifx #3\g@sind \def \m@m {#1#2\gh@sind :#5}%
  \else \ifx #3\@lambe \def \m@m {#1#2\@alda :#5}%
  \else \ifx #3\@rOmen \def \m@m {#1#2\@arda :#5}%
  \else \ifx #3\@silme \def \m@m {#1#2\@Harma :#5}%
  \else \ifx #3\@esse \def \m@m {#1#2\@anca :#5}%
  \else \def \m@m {::\@hyarmen :#5#1#2#3#4}%
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}

\def \H@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo \def \m@m {#1:\@hyarmen :#5}%
  \else \def \m@m {::\@hyarmen :#5#1#2#3:}%
  \fi}

\def \s@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo \def \m@m {#1:\@silme :#5}%
  \else \ifx #3\@silme \def \m@m {#1#2\@esse :#5}%
  \else \def \m@m {#1#2#3s#5}%
  \fi\fi}

\def \w@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo \def \m@m {#1:\@wilya :#5}%
  \else \ifx #3\@hyarmen \def \m@m {#1#2\@hwesta@sindarinwa :#5}%
  \else \ifx #2:\def \m@m {#1\w@tehta #3:#5}%
  \else \def \m@m {::\@wilya :#5#1#2#3:}%
  \fi\fi\fi}

\def \z@s #1#2#3#4#5&gt;{%
  \ifx #3\sinta@kolindo \def \m@m {#1:\@esse :#5}%
  \else \def \m@m {::\@esse :#5#1#2#3:}%
  \fi}


%%%%%%%%%%%%%%%%%% macro definitions for Beleriandic %%%%%%%%%%%%%%%%%%

\newif \ifsinta@Oman % short vowel just read
\newif \if@thegra    % first letter of a word

\def \beleriand {%
  \let \kara@kerta \b@kerta
  \ninOre \vincalma
  \def \vinya@quetta {\def \m@m {:::}\sinta@Omanfalse \@thegratrue }%
  \def \quetto@metta {\expandafter \tEw@mhedui \m@m }}

\def \@garo #1{\def \m@m {#1}\@thegrafalse }

\def \@teitho #1#2#3&gt;{%
  \ifx #2:%
  \else \ifx #2\@phormen
    \if@thegra \b@t@c@t #1\@formen#3\else \b@t@c@t #1\@formen T\fi
  \else \ifx #2\i@iEva
    \b@t@c@t #1\sinta@kolindo#3%
  \else \b@t@c@t #1#2#3%
  \fi\fi\fi }

\def \@teithov #1#2#3&gt;{%
  \ifx #2\i@iEva \anda@kolindo\else \@teitho #1#2#3&gt;\fi }

\def \tEw@mhedui #1#2#3{%
  \ifx #2\i@iEva \sinta@kolindo
  \else \ifx #2\@formen \b@t@c@t #1\@ampa #3%
  \else \ifx #2\@phormen \b@t@c@t #1\@formen#3%
  \else \ifx #2\@rOmen%
    \if@ninOre \b@t@c@t #1\@rOmen #3\else \b@t@c@t #1\@Ore #3\fi
  \else \b@t@c@t #1#2#3%
  \fi\fi\fi\fi }

\def \b@t@c@t #1#2#3{%
  \nun@tehta {\ifx #1:#2\else \tehta@tengwa #2#1\fi }#3}

%%%%%%%%%%%%%%%%%%%%%%%%% Beleriandic scanner %%%%%%%%%%%%%%%%%%%%%%%%%

\def \b@kerta #1&gt;#2{%
  \ifcat #2a\csname #2@b\endcsname #1&gt;%
  \else \ifcat #2.\m@m
  \fi\fi }

\def \a@b #1&gt;{\b@quanta@Oman #1&gt;\a@tengwa }
\def \y@b #1&gt;{\b@quanta@Oman #1&gt;\y@tengwa }

\def \b@quanta@Oman #1#2#3&gt;#4{%
  \ifx #2:\else \@teithov #1#2#3&gt;\fi
  \@garo {:#4:}\sinta@Omantrue }

\def \e@b #1&gt;{\b@tanta@Oman #1&gt;\@yanta }
\def \o@b #1&gt;{\b@tanta@Oman #1&gt;\o@tengwa }

\def \b@tanta@Oman #1#2#3&gt;#4{%
  \ifx #2#4\@garo {\@andaith #4:}\sinta@Omanfalse
  \else
    \ifx #2:\else \@teithov #1#2#3&gt;\fi
    \@garo {:#4:}\sinta@Omantrue
  \fi}

\def \i@b #1&gt;{%
  \if@thegra \b@per@Oman #1&gt;\i@iEva \y@tehta
  \else \b@per@Oman #1&gt;\sinta@kolindo \y@tehta
  \fi }
\def \u@b #1#2#3&gt;{%
  \ifx #2\@Ure \@garo {\@andaith \@Ure :}\sinta@Omanfalse
  \else \b@per@Oman #1#2#3&gt;\@Ure \w@tehta
  \fi }

\def \b@per@Oman #1#2#3&gt;#4#5{%
  \ifsinta@Oman \@garo {#5#2:}\sinta@Omanfalse
  \else
    \ifx #2:\else \@teithov #1#2#3&gt;\fi
    \@garo {:#4:}\sinta@Omantrue
  \fi}

\def \b@per@Oman #1#2#3&gt;#4#5{%
  \ifx #2#4\@garo {\@andaith #4:}\sinta@Omanfalse
  \else \ifsinta@Oman \@garo {#5#2:}\sinta@Omanfalse
  \else
    \ifx #2:\else \@teithov #1#2#3&gt;\fi
    \@garo {:#4:}\sinta@Omantrue
  \fi\fi}

\def \A@b #1&gt;{\b@anda@Oman #1&gt;\a@tengwa }
\def \E@b #1&gt;{\b@anda@Oman #1&gt;\@yanta}
\def \I@b #1&gt;{\b@anda@Oman #1&gt;\sinta@kolindo }
\def \O@b #1&gt;{\b@anda@Oman #1&gt;\o@tengwa }
\def \U@b #1&gt;{\b@anda@Oman #1&gt;\@Ure }
\def \Y@b #1&gt;{\b@anda@Oman #1&gt;\y@tengwa }

\def \b@anda@Oman #1#2#3&gt;#4{%
  \ifx #2:\else \@teithov #1#2#3&gt;\fi
  \@garo {\@andaith #4:}\sinta@Omanfalse }

\def \f@b #1&gt;{\b@surya #1&gt;\@formen D}
\def \l@b #1&gt;{\b@surya #1&gt;\@lambe L}
\def \r@b #1&gt;{\b@surya #1&gt;\@rOmen T}
\def \R@b #1&gt;{\if@ninOre \b@surya #1&gt;\@rOmen T\else \b@surya #1&gt;\@Ore T\fi}
\def \v@b #1&gt;{\b@surya #1&gt;\@ampa D}

\def \b@surya #1#2#3&gt;#4#5{%
  \ifx #2#4\@garo {#1#2#5}%
  \else
    \ifx #2:\else \@teitho #1#2#3&gt;\fi
    \@garo {:#4:}%
  \fi \sinta@Omanfalse }

\def \s@b #1#2#3&gt;{%
  \ifx #2\@silme \@garo {:\@esse :}%
  \else
    \ifx #2:\else \@teitho #1#2#3&gt;\fi
    \@garo {:\@silme :}%
  \fi \sinta@Omanfalse }

\def \c@b #1&gt;{\b@punta #1&gt;\c@sind \n@sind \arka@ama@falma T}
\def \b@b #1&gt;{\b@punta #1&gt;\@umbar \m@sind \landa@ama@falma D}
\def \d@b #1&gt;{\b@punta #1&gt;\@ando \n@sind \landa@ama@falma D}
\def \g@b #1&gt;{\b@punta #1&gt;\g@sind \n@sind \landa@ama@falma D}
\def \j@b #1&gt;{\b@punta #1&gt;\@anca \n@sind \landa@ama@falma D}
\def \k@b #1&gt;{\b@punta #1&gt;\k@sind \n@sind \arka@ama@falma T}
\def \p@b #1&gt;{\b@punta #1&gt;\@parma \m@sind \arka@ama@falma T}
\def \t@b #1&gt;{\b@punta #1&gt;\@tinco \n@sind \arka@ama@falma T}

\def \b@punta #1#2#3&gt;#4#5#6#7{%
  \ifx #2#4\@garo {#1#2#7}%
  \else \ifx #2#5\@garo {#6#4:}%
  \else
    \ifx #2:\else \@teitho #1#2#3&gt;\fi
    \@garo {:#4:}%
  \fi\fi \sinta@Omanfalse }

\def \m@b #1&gt;{\b@nengwea #1&gt;\m@sind \@malta \landa@ama@falma }
\def \n@b #1&gt;{\b@nengwea #1&gt;\n@sind \@nUmen \arka@ama@falma }

\def \b@nengwea #1#2#3&gt;#4#5#6{%
  \ifx #2#4%
    \if@ninOre \@garo {:#5:}\else \@garo {#6#2:}\fi
  \else
    \ifx #2:\else \@teitho #1#2#3&gt;\fi
    \@garo {:#4:}%
  \fi \sinta@Omanfalse }

\def \N@b #1#2#3&gt;{%
  \ifx #2\N@sind
    \@garo {\landa@ama@falma \N@sind :}%
  \else
    \ifx #2:\else \@teitho #1#2#3&gt;\fi
    \@garo {:\N@sind :}%
  \fi \sinta@Omanfalse }

\def \h@b #1#2#3&gt;{%
  \ifx #2\@tinco \@garo {#1\@TUle :}%
  \else \ifx #2\@ando \@garo {#1\@anto :}%
  \else \ifx #2\@parma \@garo {#1\@phormen :}%
  \else \ifx #2\@umbar \@garo {#1\@ampa :}%
  \else \ifx #2\m@sind \@garo {\landa@ama@falma \@ampa :}%
  \else \ifx #2\c@sind \@garo {#1\ch@sind :}%
  \else \ifx #2\g@sind \@garo {#1\gh@sind :}%
  \else \ifx #2\@lambe \@garo {#1\@alda :}%
  \else \ifx #2\@rOmen \@garo {#1\@arda :}%
  \else \ifx #2\@silme \@garo {#1\@Harma :}%
  \else \ifx #2\@esse \@garo {#1\@anca :}%
  \else
    \ifx #2:\else \@teitho #1#2#3&gt;\fi
    \@garo {:\@hyarmen :}%
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \sinta@Omanfalse }

\def \H@b #1#2#3&gt;{%
  \ifx #2:\else \@teitho #1#2#3&gt;\fi
  \@garo {:\@hyarmen :}%
  \sinta@Omanfalse }

\def \w@b #1#2#3&gt;{%
  \ifx #2\@hyarmen \@garo {:\@hwesta@sindarinwa :}%
  \else
    \ifx #2:\@garo {:\@wilya :}%
    \else \ifx #1:\@garo {\w@tehta #2:}%
    \else \@teitho #1#2#3&gt;\@garo {:\@wilya :}%
    \fi\fi
  \fi \sinta@Omanfalse }

\def \z@b #1#2#3&gt;{%
  \ifx #2:\else \@teitho #1#2#3&gt;\fi
  \@garo {:\@esse :}%
  \sinta@Omanfalse }


%%%%%%%%%%%%%%%%%%%%%% ignore  all other letters %%%%%%%%%%%%%%%%%%%%%%

\@tfor\ch@r:={BCDFJKLMPQTVWXYZj}\do{%
  \expandafter \def \csname \ch@r @q\endcsname #1#2#3#4&gt;{}}

\@tfor\ch@r:={BCDFGJKLMPQSTVWXZqx}\do{%
  \expandafter \def \csname \ch@r @s\endcsname #1#2#3#4&gt;{}%
  \expandafter \def \csname \ch@r @b\endcsname #1#2#3#4&gt;{}}
</pre></body></html>