RE: [sv-bc] white space at the end of macro text

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Thu Mar 16 2006 - 01:35:49 PST
Steve, both you and Greg seem to agree on what the intent is.

Let me summarize my understanding, including some things which you did
not write explicitly.

Rule 1. If a string literal occurs within a text macro definition, then
macro expansion does not occur inside it.
"Macro expansion" here means both substitution of formal arguments of
the macro and also expansion of other, previously defined macros.

E.g.,
`define A 111
`define B " `A "

Then `B is " `A ", not " 111 ".

Rule 2. You can have quotation marks in a text macro definition without
using \", but then Rule 1 applies, and macro expansion will not occur
after an opening quotation mark until a closing quotation mark occurs.

Rule 3. You can use \" instead of " to get a quotation mark in the text
macro definition, but then Rule 1 does not apply, and then macro
expansion WILL occur if a macro call or a formal argument name is
encountered. (What happens if " is followed by \" or the reverse?)


If those are the rules, I have no problem, but 1800 does not state them
in an understandable way. Even Brad was fooled.

By the way, how can I get `` in a macro expansion?

Finally, all the examples show use of the special escape sequences in
the macro text definition. Is it possible to use them in macro actual
arguments?

Thanks,
Shalom


> -----Original Message-----
> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On
> Behalf Of Steven Sharp
> Sent: Thursday, March 16, 2006 2:12 AM
> To: sv-bc@eda.org; Bresticker, Shalom
> Subject: RE: [sv-bc] white space at the end of macro text
> 
> 
> >From: "Bresticker, Shalom" <shalom.bresticker@intel.com>
> 
> >In any case, the 3.0 text can be interpreted as implying:
> >
> >1. You don't need back ticks for the usual case of simple
> opening and closing
> quotation marks. This could be inferred from the phrase "an
> isolated quote".
> >
> >2. In a macro text definition, if quotation marks are preceded
> by back ticks,
> then macro arguments are expanded. However, if regular
> quotation marks are used,
> then macro arguments inside the quotation marks are not
> expanded. This could be
> inferred from the sentence, " This allows macro arguments to be
> included in
> strings."
> 
> Yes, I believe this was the intent.
> 
> > (I don't know what tools did on 1364 code.)
> 
> If they were implemented correctly, they did not substitute
> macro actuals
> for macro formals inside string literals.
> 
> More accurately, they did not substitute them for text inside
> string
> literals that happened to have the same sequence of characters
> as a macro
> formal.  There are no macro formals inside a string literal,
> just text.
> 
> From 1364-2001 section 19.3.1, "A formal argument can be used
> in the
> macro text in the same manner as an identifier."  There are no
> identifiers
> inside string literals, even if there is a sequence of
> characters that
> happens to match the name of an identifier.
> 
> Steven Sharp
> sharp@cadence.com
Received on Thu Mar 16 01:35:57 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 16 2006 - 01:36:15 PST