You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arawstringliteralconsistsofarbitrarytextandnewlinesbetweenmulti-`"`-sequence delimiters (which better supports the readability of XML, JSON, and other forms of text that have some visually pleasing structure). A raw string literal may span multiple lines.
910
+
909
911
```ANTLR
910
912
String_Literal
911
913
:Regular_String_Literal
912
914
|Verbatim_String_Literal
915
+
|Raw_String_Literal
913
916
;
914
917
915
918
fragmentRegular_String_Literal
@@ -944,8 +947,59 @@ fragment Single_Verbatim_String_Literal_Character
For brevity, a *Raw_String_Literal_Delimiter* is referred to as a “delimiter,” the start *Raw_String_Literal_Delimiter* is referred to as the “start delimiter,” and the end *Raw_String_Literal_Delimiter* is referred to as the “end delimiter.”
978
+
979
+
For any *Raw_String_Literal*:
980
+
981
+
- A delimiter shall be the longest set of contiguous `"` characters found at the start or end. The number of `"` characters in a delimiter is called the ***raw string literal delimiter length***.
982
+
> *Example*: The string `""" """` is well-formed; it has 3-character start and end delimiters, and its content is a single space. However, the string `""""""` is ill-formed, as it is seen as a 6-character start delimiter, with no content, and no end delimiter, not as 3-character start and end delimiters and empty content. *end example*
983
+
- The beginning and end delimiters shall have the same raw string literal delimiter length.
984
+
> *Example*: The string `""""X""""` is well-formed; it has 4-character start and end delimiters. However, the strings `"""X""""` and `""""X"""` are ill-formed, as the start and end delimiters in each pair do not have the same length. *end example*
985
+
- A *Raw_String_Literal Content* shall not contain a set of contiguous `"` characters whose length is equal to or greater than the raw string literal delimiter length.
986
+
> *Example*: The strings `"""" """ """"` and `""""""" """""" """"" """" """ """""""`are well-formed. However, the strings `""" """ """` and `""" """" """` are ill-formed. *end example*
987
+
- As text sequences that have the form of *Comment*s are not processed within string literals ([§6.3.3](lexical-structure.md#633-comments)), they appear verbatim in their corresponding *Raw_String_Literal Content*.
988
+
989
+
For a *Single_Line_Raw_String_Literal* only:
990
+
991
+
- A *Single_Line_Raw_String_Literal* cannot be empty; it must contain at least one character.
992
+
- A *Raw_String_Literal Content* cannot begin with `"`, as such a character is considered to belong to the preceding start delimiter. Similarly, a *Raw_String_Literal Content* cannot end with `"`, as such a character is considered to belong to the following end delimiter.
993
+
- The value of the literal is *Raw_String_Literal Content*, which can contain leading, embedded, and trailing horizontal whitespace (as in `"""x x x"""` and `""" xxx """`, the latter having a leading space and trailing tabs).
994
+
995
+
For a *Multi_Line_Raw_String_Literal* only:
996
+
997
+
- If *Whitespace* precedes the end delimiter on the same line, the exact number and kind of whitespace characters (e.g., spaces vs. tabs) shall exist at the beginning of each *Raw_String_Literal Content*, and that leading whitespace shall be discarded from those *Raw_String_Literal Content*s.
998
+
- A *Raw_String_Literal Content* shall not appear on the same line as a start or end delimiter.
999
+
- A *Multi_Line_Raw_String_Literal* can be empty (by having no *Raw_String_Literal Content*s and one or more *New_Line*s).
1000
+
- A *Raw_String_Literal Content* can begin or end with `"`.
1001
+
- The value of the literal is the lexical concatenation of all of its *Raw_String_Literal Content*s and *New_Lines* after any whitespace at the beginning of each *Raw_String_Literal Content* has been discarded based on whitespace preceding the ending delimiter. Whitespace following the start delimiter and preceding the end delimiter are not included.
0 commit comments