Skip to content

Commit f9fb5f8

Browse files
authored
Merge pull request #2190 from wilzbach/hexstrings
Partially revert removing hex strings from the doc and just mark it as deprecated for now merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
2 parents ac13af3 + 38ac37c commit f9fb5f8

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

spec/lex.dd

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,18 @@ $(GNAME EscapeSequence):
321321
$(D \U) $(GLINK HexDigit) $(GLINK HexDigit) $(GLINK HexDigit) $(GLINK HexDigit) $(GLINK HexDigit) $(GLINK HexDigit) $(GLINK HexDigit) $(GLINK HexDigit)
322322
$(D \) $(GLINK2 entity, NamedCharacterEntity)
323323

324+
$(GNAME HexString):
325+
$(D x") $(GLINK HexStringChars) $(D ") $(GLINK StringPostfix)$(OPT)
326+
327+
$(GNAME HexStringChars):
328+
$(GLINK HexStringChar)
329+
$(GLINK HexStringChar) $(I HexStringChars)
330+
331+
$(GNAME HexStringChar):
332+
$(GLINK HexDigit)
333+
$(GLINK WhiteSpace)
334+
$(GLINK EndOfLine)
335+
324336
$(GNAME StringPostfix):
325337
$(B c)
326338
$(B w)
@@ -389,6 +401,23 @@ $(H3 $(LNAME2 double_quoted_strings, Double Quoted Strings))
389401
// 'a', 'b', and a linefeed
390402
---
391403

404+
$(H3 $(LNAME2 hex_strings, Hex Strings))
405+
406+
$(P Hex strings allow string literals to be created using hex data.
407+
The hex data need not form valid UTF characters.
408+
)
409+
410+
$(D_CODE
411+
x"0A" // same as "\x0A"
412+
x"00 FBCD 32FD 0A" // same as
413+
// "\x00\xFB\xCD\x32\xFD\x0A"
414+
)
415+
416+
$(P Whitespace and newlines are ignored, so the hex data can be easily
417+
formatted. The number of hex characters must be a multiple of 2.)
418+
419+
$(P Note: Hex Strings are $(B deprecated). Please use $(REF hexString, std,conv) instead.)
420+
392421
$(H3 $(LNAME2 delimited_strings, Delimited Strings))
393422

394423
$(P Delimited strings use various forms of delimiters.
@@ -683,6 +712,10 @@ $(GNAME HexLetter):
683712
by a $(SINGLEQUOTE 0b) or $(SINGLEQUOTE 0B).
684713
)
685714

715+
$(P C-style octal integer notation was deemed too easy to mix up with decimal notation;
716+
it is only fully supported in string literals.
717+
D still supports octal integer literals interpreted at compile time through the $(REF octal, std,conv)
718+
template, as in $(D octal!167).)
686719
$(P Hexadecimal integers are a sequence of hexadecimal digits preceded
687720
by a $(SINGLEQUOTE 0x) or $(SINGLEQUOTE 0X).
688721
)

0 commit comments

Comments
 (0)