From 5ec8d62749ac097123edbc30ad03ef4e995f0888 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 23 Jan 2024 07:41:08 -0800 Subject: [PATCH 1/5] Beautify the ABNF As we lock down the ABNF, start to fix spacing and alignment. In this PR all of the changes are editorial. Note that I have moved a few of the productions in an attempt to organize items more logically. I have also added comments for individual blocks. --- spec/message.abnf | 82 ++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/spec/message.abnf b/spec/message.abnf index 978ab5263c..7370202618 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -1,47 +1,56 @@ -message = simple-message / complex-message +message = simple-message / complex-message simple-message = [simple-start pattern] -simple-start = simple-start-char / text-escape / placeholder -pattern = *(text-char / text-escape / placeholder) -placeholder = expression / markup +simple-start = simple-start-char / text-escape / placeholder +pattern = *(text-char / text-escape / placeholder) +placeholder = expression / markup + +complex-message = *(declaration [s]) complex-body +declaration = input-declaration / local-declaration / reserved-statement +complex-body = quoted-pattern / matcher -complex-message = *(declaration [s]) complex-body -declaration = input-declaration / local-declaration / reserved-statement input-declaration = input [s] variable-expression local-declaration = local s variable [s] "=" [s] expression -complex-body = quoted-pattern / matcher -quoted-pattern = "{{" pattern "}}" +quoted-pattern = "{{" pattern "}}" -matcher = match-statement 1*([s] variant) +matcher = match-statement 1*([s] variant) match-statement = match 1*([s] selector) -selector = expression -variant = key *(s key) [s] quoted-pattern -key = literal / "*" - -expression = literal-expression - / variable-expression - / annotation-expression -literal-expression = "{" [s] literal [s annotation] *(s attribute) [s] "}" -variable-expression = "{" [s] variable [s annotation] *(s attribute) [s] "}" +selector = expression +variant = key *(s key) [s] quoted-pattern +key = literal / "*" + +; Expressions +expression = literal-expression + / variable-expression + / annotation-expression +literal-expression = "{" [s] literal [s annotation] *(s attribute) [s] "}" +variable-expression = "{" [s] variable [s annotation] *(s attribute) [s] "}" annotation-expression = "{" [s] annotation *(s attribute) [s] "}" -annotation = function - / private-use-annotation - / reserved-annotation +annotation = function + / private-use-annotation + / reserved-annotation + +; Markup. Note that standalone markup is part of the markup = "{" [s] markup-open *(s attribute) [s] ["/"] "}" / "{" [s] markup-close *(s attribute) [s] "}" markup-open = "#" identifier *(s option) markup-close = "/" identifier -literal = quoted / unquoted -quoted = "|" *(quoted-char / quoted-escape) "|" -unquoted = name / number-literal -variable = "$" name -function = ":" identifier *(s option) -option = identifier [s] "=" [s] (literal / variable) -attribute = "@" identifier [[s] "=" [s] (literal / variable)] +; Expression and literal parts +literal = quoted / unquoted +quoted = "|" *(quoted-char / quoted-escape) "|" +unquoted = name / number-literal +variable = "$" name +function = ":" identifier *(s option) +option = identifier [s] "=" [s] (literal / variable) +; Attributes are reserved for future standardization +attribute = "@" identifier [[s] "=" [s] (literal / variable)] +; number-literal matches JSON number (https://www.rfc-editor.org/rfc/rfc8259#section-6) +number-literal = ["-"] (0 / ([1-9] *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT] +; Keywords; Note that these are case-sensitive input = %s".input" local = %s".local" match = %s".match" @@ -51,21 +60,18 @@ reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression) ; Note that the following expression is a simplification, ; as this rule MUST NOT be considered to match existing keywords ; (`.input`, `.local`, and `.match`). -reserved-keyword = "." name +reserved-keyword = "." name ; Reserve additional sigils for use by future versions of this specification. -reserved-annotation = reserved-annotation-start reserved-body +reserved-annotation = reserved-annotation-start reserved-body reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~" -reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted)) - ; Reserve sigils for private-use by implementations. -private-use-annotation = private-start reserved-body -private-start = "^" / "&" +private-use-annotation = private-start reserved-body +private-start = "^" / "&" -; number-literal matches JSON number -; https://www.rfc-editor.org/rfc/rfc8259#section-6 -number-literal = ["-"] (0 / ([1-9] *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT] +; The body of a private-use or reserved annotation is highly permissive +reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted)) ; identifier matches https://www.w3.org/TR/REC-xml-names/#NT-QName ; name matches https://www.w3.org/TR/REC-xml-names/#NT-NCName @@ -80,6 +86,7 @@ name-start = ALPHA / "_" name-char = name-start / DIGIT / "-" / "." / %xB7 / %x300-36F / %x203F-2040 +; Restrictions on characters in various contexts simple-start-char = content-char / s / "@" / "|" text-char = content-char / s / "." / "@" / "|" quoted-char = content-char / s / "." / "@" / "{" / "}" @@ -99,4 +106,5 @@ quoted-escape = backslash ( backslash / "|" ) reserved-escape = backslash ( backslash / "{" / "|" / "}" ) backslash = %x5C ; U+005C REVERSE SOLIDUS "\" +; Whitespace s = 1*( SP / HTAB / CR / LF / %x3000 ) From ffaff4f4e0b62b2abf082636c9cab8f6df3f143c Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 23 Jan 2024 07:42:50 -0800 Subject: [PATCH 2/5] A few more block alignments --- spec/message.abnf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/message.abnf b/spec/message.abnf index 7370202618..44da8ca21d 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -1,9 +1,9 @@ -message = simple-message / complex-message +message = simple-message / complex-message -simple-message = [simple-start pattern] -simple-start = simple-start-char / text-escape / placeholder -pattern = *(text-char / text-escape / placeholder) -placeholder = expression / markup +simple-message = [simple-start pattern] +simple-start = simple-start-char / text-escape / placeholder +pattern = *(text-char / text-escape / placeholder) +placeholder = expression / markup complex-message = *(declaration [s]) complex-body declaration = input-declaration / local-declaration / reserved-statement @@ -14,11 +14,11 @@ local-declaration = local s variable [s] "=" [s] expression quoted-pattern = "{{" pattern "}}" -matcher = match-statement 1*([s] variant) -match-statement = match 1*([s] selector) -selector = expression -variant = key *(s key) [s] quoted-pattern -key = literal / "*" +matcher = match-statement 1*([s] variant) +match-statement = match 1*([s] selector) +selector = expression +variant = key *(s key) [s] quoted-pattern +key = literal / "*" ; Expressions expression = literal-expression From 9417fb5bf734d38f5bdd6d3e8eae6a84924e1a64 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 23 Jan 2024 07:44:17 -0800 Subject: [PATCH 3/5] Fix markup note --- spec/message.abnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/message.abnf b/spec/message.abnf index 44da8ca21d..994d34dbb6 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -32,7 +32,7 @@ annotation = function / private-use-annotation / reserved-annotation -; Markup. Note that standalone markup is part of the +; Markup. Note that standalone markup is part of the first line markup = "{" [s] markup-open *(s attribute) [s] ["/"] "}" / "{" [s] markup-close *(s attribute) [s] "}" markup-open = "#" identifier *(s option) From 73c517000765bc78d606b8599999af4447265d45 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 23 Jan 2024 07:47:07 -0800 Subject: [PATCH 4/5] ... and a final tidy... --- spec/message.abnf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/message.abnf b/spec/message.abnf index 994d34dbb6..c098d204bd 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -32,7 +32,7 @@ annotation = function / private-use-annotation / reserved-annotation -; Markup. Note that standalone markup is part of the first line +; Markup; Note that standalone markup is part of the first line markup = "{" [s] markup-open *(s attribute) [s] ["/"] "}" / "{" [s] markup-close *(s attribute) [s] "}" markup-open = "#" identifier *(s option) @@ -57,7 +57,7 @@ match = %s".match" ; Reserve additional .keywords for use by future versions of this specification. reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression) -; Note that the following expression is a simplification, +; Note that the following production is a simplification, ; as this rule MUST NOT be considered to match existing keywords ; (`.input`, `.local`, and `.match`). reserved-keyword = "." name @@ -69,10 +69,9 @@ reserved-annotation-start = "!" / "%" / "*" / "+" / "<" / ">" / "?" / "~" ; Reserve sigils for private-use by implementations. private-use-annotation = private-start reserved-body private-start = "^" / "&" - -; The body of a private-use or reserved annotation is highly permissive reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted)) +; Names and identifiers ; identifier matches https://www.w3.org/TR/REC-xml-names/#NT-QName ; name matches https://www.w3.org/TR/REC-xml-names/#NT-NCName identifier = [namespace ":"] name @@ -101,6 +100,7 @@ content-char = %x00-08 ; omit HTAB (%x09) and LF (%x0A) / %x7E-D7FF ; omit surrogates / %xE000-10FFFF +; Character escapes text-escape = backslash ( backslash / "{" / "}" ) quoted-escape = backslash ( backslash / "|" ) reserved-escape = backslash ( backslash / "{" / "|" / "}" ) From 85464bb0d528f93a9c4dec14633faa28fdded05f Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 23 Jan 2024 10:36:15 -0800 Subject: [PATCH 5/5] Minor reordering per comment --- spec/message.abnf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/message.abnf b/spec/message.abnf index c098d204bd..1c4488b2c1 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -39,14 +39,15 @@ markup-open = "#" identifier *(s option) markup-close = "/" identifier ; Expression and literal parts -literal = quoted / unquoted -quoted = "|" *(quoted-char / quoted-escape) "|" -unquoted = name / number-literal -variable = "$" name function = ":" identifier *(s option) option = identifier [s] "=" [s] (literal / variable) ; Attributes are reserved for future standardization attribute = "@" identifier [[s] "=" [s] (literal / variable)] + +variable = "$" name +literal = quoted / unquoted +quoted = "|" *(quoted-char / quoted-escape) "|" +unquoted = name / number-literal ; number-literal matches JSON number (https://www.rfc-editor.org/rfc/rfc8259#section-6) number-literal = ["-"] (0 / ([1-9] *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]