RE: [sv-bc] `` macro token gluing operator

From: Steven Sharp <sharp_at_.....>
Date: Thu Jun 21 2007 - 15:29:05 PDT
>From: "Gran, Alex" <alex_gran@mentor.com>

>   So your example in
>
>	`define x \a ``b[1]
> 
>I think this should result in the escaped identifier '\ab[1] '
>Unless the right hand side token of `` needs to be a legal identifier
>prior to `` being evaluated.  Does that need to be the case?

It is a matter of how you define it.  The terms "token pasting" or
"token gluing" imply that you recognize tokens and then connect
them to create a single token.

What you are describing would be better called "token continuation".
Even then there are different ways it could be interpreted.  When
you continue consuming characters for the identifier, do you do so
in "escaped identifier mode", or has that been reset by seeing the
white space?


>  I believe
>it should be legal to have this
>
>	`define x a``1
>
>result in the identifier 'a1'
>
>  I don't think it is necessary for the right hand side of the `` to be
>legal identifier prior to evaluation.

I agree that it should be legal to do this.  But while 1 is not a
legal identifier, it is a legal token.  Since b[1] is 4 tokens when
not escaped, the two situations are not the same.  Creating 'a1' is
pasting two tokens.  Creating 'ab[1]' is pasting 5 tokens with a
single token-pasting operator.  That is, unless you tokenize the b[1]
in a mode that is continuing an escaped identifier (even though that
escaped identifier token has already been terminated with whitespace).

Note that my alternative of requiring

`define x \a ``\b[1]

takes two escaped identifier tokens and pastes them together.  Since
the \ is not part of either identifier name, you get 'ab[1]'.

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Jun 21 15:29:33 2007

This archive was generated by hypermail 2.1.8 : Thu Jun 21 2007 - 15:29:44 PDT