Skip to content

Commit 104160f

Browse files
committed
[lex.string] Adopt character-string grammer to simplify string literals
There are several places in the grammar where we want to refer to a plain character string literal without a prefix and that is not raw. Introduce _character-string_ into the grammar to replace a quoted _s-char-sequence_in a number of places, and move the `R` of a raw string literal into the _raw-string_ grammar so that _raw-string_ and _character-string_ are used consistently where they appear.
1 parent ecf79f7 commit 104160f

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

source/lex.tex

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@
614614
parenthesis is identified. The raw string literal is defined as the shortest sequence
615615
of characters that matches the raw-string pattern
616616
\begin{ncbnf}
617-
\opt{encoding-prefix} \terminal{R} raw-string
617+
\opt{encoding-prefix} raw-string
618618
\end{ncbnf}
619619

620620
\item Otherwise, if the next three characters are \tcode{<::} and the subsequent character
@@ -1800,8 +1800,13 @@
18001800
\indextext{literal!string}%
18011801
\begin{bnf}
18021802
\nontermdef{string-literal}\br
1803-
\opt{encoding-prefix} \terminal{"} \opt{s-char-sequence} \terminal{"}\br
1804-
\opt{encoding-prefix} \terminal{R} raw-string
1803+
\opt{encoding-prefix} character-string\br
1804+
\opt{encoding-prefix} raw-string
1805+
\end{bnf}
1806+
1807+
\begin{bnf}
1808+
\nontermdef{character-string}\br
1809+
\terminal{"} \opt{s-char-sequence} \terminal{"}
18051810
\end{bnf}
18061811

18071812
\begin{bnf}
@@ -1824,7 +1829,7 @@
18241829

18251830
\begin{bnf}
18261831
\nontermdef{raw-string}\br
1827-
\terminal{"} \opt{d-char-sequence} \terminal{(} \opt{r-char-sequence} \terminal{)} \opt{d-char-sequence} \terminal{"}
1832+
\terminal{R} \terminal{"} \opt{d-char-sequence} \terminal{(} \opt{r-char-sequence} \terminal{)} \opt{d-char-sequence} \terminal{"}
18281833
\end{bnf}
18291834

18301835
\begin{bnf}
@@ -2111,12 +2116,10 @@
21112116

21122117
\begin{bnf}
21132118
\nontermdef{unevaluated-string}\br
2114-
string-literal
2119+
character-string\br
2120+
raw-string
21152121
\end{bnf}
21162122

2117-
\pnum
2118-
An \grammarterm{unevaluated-string} shall have no \grammarterm{encoding-prefix}.
2119-
21202123
\pnum
21212124
Each \grammarterm{universal-character-name} and each \grammarterm{simple-escape-sequence} in an \grammarterm{unevaluated-string} is
21222125
replaced by the member of the translation character set it denotes.

source/preprocessor.tex

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@
18051805
token in the replacement list.
18061806

18071807
\pnum
1808-
A \defn{character string literal} is a \grammarterm{string-literal} with no prefix.
1808+
A \defn{character string literal} is a \grammarterm{characeter-string}.
18091809
If, in the replacement list, a parameter is immediately
18101810
preceded by a
18111811
\tcode{\#}
@@ -2070,12 +2070,6 @@
20702070
\indextext{preprocessing directive!line control}%
20712071
\indextext{\idxcode{\#line}|see{preprocessing directive, line control}}
20722072

2073-
\pnum
2074-
The \grammarterm{string-literal} of a
2075-
\tcode{\#line}
2076-
directive, if present,
2077-
shall be a character string literal\iref{cpp.stringize}.
2078-
20792073
\pnum
20802074
The
20812075
\defn{line number}
@@ -2102,11 +2096,11 @@
21022096
\pnum
21032097
A preprocessing directive of the form
21042098
\begin{ncsimplebnf}
2105-
\terminal{\# line} digit-sequence \terminal{"} \opt{string-literal} \terminal{"} new-line
2099+
\terminal{\# line} digit-sequence character-string new-line
21062100
\end{ncsimplebnf}
21072101
sets the presumed line number similarly and changes the
21082102
presumed name of the source file to be the contents
2109-
of the character string literal.
2103+
of the \grammarterm{character-string}.
21102104

21112105
\pnum
21122106
A preprocessing directive of the form

0 commit comments

Comments
 (0)