Thiago Adams <
thiago...@gmail.com> writes:
> On Friday, July 15, 2022 at 5:12:09 PM UTC-3, Philipp Klaus Krause wrote:
>> Am 15.07.22 um 22:06 schrieb Lew Pitcher:
>> >
>> > 0xfe-BAD is a valid hexadecimal floating point constant,
>> > ((f) (e-BAD) or (15 times 10 to the power of -2989))
>> > and the lexer is required to interpret it as such ("maximal munch").
>> >
>> > You /should/ get an error on the "(3)" portion of the statement, though.
>> >
>> It is a valid preprocessing-number, not a valid hexadecimal
>> floating-point constant. So I get the error for both (though later, not
>> at preprocessing time).
>
> I think to be valid ppnumber "-BAD" must be " identifier-continue"
> that is "universal-character-name of class XID_Continue"
No, "-BAD" is not a valid pp-number.
> identifier-continue
> digit
> nondigit
> universal-character-name of class XID_Continue
>
> pp-number:
> digit
> . digit
> pp-number identifier-continue
> pp-number ’ digit
> pp-number ’ nondigit
> pp-number e sign
> pp-number E sign
> pp-number p sign
> pp-number P sign
> pp-number .
You must be looking at a recent draft of the standard.
In C11 and C17, "identifier-continue" is called "identifier-nondigit".
It's an underscore or any of the 62 uppercase or lowercase letters (or a
universal-character-name or other implementation-defined character, but
those don't come into play here).
(In the following, 'e' and 'p' can be lower or upper case.)
"-BAD" is not a pp-number, since a pp-number can't start with a sign.
Any sign must follow an 'e' or 'p' (i.e., be part of an exponent). (A sign
applied to a numeric constant is not part of the constant; it's a
separate unary minus operator.)
"0xfe-BAD" is not a valid hexadecimal floating constant. They use 'p',
'e' to introduce the exponent, since 'e' is a valid hex digit.
But "0xfe-BAD" is a valid pp-number. It consists of:
- '0', a digit
- 'x', 'f', both identifier-nondigits
- 'e' followed by a sign '-'
- 'B', 'A', 'D', all identifier-nondigits
pp-numbers encompass all integer and floating-point constants, in all
supported bases, with or without suffixes like "ULL". They also include
a lot of things that aren't valid tokens, basically to make the
preprocessor's job easier. If a pp-number can't be converted to a valid
token, which is the case here, it's a syntax error.
The apparent ambiguity (the 'e' could be either an identifier-nondigit
or the first character of an "e sign" sequence) is resolved in favor of
the longest sequence.
If the input stream has been parsed into preprocessing tokens up to
a given character, the next preprocessing token is the longest
sequence of characters that could constitute a preprocessing token.
--
Keith Thompson (The_Other_Keith)
Keith.S.T...@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */