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

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Sun Mar 19 2006 - 05:31:37 PST
Hi,

> -----Original Message-----
> From: Steven Sharp [mailto:sharp@cadence.com]
> Sent: Friday, March 17, 2006 4:18 AM
> To: sharp@cadence.com; 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>
> 
> >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.
> 
> Yes.

[Shalom] Note that there are two types of expansion: substitution of
actual arguments into formal arguments, and expansion of macro calls of
previously defined macros.
The text seems to talk only about expansion of arguments, leaving fuzzy
whether the same applies to macro calls as well.
It should be explicit.


> >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.
> 
> I assume you meant `" here, instead of \".

[Shalom] Oops. Yes.


> This appears to be a re-stating of Rule 1.  String literals and
> text in
> quotation marks are the same thing.  Is there something
> additional
> that you were trying to say with Rule 2?

[Shalom] You're correct. Rule 2 was trying to emphasize that you can use
" without a preceding apostrophe and the " will be preserved and treated
as the beginning (or end) of a string literal. 

That's not as trivial as it sounds. 1800 says,
"An `" ... indicates that the expansion should include an actual
quotation mark." That sounds like it says that a plain " will not cause
"an actual quotation mark" to be included.


> >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.
> 
> Yes.  The `" (not \") is a sort of "delayed quote".  You do
> expansion
> as if it were not a quote, but then at the end you turn it into
> a quote
> and everything that is now inside quotes is considered a string
> literal.
> As Greg said, you have to re-tokenize the macro text after the
> expansion.
> Things that were identifiers may have become part of a string
> literal
> (due to `") or part of a larger identifier (due to ``).
> 
> > (What happens if " is followed by \" or the reverse?)
> 
> If " is followed by `", then the `" would just be two
> characters in a
> string literal.

[Shalom] Wouldn't the tic be the last character in a string literal and
the " end the literal?

 
> >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?
> 
> I don't think so.  The LRM only says they can be used in macro
> text.

[Shalom] True. But when I substitute the arguments, they become part of
the text. It should be stated explicitly.

Thanks,
Shalom
Received on Sun Mar 19 05:31:51 2006

This archive was generated by hypermail 2.1.8 : Sun Mar 19 2006 - 05:31:57 PST