Skip to content

Commit 60c1b1f

Browse files
authored
Collapse all escape sequence rules into one (#743)
1 parent 6414b6c commit 60c1b1f

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

spec/message.abnf

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
message = simple-message / complex-message
22

33
simple-message = [simple-start pattern]
4-
simple-start = simple-start-char / text-escape / placeholder
5-
pattern = *(text-char / text-escape / placeholder)
4+
simple-start = simple-start-char / escaped-char / placeholder
5+
pattern = *(text-char / escaped-char / placeholder)
66
placeholder = expression / markup
77

88
complex-message = *(declaration [s]) complex-body
@@ -43,7 +43,7 @@ attribute = "@" identifier [[s] "=" [s] (literal / variable)]
4343

4444
variable = "$" name
4545
literal = quoted / unquoted
46-
quoted = "|" *(quoted-char / quoted-escape) "|"
46+
quoted = "|" *(quoted-char / escaped-char) "|"
4747
unquoted = name / number-literal
4848
; number-literal matches JSON number (https://www.rfc-editor.org/rfc/rfc8259#section-6)
4949
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
@@ -68,7 +68,7 @@ reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
6868
private-use-annotation = private-start [[s] reserved-body]
6969
private-start = "^" / "&"
7070
reserved-body = reserved-body-part *([s] reserved-body-part)
71-
reserved-body-part = reserved-char / reserved-escape / quoted
71+
reserved-body-part = reserved-char / escaped-char / quoted
7272

7373
; Names and identifiers
7474
; identifier matches https://www.w3.org/TR/REC-xml-names/#NT-QName
@@ -101,10 +101,8 @@ content-char = %x01-08 ; omit NULL (%x00), HTAB (%x09) and LF (%x0A)
101101
/ %xE000-10FFFF
102102

103103
; Character escapes
104-
text-escape = backslash ( backslash / "{" / "}" )
105-
quoted-escape = backslash ( backslash / "|" )
106-
reserved-escape = backslash ( backslash / "{" / "|" / "}" )
107-
backslash = %x5C ; U+005C REVERSE SOLIDUS "\"
104+
escaped-char = backslash ( backslash / "{" / "|" / "}" )
105+
backslash = %x5C ; U+005C REVERSE SOLIDUS "\"
108106

109107
; Whitespace
110108
s = 1*( SP / HTAB / CR / LF / %x3000 )

spec/syntax.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ An empty string is a valid _simple message_.
158158

159159
```abnf
160160
simple-message = [simple-start pattern]
161-
simple-start = simple-start-char / text-escape / placeholder
161+
simple-start = simple-start-char / escaped-char / placeholder
162162
```
163163

164164
A **_<dfn>complex message</dfn>_** is any _message_ that contains _declarations_,
@@ -264,7 +264,7 @@ Unless there is an error, resolving a _message_ always results in the formatting
264264
of a single _pattern_.
265265

266266
```abnf
267-
pattern = *(text-char / text-escape / placeholder)
267+
pattern = *(text-char / escaped-char / placeholder)
268268
```
269269
A _pattern_ MAY be empty.
270270

@@ -300,7 +300,7 @@ U+007B LEFT CURLY BRACKET `{`, and U+007D RIGHT CURLY BRACKET `}`
300300
MUST be escaped as `\\`, `\{`, and `\}` respectively.
301301
302302
In the ABNF, _text_ is represented by non-empty sequences of
303-
`simple-start-char`, `text-char`, and `text-escape`.
303+
`simple-start-char`, `text-char`, and `escaped-char`.
304304
The first of these is used at the start of a _simple message_,
305305
and matches `text-char` except for not allowing U+002E FULL STOP `.`.
306306
The ABNF uses `content-char` as a shared base for _text_ and _quoted literal_ characters.
@@ -675,7 +675,7 @@ reserved-annotation = reserved-annotation-start [[s] reserved-body]
675675
reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
676676
677677
reserved-body = reserved-body-part *([s] reserved-body-part)
678-
reserved-body-part = reserved-char / reserved-escape / quoted
678+
reserved-body-part = reserved-char / escaped-char / quoted
679679
```
680680
681681
## Markup
@@ -852,7 +852,7 @@ of number values in _operands_ or _options_, or as _keys_ for _variants_.
852852

853853
```abnf
854854
literal = quoted / unquoted
855-
quoted = "|" *(quoted-char / quoted-escape) "|"
855+
quoted = "|" *(quoted-char / escaped-char) "|"
856856
unquoted = name / number-literal
857857
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
858858
```
@@ -934,14 +934,13 @@ An **_<dfn>escape sequence</dfn>_** is a two-character sequence starting with
934934
U+005C REVERSE SOLIDUS `\`.
935935

936936
An _escape sequence_ allows the appearance of lexically meaningful characters
937-
in the body of _text_, _quoted_, or _reserved_ (which includes, in this case,
938-
_private-use_) sequences respectively:
937+
in the body of _text_, _quoted_, or _reserved_
938+
(which includes, in this case, _private-use_) sequences.
939+
Each _escape sequence_ represents the literal character immediately following the initial `\`.
939940

940941
```abnf
941-
text-escape = backslash ( backslash / "{" / "}" )
942-
quoted-escape = backslash ( backslash / "|" )
943-
reserved-escape = backslash ( backslash / "{" / "|" / "}" )
944-
backslash = %x5C ; U+005C REVERSE SOLIDUS "\"
942+
escaped-char = backslash ( backslash / "{" / "|" / "}" )
943+
backslash = %x5C ; U+005C REVERSE SOLIDUS "\"
945944
```
946945

947946
### Whitespace

0 commit comments

Comments
 (0)