8000 Add content-char as common root of simple-start-char, text-char, quot… · unicode-org/message-format-wg@1c62834 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c62834

Browse files
authored
Add content-char as common root of simple-start-char, text-char, quoted-char & reserved-char (#562)
* Add content-char as common root of simple-start-char, text-char, quoted-char & reserved-char * Add brief mention of content-char in syntax.md * Move content-char definition under its users
1 parent 258d49a commit 1c62834

File tree

2 files changed

+33
-47
lines changed

2 files changed

+33
-47
lines changed

spec/message.abnf

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ markup-open = "#" identifier *(s option)
3535
markup-close = "/" identifier
3636

3737
literal = quoted / unquoted
38+
quoted = "|" *(quoted-char / quoted-escape) "|"
39+
unquoted = name / number-literal
3840
variable = "$" name
3941
function = ":" identifier *(s option)
4042
option = identifier [s] "=" [s] (literal / variable)
@@ -44,26 +46,6 @@ input = %s".input"
4446
local = %s".local"
4547
match = %s".match"
4648

47-
simple-start-char = %x0-2D ; omit .
48-
/ %x2F-5B ; omit \
49-
/ %x5D-7A ; omit {
50-
/ %x7C ; omit }
51-
/ %x7E-D7FF ; omit surrogates
52-
/ %xE000-10FFFF
53-
text-char = simple-start-char / "."
54-
55-
quoted = "|" *(quoted-char / quoted-escape) "|"
56-
quoted-char = %x0-5B ; omit \
57-
/ %x5D-7B ; omit |
58-
/ %x7D-D7FF ; omit surrogates
59-
/ %xE000-10FFFF
60-
61-
unquoted = name
62-
/ number-literal
63-
; number-literal matches JSON number
64-
; https://www.rfc-editor.org/rfc/rfc8259#section-6
65-
number-literal = ["-"] (0 / ([1-9] *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
66-
6749
; Reserve additional .keywords for use by future versions of this specification.
6850
reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
6951
; Note that the following expression is a simplification,
@@ -75,21 +57,16 @@ reserved-keyword = "." name
7557
reserved-annotation = reserved-annotation-start reserved-body
7658
reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
7759

78-
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
79-
reserved-char = %x00-08 ; omit HTAB and LF
80-
/ %x0B-0C ; omit CR
81-
/ %x0E-19 ; omit SP
82-
/ %x21-3F ; omit @
83-
/ %x41-5B ; omit \
84-
/ %x5D-7A ; omit { | }
85-
/ %x7E-2FFF ; omit IDEOGRAPHIC SPACE
86-
/ %x3001-D7FF ; omit surrogates
87-
/ %xE000-10FFFF
60+
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
8861

8962
; Reserve sigils for private-use by implementations.
9063
private-use-annotation = private-start reserved-body
9164
private-start = "^" / "&"
9265

66+
; number-literal matches JSON number
67+
; https://www.rfc-editor.org/rfc/rfc8259#section-6
68+
number-literal = ["-"] (0 / ([1-9] *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
69+
9370
; identifier matches https://www.w3.org/TR/REC-xml-names/#NT-QName
9471
; name matches https://www.w3.org/TR/REC-xml-names/#NT-NCName
9572
identifier = [namespace ":"] name
@@ -103,6 +80,20 @@ name-start = ALPHA / "_"
10380
name-char = name-start / DIGIT / "-" / "."
10481
/ %xB7 / %x300-36F / %x203F-2040
10582

83+
simple-start-char = content-char / s / "@" / "|"
84+
text-char = content-char / s / "." / "@" / "|"
85+
quoted-char = content-char / s / "." / "@" / "{" / "}"
86+
reserved-char = content-char / "."
87+
content-char = %x00-08 ; omit HTAB (%x09) and LF (%x0A)
88+
/ %x0B-0C ; omit CR (%x0D)
89+
/ %x0E-19 ; omit SP (%x20)
90+
/ %x21-2D ; omit . (%x2E)
91+
/ %x2F-3F ; omit @ (%x40)
92+
/ %x41-5B ; omit \ (%x5C)
93+
/ %x5D-7A ; omit { | } (%x7B-7D)
94+
/ %x7E-D7FF ; omit surrogates
95+
/ %xE000-10FFFF
96+
10697
text-escape = backslash ( backslash / "{" / "}" )
10798
quoted-escape = backslash ( backslash / "|" )
10899
reserved-escape = backslash ( backslash / "{" / "|" / "}" )

spec/syntax.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,23 @@ In the ABNF, _text_ is represented by non-empty sequences of
281281
`simple-start-char`, `text-char`, and `text-escape`.
282282
The first of these is used at the start of a _simple message_,
283283
and matches `text-char` except for not allowing U+002E FULL STOP `.`.
284+
The ABNF uses `content-char` as a shared base for _text_ and _quoted literal_ characters.
284285
285286
Whitespace in _text_, including tabs, spaces, and newlines is significant and MUST
286287
be preserved during formatting.
287288
288289
```abnf
289-
simple-start-char = %x0-2D ; omit .
290-
/ %x2F-5B ; omit \
291-
/ %x5D-7A ; omit {
292-
/ %x7C ; omit }
290+
simple-start-char = content-char / s / "@" / "|"
291+
text-char = content-char / s / "." / "@" / "|"
292+
content-char = %x00-08 ; omit HTAB (%x09) and LF (%x0A)
293+
/ %x0B-0C ; omit CR (%x0D)
294+
/ %x0E-19 ; omit SP (%x20)
295+
/ %x21-2D ; omit . (%x2E)
296+
/ %x2F-3F ; omit @ (%x40)
297+
/ %x41-5B ; omit \ (%x5C)
298+
/ %x5D-7A ; omit { | } (%x7B-7D)
293299
/ %x7E-D7FF ; omit surrogates
294300
/ %xE000-10FFFF
295-
text-char = simple-start-char / "."
296301
```
297302
298303
When a _pattern_ is quoted by embedding the _pattern_ in curly brackets, the
@@ -646,14 +651,7 @@ reserved-annotation = reserved-annotation-start reserved-body
646651
reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
647652
648653
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
649-
reserved-char = %x00-08 ; omit HTAB and LF
650-
/ %x0B-0C ; omit CR
651-
/ %x0E-19 ; omit SP
652-
/ %x21-3F ; omit @
653-
/ %x41-5B ; omit \
654-
/ %x5D-7A ; omit { | }
655-
/ %x7E-D7FF ; omit surrogates
656-
/ %xE000-10FFFF
654+
reserved-char = content-char / "."
657655
```
658656
659657
## Markup
@@ -787,10 +785,7 @@ of number values in _operands_ or _options_, or as _keys_ for _variants_.
787785
literal = quoted / unquoted
788786
789787
quoted = "|" *(quoted-char / quoted-escape) "|"
790-
quoted-char = %x0-5B ; omit \
791-
/ %x5D-7B ; omit |
792-
/ %x7D-D7FF ; omit surrogates
793-
/ %xE000-10FFFF
788+
quoted-char = content-char / s / "." / "@" / "{" / "}"
794789
795790
unquoted = name
796791
/ number-literal

0 commit comments

Comments
 (0)
0