Skip to content

Commit bbf6880

Browse files
committed
Disallow whitespace as the first character of a reserved-body in a reserved-statement.
In the 'reserved-statement' nonterminal, there is an ambiguity if there is more than one whitespace character between the 'reserved-keyword' and the first non-whitespace character of the 'reserved-body', because these whitespace characters can be seen as part of the 's' nonterminal or as part of the 'reserved-body' nonterminal. According to the principles explained in #725 and the proposed resolution of #721, it is not desired that a 'reserved-body' starts with a whitespace character; rather, such a whitespace character is meant to be interpreted as part of the preceding 's' nonterminal. Test case: ``` .regex /foo/{xyz}{{hello}} ``` This patch removes this ambiguity, by disallowing whitespace as the first character of a 'reserved-body' in a reserved-statement. It thus fixes the first part of #721. Details: - Other occurrences of 'resolved-body' (after a 'reserved-annotation' or 'private-use-annotation') are not affected. - A new nonterminal 'resolved-body-part' is introduced, referenced twice. - A new nonterminal 'reserved-body-in-statement' is introduced, referenced once. Its purpose is to clarify that the two parts belong together. - A new nonterminal 'reserved-body-in-statement-start' is introduced, in order to follow the common *-start / *-part idiom.
1 parent 1009ea9 commit bbf6880

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

spec/message.abnf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ local = %s".local"
5454
match = %s".match"
5555

5656
; Reserve additional .keywords for use by future versions of this specification.
57-
reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
57+
reserved-statement = reserved-keyword [s reserved-body-in-statement] 1*([s] expression)
5858
; Note that the following production is a simplification,
5959
; as this rule MUST NOT be considered to match existing keywords
6060
; (`.input`, `.local`, and `.match`).
6161
reserved-keyword = "." name
62+
reserved-body-in-statement = reserved-body-in-statement-start *([s] 1*reserved-body-part)
63+
reserved-body-in-statement-start = reserved-body-part
6264

6365
; Reserve additional sigils for use by future versions of this specification.
6466
reserved-annotation = reserved-annotation-start reserved-body
@@ -67,7 +69,8 @@ reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
6769
; Reserve sigils for private-use by implementations.
6870
private-use-annotation = private-start reserved-body
6971
private-start = "^" / "&"
70-
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
72+
reserved-body = *([s] 1*reserved-body-part)
73+
reserved-body-part = reserved-char / reserved-escape / quoted
7174

7275
; Names and identifiers
7376
; identifier matches https://www.w3.org/TR/REC-xml-names/#NT-QName

spec/syntax.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ a similarly wide range of content as _reserved annotations_,
222222
but it MUST end with one or more _expressions_.
223223
224224
```abnf
225-
reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
225+
reserved-statement = reserved-keyword [s reserved-body-in-statement] 1*([s] expression)
226226
reserved-keyword = "." name
227+
reserved-body-in-statement = reserved-body-in-statement-start *([s] 1*reserved-body-part)
228+
reserved-body-in-statement-start = reserved-body-part
227229
```
228230
229231
> [!Note]
@@ -656,7 +658,8 @@ unrecognized _reserved-annotations_ or _private-use-annotations_ have no meaning
656658
reserved-annotation = reserved-annotation-start reserved-body
657659
reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
658660
659-
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
661+
reserved-body = *([s] 1*reserved-body-part)
662+
reserved-body-part = reserved-char / reserved-escape / quoted
660663
```
661664
662665
## Markup

0 commit comments

Comments
 (0)