| Thread overview | |||||
|---|---|---|---|---|---|
|
October 28, 2016 exercise - find invalid D tokens (Impossible ?) | ||||
|---|---|---|---|---|
| ||||
Here are the specifications of token strings:
"Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. The { and }"
So we can deduce that any invalid D token inside a token string will lead to a compilation error. Indeed:
void main()
{
enum s = q{#}; // malformed special token sequence
}
produces an error.
So are you able to find more invalid token ?
| ||||
October 28, 2016 Re: exercise - find invalid D tokens (Impossible ?) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Basile B. | On Friday, 28 October 2016 at 05:16:45 UTC, Basile B. wrote:
> Here are the specifications of token strings:
>
> "Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. The { and }"
>
> So we can deduce that any invalid D token inside a token string will lead to a compilation error. Indeed:
>
> void main()
> {
> enum s = q{#}; // malformed special token sequence
> }
>
> produces an error.
>
> So are you able to find more invalid token ?
Try '}'
| |||
October 28, 2016 Re: exercise - find invalid D tokens (Impossible ?) | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | On Friday, 28 October 2016 at 06:21:38 UTC, Johan Engelen wrote: > On Friday, 28 October 2016 at 05:16:45 UTC, Basile B. wrote: >> Here are the specifications of token strings: >> >> "Token strings open with the characters q{ and close with the token }. In between must be valid D tokens. The { and }" >> >> So we can deduce that any invalid D token inside a token string will lead to a compilation error. Indeed: >> >> void main() >> { >> enum s = q{#}; // malformed special token sequence >> } >> >> produces an error. >> >> So are you able to find more invalid token ? > > Try '}' Yes and many others. Since I've posted this message I've realized that actually there are much invalid tokens. Any character that's not an Universal Alpha and that's not in a string prevents compilation. A complete list is at page 451 in http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply