Above we basically treated all the special cases. Let us turn to the actual translation functions.
There are two functions that are called in the main while loop above.
From the implementation point of view adtranslateAdsnippetText is the simpler one. An adsnippet like environment is realized in aldordoc.sty.nw by escaping anything with ∖verb that is not one of the active commands.
A bit more complex is the function adtranslateLine. It basically works as follows. If there is an ∖adcode command within a line, the line is split into the text before ∖adcode, the argument of ∖adcode, and the text after the ∖adcode argument. Of course, we take care of the argument delimiter character. In particular, we treat
\adcode{SOME CODE}
|
in the same way as
\adcode}SOME CODE}
|
where the closing brace } is considered to be the delimiting character.
The text before ∖adcode is investigated for aldordoc interface-only commands via the function adtranslateInterfaceOnlyCommands. The string ∖adcode is thrown away and its argument is replaced by the output of the function adtranslateAdcodeArgument.
The text after the argument of ∖adcode is treated recursively. Well, we do it in a while loop.
Again, the translation of the ∖adcode argument is as simple as for the adsnippet environment done by the function adtranslateAdsnippetText, since the main work is done by the function adtranslateActiveCommands.
This text is considered by LATEX for expansion, so we must really turn it into verbatim text by generating a ∖verb command. If an empty string is given, no ∖verb command is generated. An empty delimiter means that we must choose a delimiter and take care of the case if the the delimiter is part of the string. We choose the character &, because it is a reserved character for the Aldor language and does usually not appear in an Aldor program. Nevertheless, the implementation below takes care of possible appearances of this character.