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:
auto w = x"1e1d 1e1f"w;
on dmd 2.047
but what it results in is pretty screwy.
So, to correct the documentation, the "postfix" needs to be removed from
HexString and added to DelimitedString and TokenString.
I tried to see if this was already reporded in the bug tracker but
couldn't see anything close.
On a slightly quieter note, there is also a spare underscore in the
definition of HexidecimalDigit as it "extends" DecimalDigit which
already has an underscore.
I also noticed a bug in the tracker related to initial underscores in
float literals, if the diagrams start getting to puzzling I might look
into that ^^
What what?
A...
PS, my copy of tDPL is in the post, yay!