26.3 Translation of aldordoc Interface-Only Commands

Except adcode, the commands of the aldordoc user interface that are not directly implemented in aldordoc.sty.nw are called interface-only commands. Their corresponding implemented counterparts are listed in Section 25.4.

These commands are

and they will be translated into

with appropriate parameters.

There can be several interface-only commands on one line. We treat them one after the other by calling the actual translation routine adtranslateInterfaceOnlyCommand.

The function works roughly as follows. It loops over the given string as long as it finds occurrences of interface-only commands. If such a command is found, the text before the command is fed to the (escape) function that was given as the second parameter. The interface-only command itself is handed over to adtranslateInterfaceOnlyCommand which returns the translated command together with the remaining text that come after this command.

307adtranslateInterfaceOnlyCommands 307  (330)
sub adtranslateInterfaceOnlyCommands {
    my ($str, $escape, @escargs) = @_;
    my ($ret, $translated) = (’’, ’’);
    while ($str=~/(\\ad(parameter|(define)?name))/) {
        $ret .= &{$escape}($‘, @escargs);
        $str = "$1$’";
        ($translated, $str) = &adtranslateInterfaceOnlyCommand($str);
        $ret .= $translated;
    }
    $ret .= &{$escape}($str, @escargs);
    return $ret;
}

Defines:
adtranslateInterfaceOnlyCommands, used in chunk 304.

Uses adtranslateInterfaceOnlyCommand 308.

The actual translation routine is listed below. It takes as input a string that must start with one of the interface-only commands. In fact, \ad must be the first three characters. An optional type parameter that matches ConstructorNameRegularExpression is copied without modification for adname and addefinename. The actual argument has the form

FUNC: SIGNATURE

where the SIGNATURE part is allowed to be missing for adname.

ToDo 15 The existence of the signature part is not checked.
308adtranslateInterfaceOnlyCommand 308  (330)
sub adtranslateInterfaceOnlyCommand {
    my ($str) = @_;
    my ($ret) = ’’;
    my ($b, $o, $type, $name, $c);
    my ($indexkey, $indextext);
    my ($hyperlabelname, $hyperlabelsignature);
    my ($latextext, $signature);
    my ($texcommand);

    if ($str=~/^\\ad(parameter|(define)?name(\[constructor name regular expression 317\])?){/) {
        $texcommand = $1;
        $str = "{$’"; # must copy {
        ($b, $o, $name, $c, $str) = &splitBalancedParentheses($str,’{’,’}’);

        ($indexkey, $indextext,
         $hyperlabelname, $hyperlabelsignature,
         $latextext, $signature) = &splitNameAndSignatureArgument($name);

        if ($texcommand =~ /^name/) {$ret = ’use’;} #\adinternalusename
        $ret = ’\adinternal’ . $ret . $texcommand;

        if ($texcommand eq ’parameter’) {
            $ret .= "{$latextext}{" . &escapeForTTLatex($signature) . "}";
        } else {
            $ret .= "{$indexkey}{$indextext}"
                  . "{$hyperlabelname}{$hyperlabelsignature}"
                  . "{$latextext}";
        }
    } else {
        print STDERR "ERROR: adtranslateInterfaceOnlyCommand: " .
                     "No interface-only command found.\n";
        print STDERR "Current line is:\n";
        print STDERR "$str\n";
        die "";
    }
    return ($ret, $str);
}

Defines:
adtranslateInterfaceOnlyCommand, used in chunks 307 and 318.

Uses escapeForTTLatex 329, splitBalancedParentheses 321, and splitNameAndSignatureArgument 325.