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

From: Feldman, Yulik <yulik.feldman_at_.....>
Date: Sun Feb 12 2006 - 00:43:37 PST
Hi,

 

I'm not sure how to interpret the LRM on whether the white space at the
end of macro text should become a part of the substituted macro text at
the location of the macro usage, or whether it should be removed.

 

Consider the following macro definition and macro usage:

 

`define kuku 1   

a = `kuku;

 

The macro "kuku" contains 3 spaces at the end of the line before the
new-line character. Should the result of the macro substitution be "a =
1;" or "a = 1   ;"?

 

The section "19.3.1 `define" of IEEE P1364-2005 says: "The first newline
not preceded by a backslash shall end the macro text.". This may be
interpreted as if the white space should be preserved, but it is not
clear whether this description refers just to the general definition of
where the macro definition ends or it indeed defines whether the white
space should be preserved or not.

 

Consider a slightly different example, with a one-line comment following
the macro text:

 

`define kuku_with_comment 2   // comment

a = `kuku_with_comment;

 

According to the LRM, the comment should be removed, but nothing is said
on whether the white space preceding the comment should be removed or
not. 

 

There are situations when the presence or absence of the white space at
the end of the substituted text may be important. Consider the
following, more complex, example:

 

`define kuku 1   

`define kuku_with_comment 2   // comment

 

`define mod(arg1,arg2) \

(* foo = "AA``arg1BB``arg2" *) \

module a(); \

endmodule

 

`mod(`kuku,`kuku_with_comment)

 

Should the final value of the attribute be "AA1BB2" or "AA1   BB2   "?
From the design perspective, it is advantageous that the language
requires the removal of the trailing spaces in both cases, to allow
building strings/names as in the example above. Note that it is
especially important to remove the trailing spaces in the case with the
comment, since, if the spaces are not removed, it makes it impossible to
define a macro with a comment that doesn't have a white space at the end
of its substituted text. 

 

--Yulik.

 
Received on Sun, 12 Feb 2006 10:43:37 +0200

This archive was generated by hypermail 2.1.8 : Sun Feb 12 2006 - 00:44:26 PST