Skip to content

Commit 20a61b4

Browse files
authored
Disallow whitespace as the first character of a reserved-body in a reserved-statement. (#731)
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: - In the other occurrences of 'resolved-body' as well (in a 'reserved-annotation' or 'private-use-annotation') the leading whitespace is separated as well. This has no influence on the set of inputs that the 'reserved-annotation' and 'private-use-annotation' nonterminals can match, but highlights that the parser should better trim off this leading whitespace in these places before entering the resolved-body into the data model. - A nonterminal 'resolved-body-part' is introduced.
1 parent 6d7b4ba commit 20a61b4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

spec/message.abnf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
6161
reserved-keyword = "." name
6262

6363
; Reserve additional sigils for use by future versions of this specification.
64-
reserved-annotation = reserved-annotation-start reserved-body
64+
reserved-annotation = reserved-annotation-start [[s] reserved-body]
6565
reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
6666

6767
; Reserve sigils for private-use by implementations.
68-
private-use-annotation = private-start reserved-body
68+
private-use-annotation = private-start [[s] reserved-body]
6969
private-start = "^" / "&"
70-
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
70+
reserved-body = reserved-body-part *([s] reserved-body-part)
71+
reserved-body-part = reserved-char / reserved-escape / quoted
7172

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

spec/syntax.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ wish to use a syntax exactly like other functions. Specifically:
610610
A _private-use annotation_ MAY be empty after its introducing sigil.
611611
612612
```abnf
613-
private-use-annotation = private-start reserved-body
613+
private-use-annotation = private-start [[s] reserved-body]
614614
private-start = "^" / "&"
615615
```
616616
@@ -653,10 +653,11 @@ While a reserved sequence is technically "well-formed",
653653
unrecognized _reserved-annotations_ or _private-use-annotations_ have no meaning.
654654
655655
```abnf
656-
reserved-annotation = reserved-annotation-start reserved-body
656+
reserved-annotation = reserved-annotation-start [[s] reserved-body]
657657
reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~"
658658
659-
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
659+
reserved-body = reserved-body-part *([s] reserved-body-part)
660+
reserved-body-part = reserved-char / reserved-escape / quoted
660661
```
661662
662663
## Markup

0 commit comments

Comments
 (0)