Skip to content

Commit 51c4357

Browse files
committed
[lex.string] Adopt plain-string-literal grammar 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 2648f0b commit 51c4357

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
@@ -613,7 +613,7 @@
613613
parenthesis is identified. The raw string literal is defined as the shortest sequence
614614
of characters that matches the raw-string pattern
615615
\begin{ncbnf}
616-
\opt{encoding-prefix} \terminal{R} raw-string
616+
\opt{encoding-prefix} raw-string
617617
\end{ncbnf}
618618

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

18061811
\begin{bnf}
@@ -1823,7 +1828,7 @@
18231828

18241829
\begin{bnf}
18251830
\nontermdef{raw-string}\br
1826-
\terminal{"} \opt{d-char-sequence} \terminal{(} \opt{r-char-sequence} \terminal{)} \opt{d-char-sequence} \terminal{"}
1831+
\terminal{R} \terminal{"} \opt{d-char-sequence} \terminal{(} \opt{r-char-sequence} \terminal{)} \opt{d-char-sequence} \terminal{"}
18271832
\end{bnf}
18281833

18291834
\begin{bnf}
@@ -2110,12 +2115,10 @@
21102115

21112116
\begin{bnf}
21122117
\nontermdef{unevaluated-string}\br
2113-
string-literal
2118+
plain-string-literal\br
2119+
raw-string
21142120
\end{bnf}
21152121

2116-
\pnum
2117-
An \grammarterm{unevaluated-string} shall have no \grammarterm{encoding-prefix}.
2118-
21192122
\pnum
21202123
Each \grammarterm{universal-character-name} and each \grammarterm{simple-escape-sequence} in an \grammarterm{unevaluated-string} is
21212124
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{plain-string-literal}.
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 plain-string-literal 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{plain-string-literal}.
21102104

21112105
\pnum
21122106
A preprocessing directive of the form

0 commit comments

Comments
 (0)