String Literal Docs

div0 div0 at users.sourceforge.net
Sat Jun 19 14:26:44 PDT 2010


On 19/06/2010 22:16, Ellery Newcomer wrote:
> On 06/19/2010 03:12 PM, Alix Pexton wrote:
>> I've been sketching some grammar diagrams for D2.0, a little like those
>> on JSON.org, and of course I didn't get far before I ran into something
>> odd.
>>
>> In the section of www.digitalmars.com/d/2.0/lex.html on string literals,
>> the productions imply that the [c|w|d] "postfix" is allowed on Wysiwyg,
>> DoubleQuote and Hex strings and not on either Delimited or Token
>> strings, which didn't make a lot of sense to me, so I tested it with DMD
>> (v2.046, win)...
>>
>> ---
>>
>> import std.stdio;
>>
>> void main(){
>> auto t1 = "double quote"d; // OK
>> auto t2 = `back tick`d; // OK
>> auto t3 = x"dead beef"; // postfix not allowed on hexstrings!
>> auto t4 = q"<delimited/>"d;// OK
>> auto t5 = q{if}d; // OK
>>
>> writefln("all literals A-OK!");
>> }
>>
>> ---
>>
>> This makes sense to me, HexStrings with wide chars would have made my
>> brain scream ><
>
>
> http://d.puremagic.com/issues/show_bug.cgi?id=4351
>
>
> but I'm not so sure about the hex string one. I think you just gave it
> invalid unicode. E.g., this compiles fine:

Hex strings are specifically exempted from the requirement for valid utf.


-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


More information about the Digitalmars-d mailing list