[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vaxuum::document_ft

Title:DOCUMENT T1.0
Notice:**New notesfile (DOCUMENT.NOTE) now available (see note 897)**
Moderator:CLOSET::ADLER
Created:Mon Feb 09 1987
Last Modified:Thu Oct 31 1991
Last Successful Update:Fri Jun 06 1997
Number of topics:897
Total number of notes:4397

883.0. "Help requested with defining new tags" by CASEE::CLARK (Ward Clark) Sun Sep 06 1987 13:05

    I've been venturing into the relatively uncharted realms of defining
    new tags (see 848.*).  Even with the help of the hefty Tag Designer's
    Guide (sans index), I've run into an apparent dead end regarding
    "quoting".  (Note 848.4 has the details.) 

    At this point, I see three ways out of my dead end:

        1.  Inspect the definitions for similar builtin tags (e.g., <HEAD1>) 
	    for inspiration.  Unfortunately, the source for the builtin
	    definitions don't seem to be part of the kit.

	2.  Ask the developers and/or writers for a more complete
	    description of DOCUMENT's "quoting" rules.

	    Translating my current problem into BLISS, "|&" becomes
	    "%QUOTE", but I can't find an equivalent for "%UNQUOTE".

	3.  Ask the developers for specific help with my tag definitions.

    Where do I go from here?

    -- Ward
T.RTitleUserPersonal
Name
DateLines
883.1CUPOLA::HAKKARAINENDays of Mackerel and FlounderTue Sep 08 1987 09:239
    Not sure what you mean by ``unquote''. The vbar and ampersand pair
    are the begin and end quote characters:
    
    |this is quoted.& this is not.
    
    If a quote string is encountered during tag translation, the string
    is stashed, untranslated, as the defn of the tag. If tags are contained
    within the quoted string, they aren't evaluated until the parent
    tag is called for.
883.2Getting down to the nitty-grittyCASEE::CLARKWard ClarkTue Sep 08 1987 14:4468
    Here's a simplified form of the <HEAD1> redefinition that I'm
    attempting:

	<COPY_TAG>(HEAD1\xdoc_head1)

	<DEFINE>(HEAD1\<EOL>
	    <COMMENT>( Pass 2 )<EOL>
		|<EOL>
		<COMMENT>( Just invoke the copied tag. )<EOL>
		<xdoc_head1>($1\$2)<EOL>

		<COMMENT>( Reset the requirement counter to 0. )<EOL>
		<COUNTER>(xdoc_req_counter\=0)<EOL>
		<COUNTER>(xdoc_head1_number\+1)<EOL>
		&<EOL>
	    \\\\\
	    <COMMENT>( Pass 1 )<EOL>
		|<EOL>
		<COMMENT>( Just invoke the copied tag. )<EOL>
		<xdoc_head1>($1\$2)<EOL>
		&<EOL>
	    )<EOL>

    As I indicated in the "\newtheorem" topic, this definition fails
    during Pass 1 unless all <HEAD1> tags include a symbol name ($2).
    So I tried to make the Pass 1 invocation of <xdoc_head1> include the
    right number of arguments.  Here's my first attempt:

	    <COMMENT>( Pass 1 )<EOL>
		|<EOL>
		<COMMENT>( Just invoke the copied tag. )<EOL>
		<COMPARE>($2\<EOL>
		    \<xdoc_head1>($1)<EOL>
		    \<xdoc_head1>($1\$2)<EOL>
		    )<EOL>
		&<EOL>

    When the error messages didn't go away, I hacked in some "print"
    statements (actually <TAG_DIAGNOSTIC>s) and it appeared that both
    "legs" of the <COMPARE> were being evaluated/invoked.

    Since that appeared to be a quoting problem, I added the "|&" quoting
    characters:

	    <COMMENT>( Pass 1 )<EOL>
		|<EOL>
		<COMMENT>( Just invoke the copied tag. )<EOL>
		<COMPARE>($2\<EOL>
		    \|<xdoc_head1>($1)&<EOL>
		    \|<xdoc_head1>($1\$2)&<EOL>
		    )<EOL>
		&<EOL>

    That seems to cause only the desired "leg" of the <COMPARE> to be
    invoked.  However, it then appears that the "$2" is passed to the
    <xdoc_head1> tag as a literal, rather than having argument
    substitution.

    It seems that I'm in a "damned if I do and damned if I don't" situation
    with respect to quoting.

    There must be a way to achieve what I want because the builtin
    definition of <HEAD1> probably includes similar logic.

    -- Ward

    P.S.  A discussion of unquoting/%UNQUOTE would be far effort than it's
    worth.  Trust me or ask your local BLISS macro wizard.
883.3quoting and "unquoting"VAXUUM::KOHLBRENNERTue Sep 08 1987 16:3131
    You found out about quoting args 3 and 4 to the <compare>.  If you
    do not quote them, they get "executed" as they are read.  If you
    do quote them, then only one of them gets executed, depending
    on the result of the comparison.
    
    WHen you quote them, however, you are putting a protection around
    the argument references, so they do not get replaced with the arguments
    to the <head1> tag.  That is the damned if you do and damned if
    you don't dilemma.
    
    WHat you must do is to "unquote" each argument reference.  So:
    
      |<compare>($2\\|<foo>(&$1|)&\|<foo>(&$1|\&$2|)&)&
                     ^------^  ^-^ ^------^  ^-^  ^-^   inner quotes
      ^-----------------------------------------------^ outer quote
    
    WHat you are doing is leaving the $n argument references at the
    "top-level" of quoting.  That way, when the argument substitution
    for the <head1> tag takes place, all the $n argument references
    are not protected by any inner quoting characters, thus the
    references are replaced by the corresponding arguments.
               
    By the way, there are two ways to test if there was a second
    argument.  The way you have chosen tests whether the second 
    argument is non-blank, which is probably what you want to do.
    Sometimes you want to test whether or not an argument was
    supplied (even a blank or null one).  In this case you'll
    want to do <compare_numeric>($#\lt\2\...
    
    bill