Skip to content

Commit 3f35bee

Browse files
eemeligibson042
andauthored
Implement code more introducer (#529)
* Add .keywords to ABNF * Consider all messages starting with . as complex * Rename text-start as simple-start-char, drop text, fix whitespace Co-authored-by: Richard Gibson <richard.gibson@gmail.com> * Rename reserved-declaration as reserved-syntax * Rename & group reserved syntax rules together * Fix typo * Rename reserved-keyword as reserved-statement * Apply suggestions from code review * Drop \. escapes * Add reserved-keyword to reserved-statement * Apply suggestions from code review Co-authored-by: Richard Gibson <richard.gibson@gmail.com> --------- Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
1 parent 1409c6d commit 3f35bee

File tree

1 file changed

+38
-28
lines changed

1 file changed

+38
-28
lines changed

spec/message.abnf

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
1-
message = pattern / complex-message
1+
message = simple-message / complex-message
22

3-
complex-message = "{{" [s] *(declaration [s]) body [s] "}}"
3+
simple-message = [simple-start pattern]
4+
simple-start = simple-start-char / text-escape / expression
5+
pattern = *(text-char / text-escape / expression)
46

5-
declaration = input-declaration / local-declaration
7+
complex-message = *(declaration [s]) complex-body
8+
declaration = input-declaration / local-declaration / reserved-statement
69
input-declaration = input [s] variable-expression
710
local-declaration = local s variable [s] "=" [s] expression
811

9-
body = quoted-pattern
10-
/ (selectors 1*([s] variant))
11-
12+
complex-body = quoted-pattern
13+
/ ((selectors / reserved-statement) 1*([s] variant))
1214
quoted-pattern = "{{" pattern "}}"
13-
pattern = *(text / expression)
15+
1416
selectors = match 1*([s] expression)
15-
variant = when 1*(s key) [s] quoted-pattern
17+
variant = key *(s key) [s] quoted-pattern
1618
key = literal / "*"
1719

1820
expression = literal-expression / variable-expression / function-expression
1921
literal-expression = "{" [s] literal [s annotation] [s] "}"
2022
variable-expression = "{" [s] variable [s annotation] [s] "}"
2123
function-expression = "{" [s] annotation [s] "}"
22-
annotation = (function *(s option)) / reserved / private-use
24+
annotation = (function *(s option))
25+
/ reserved-annotation
26+
/ private-use-annotation
2327

2428
literal = quoted / unquoted
2529
variable = "$" name
2630
function = (":" / "+" / "-") identifier
2731
option = identifier [s] "=" [s] (literal / variable)
2832

29-
; reserved keywords are always lowercase
30-
input = %s"input"
31-
local = %s"local"
32-
match = %s"match"
33-
when = %s"when"
33+
input = %s".input"
34+
local = %s".local"
35+
match = %s".match"
3436

35-
text = 1*(text-char / text-escape)
36-
text-char = %x0-5B ; omit \
37-
/ %x5D-7A ; omit {
38-
/ %x7C ; omit }
39-
/ %x7E-D7FF ; omit surrogates
40-
/ %xE000-10FFFF
37+
simple-start-char = %x0-2D ; omit .
38+
/ %x2F-5B ; omit \
39+
/ %x5D-7A ; omit {
40+
/ %x7C ; omit }
41+
/ %x7E-D7FF ; omit surrogates
42+
/ %xE000-10FFFF
43+
text-char = simple-start-char / "."
4144

4245
quoted = "|" *(quoted-char / quoted-escape) "|"
4346
quoted-char = %x0-5B ; omit \
@@ -49,16 +52,19 @@ unquoted = unquoted-start *(name-char / ":")
4952
unquoted-start = name-start / DIGIT / "."
5053
/ %xB7 / %x300-36F / %x203F-2040
5154

52-
; reserve sigils for private-use by implementations
53-
private-use = private-start reserved-body
54-
private-start = "^" / "&"
55+
; Reserve additional .keywords for use by future versions of this specification.
56+
reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
57+
; Note that the following expression is a simplification,
58+
; as this rule MUST NOT be considered to match existing keywords
59+
; (`.input`, `.local`, and `.match`).
60+
reserved-keyword = "." name
5561

56-
; reserve additional sigils for use by
57-
; future versions of this specification
58-
reserved = reserved-start reserved-body
59-
reserved-start = "!" / "@" / "#" / "%" / "*" / "<" / ">" / "/" / "?" / "~"
60-
reserved-body = *( [s] 1*(reserved-char / reserved-escape / quoted))
62+
; Reserve additional sigils for use by future versions of this specification.
63+
reserved-annotation = reserved-annotation-start reserved-body
64+
reserved-annotation-start = "!" / "@" / "#" / "%" / "*"
65+
/ "<" / ">" / "/" / "?" / "~"
6166

67+
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
6268
reserved-char = %x00-08 ; omit HTAB and LF
6369
/ %x0B-0C ; omit CR
6470
/ %x0E-19 ; omit SP
@@ -67,6 +73,10 @@ reserved-char = %x00-08 ; omit HTAB and LF
6773
/ %x7E-D7FF ; omit surrogates
6874
/ %xE000-10FFFF
6975

76+
; Reserve sigils for private-use by implementations.
77+
private-use-annotation = private-start reserved-body
78+
private-start = "^" / "&"
79+
7080
; identifier matches https://www.w3.org/TR/REC-xml-names/#NT-QName
7181
; name matches https://www.w3.org/TR/REC-xml-names/#NT-NCName
7282
identifier = [namespace ":"] name

0 commit comments

Comments
 (0)