Skip to content

Commit e418a4e

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 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-trimmed' is introduced, referenced once. Its purpose is to clarify that the two parts ('reserved-body-part' and 'reserved-body') belong together.
1 parent afc7ff8 commit e418a4e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

spec/message.abnf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ 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-trimmed] 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-trimmed = reserved-body-part reserved-body
6263

6364
; Reserve additional sigils for use by future versions of this specification.
6465
reserved-annotation = reserved-annotation-start reserved-body
@@ -67,7 +68,8 @@ reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
6768
; Reserve sigils for private-use by implementations.
6869
private-use-annotation = private-start reserved-body
6970
private-start = "^" / "&"
70-
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
71+
reserved-body = *([s] 1*reserved-body-part)
72+
reserved-body-part = reserved-char / reserved-escape / quoted
7173

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

spec/syntax.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ 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-trimmed] 1*([s] expression)
226226
reserved-keyword = "." name
227+
reserved-body-trimmed = reserved-body-part reserved-body
227228
```
228229
229230
> [!Note]
@@ -655,7 +656,8 @@ unrecognized _reserved-annotations_ or _private-use-annotations_ have no meaning
655656
reserved-annotation = reserved-annotation-start reserved-body
656657
reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
657658
658-
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
659+
reserved-body = *([s] 1*reserved-body-part)
660+
reserved-body-part = reserved-char / reserved-escape / quoted
659661
```
660662
661663
## Markup

0 commit comments

Comments
 (0)