Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 24 additions & 25 deletions spec/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ An empty string is a valid _simple message_.

```abnf
simple-message = [simple-start pattern]
simple-start = simple-start-char / text-escape / placeholder
simple-start = simple-start-char / text-escape / placeholder
```

A **_<dfn>complex message</dfn>_** is any _message_ that contains _declarations_,
Expand Down Expand Up @@ -167,7 +167,7 @@ For compatibility with later MessageFormat 2 specification versions,
_declarations_ MAY also include _reserved statements_.

```abnf
declaration = input-declaration / local-declaration / reserved-statement
declaration = input-declaration / local-declaration / reserved-statement
input-declaration = input [s] variable-expression
local-declaration = local s variable [s] "=" [s] expression
```
Expand Down Expand Up @@ -209,8 +209,8 @@ a similarly wide range of content as _reserved annotations_,
but it MUST end with one or more _expressions_.

```abnf
reserved-statement = reserved-keyword [s reserved-body] 1*expression
reserved-keyword = "." 2*(%x61-7A)
reserved-statement = reserved-keyword [s reserved-body] 1*([s] expression)
reserved-keyword = "." name
```

> [!Note]
Expand Down Expand Up @@ -289,6 +289,8 @@ be preserved during formatting.
```abnf
simple-start-char = content-char / s / "@" / "|"
text-char = content-char / s / "." / "@" / "|"
quoted-char = content-char / s / "." / "@" / "{" / "}"
reserved-char = content-char / "."
Comment on lines +292 to +293
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already listed elsewhere in syntax.md. Is there a reason to bring them here, rather than keeping them in their current places?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing this? Where are the productions doubled in @alerque's text?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quoted-char is currently under Literals right after quoted, and reserved-char under Reserved Annotations right after reserved-body. The proposed change moves their listings from those places (which are their only users) to here.

As is, their meaning is obvious from context. If they're moved here, then we should add some text here explaining what they are.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those definitions moved in the abnf source too, and I found their new/current locations much easier to grok than the old ones the syntax explanations were using because they are now grouped with more related context with other similar definitions.

If consensuses is that isn't a good change they can go back to their original places, but the abnf snippets will no longer be all blocks where the whole snippet comes from a contiguous bit of source. Having all the snippets match some contiguous bit from the original file makes it quite a bit easier to verify that it is in sync.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we do not intend to make further syntax changes, mirroring such changes in syntax.md as well as the ANBF should not need to be done later.

I have a weak preference for keeping these as they currently are, but I'm fine to go with whatever most people think.

content-char = %x00-08 ; omit HTAB (%x09) and LF (%x0A)
/ %x0B-0C ; omit CR (%x0D)
/ %x0E-19 ; omit SP (%x20)
Expand Down Expand Up @@ -346,7 +348,7 @@ satisfied:
or contain a _variable_ that directly or indirectly references a _declaration_ with an _annotation_.

```abnf
matcher = match-statement 1*([s] variant)
matcher = match-statement 1*([s] variant)
match-statement = match 1*([s] selector)
```

Expand Down Expand Up @@ -412,7 +414,7 @@ Whitespace is permitted but not required between the last _key_ and the _quoted

```abnf
variant = key *(s key) [s] quoted-pattern
key = literal / "*"
key = literal / "*"
```

#### Key
Expand Down Expand Up @@ -444,9 +446,11 @@ optionally followed by an _annotation_.
An **_<dfn>annotation-expression</dfn>_** contains an _annotation_ without an _operand_.

```abnf
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] "}"
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] "}"
```

Expand Down Expand Up @@ -605,7 +609,7 @@ A _private-use annotation_ MAY be empty after its introducing sigil.

```abnf
private-use-annotation = private-start reserved-body
private-start = "^" / "&"
private-start = "^" / "&"
```

> [!Note]
Expand Down Expand Up @@ -647,11 +651,10 @@ While a reserved sequence is technically "well-formed",
unrecognized _reserved-annotations_ or _private-use-annotations_ have no meaning.

```abnf
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))
reserved-char = content-char / "."
reserved-body = *([s] 1*(reserved-char / reserved-escape / quoted))
```

## Markup
Expand Down Expand Up @@ -785,13 +788,9 @@ A _number-literal_ uses the same syntax as JSON and is intended for the encoding
of number values in _operands_ or _options_, or as _keys_ for _variants_.

```abnf
literal = quoted / unquoted

literal = quoted / unquoted
quoted = "|" *(quoted-char / quoted-escape) "|"
quoted-char = content-char / s / "." / "@" / "{" / "}"

unquoted = name
/ number-literal
unquoted = name / number-literal
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
```

Expand Down Expand Up @@ -848,8 +847,8 @@ Support for _namespaces_ and their interpretation is implementation-defined
in this release.

```abnf
variable = "$" name
option = identifier [s] "=" [s] (literal / variable)
variable = "$" name
option = identifier [s] "=" [s] (literal / variable)

identifier = [namespace ":"] name
namespace = name
Expand All @@ -873,10 +872,10 @@ in the body of _text_, _quoted_, or _reserved_ (which includes, in this case,
_private-use_) sequences respectively:

```abnf
text-escape = backslash ( backslash / "{" / "}" )
quoted-escape = backslash ( backslash / "|" )
reserve-escape = backslash ( backslash / "{" / "|" / "}" )
backslash = %x5C ; U+005C REVERSE SOLIDUS "\"
text-escape = backslash ( backslash / "{" / "}" )
quoted-escape = backslash ( backslash / "|" )
reserved-escape = backslash ( backslash / "{" / "|" / "}" )
backslash = %x5C ; U+005C REVERSE SOLIDUS "\"
```

### Whitespace
Expand Down