diff --git a/spec/data-model/README.md b/spec/data-model/README.md index 3577f72dbf..f65df5e4a7 100644 --- a/spec/data-model/README.md +++ b/spec/data-model/README.md @@ -117,28 +117,33 @@ The `body` strings are the "cooked" _text_ values, i.e. escape sequences are pro Implementations MUST NOT rely on the set of `Expression` interfaces being exhaustive, as future versions of this specification MAY define additional expressions. -An `Expression` `func` with an unrecognized value SHOULD be treated as an `UnsupportedExpression` value. ```ts interface Pattern { body: Array; } -type Expression = LiteralExpression | VariableExpression | FunctionExpression; +type Expression = LiteralExpression | VariableExpression | FunctionExpression | + UnsupportedExpression; interface LiteralExpression { arg: Literal; - func?: FunctionRef | UnsupportedExpression; + annotation?: FunctionAnnotation | UnsupportedAnnotation; } interface VariableExpression { arg: VariableRef; - func?: FunctionRef | UnsupportedExpression; + annotation?: FunctionAnnotation | UnsupportedAnnotation; } interface FunctionExpression { arg?: never; - func: FunctionRef | UnsupportedExpression; + annotation: FunctionAnnotation; +} + +interface UnsupportedExpression { + arg?: never; + annotation: UnsupportedAnnotation; } ``` @@ -166,22 +171,19 @@ interface VariableRef { } ``` -A `FunctionRef` represents an _expression_ with a _function_ _annotation_. -In a `FunctionRef`, +A `FunctionAnnotation` represents a _function_ _annotation_. +In a `FunctionAnnotation`, the `kind` corresponds to the starting sigil of a _function_: `'open'` for `+`, `'close'` for `-`, and `'value'` for `:`. The `name` does not include this starting sigil. -The optional `operand` is the _literal_ or _variable_ -before the _annotation_ in the _expression_, if present. Each _option_ is represented by an `Option`. ```ts -interface FunctionRef { +interface FunctionAnnotation { type: "function"; kind: "open" | "close" | "value"; name: string; - operand?: Literal | VariableRef; options?: Option[]; } @@ -191,9 +193,8 @@ interface Option { } ``` -An `UnsupportedExpression` represents an _expression_ with a -_reserved annotation_ or a _private-use annotation_ not supported -by the implementation. +An `UnsupportedAnnotation` represents a +_private-use annotation_ not supported by the implementation or a _reserved annotation_. The `sigil` corresponds to the starting sigil of the _annotation_. The `source` is the "raw" value (i.e. escape sequences are not processed) and does not include the starting `sigil`. @@ -204,9 +205,6 @@ and does not include the starting `sigil`. > This would result in new interfaces being added to > this data model. -If the _expression_ includes a _literal_ or _variable_ before the _annotation_, -it is included as the `operand`. - When parsing the syntax of a _message_ that includes a _private-use annotation_ supported by the implementation, the implementation SHOULD represent it in the data model @@ -214,11 +212,10 @@ using an interface appropriate for the semantics and meaning that the implementation attaches to that _annotation_. ```ts -interface UnsupportedExpression { - type: "unsupported-expression"; +interface UnsupportedAnnotation { + type: "unsupported-annotation"; sigil: "!" | "@" | "#" | "%" | "^" | "&" | "*" | "<" | ">" | "/" | "?" | "~"; source: string; - operand?: Literal | VariableRef; } ``` diff --git a/spec/data-model/message.dtd b/spec/data-model/message.dtd index 5f1810f39b..2a6df759db 100644 --- a/spec/data-model/message.dtd +++ b/spec/data-model/message.dtd @@ -24,8 +24,8 @@ @@ -34,13 +34,13 @@ - - + - - + + diff --git a/spec/data-model/message.json b/spec/data-model/message.json index 4b6c154ffd..acce03ffcb 100644 --- a/spec/data-model/message.json +++ b/spec/data-model/message.json @@ -22,11 +22,18 @@ }, "required": ["type", "name"] }, - "value": { - "oneOf": [{ "$ref": "#/$defs/literal" }, { "$ref": "#/$defs/variable" }] + "option": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "value": { + "oneOf": [{ "$ref": "#/$defs/literal" }, { "$ref": "#/$defs/variable" }] + } + }, + "required": ["name", "value"] }, - "function": { + "function-annotation": { "type": "object", "properties": { "type": { "const": "function" }, @@ -34,24 +41,17 @@ "name": { "type": "string" }, "options": { "type": "array", - "items": { - "type": "object", - "properties": { - "name": { "type": "string" }, - "value": { "$ref": "#/$defs/value" } - }, - "required": ["name", "value"] - } + "items": { "$ref": "#/$defs/option" } } }, "required": ["type", "kind", "name"] }, - "unsupported-expression": { + "unsupported-annotation": { "type": "object", "properties": { - "type": { "const": "unsupported-expression" }, + "type": { "const": "unsupported-annotation" }, "sigil": { - "enum": ["!", "@", "#", "%", "^", "&", "*", "<", ">", "?", "~"] + "enum": ["!", "@", "#", "%", "^", "&", "*", "<", ">", "/", "?", "~"] }, "source": { "type": "string" } }, @@ -59,8 +59,8 @@ }, "annotation": { "oneOf": [ - { "$ref": "#/$defs/function" }, - { "$ref": "#/$defs/unsupported-expression" } + { "$ref": "#/$defs/function-annotation" }, + { "$ref": "#/$defs/unsupported-annotation" } ] }, @@ -68,7 +68,7 @@ "type": "object", "properties": { "arg": { "$ref": "#/$defs/literal" }, - "func": { "$ref": "#/$defs/annotation" } + "annotation": { "$ref": "#/$defs/annotation" } }, "required": ["arg"] }, @@ -76,22 +76,30 @@ "type": "object", "properties": { "arg": { "$ref": "#/$defs/variable" }, - "func": { "$ref": "#/$defs/annotation" } + "annotation": { "$ref": "#/$defs/annotation" } }, "required": ["arg"] }, "function-expression": { "type": "object", "properties": { - "func": { "$ref": "#/$defs/annotation" } + "annotation": { "$ref": "#/$defs/function-annotation" } }, - "required": ["func"] + "required": ["annotation"] + }, + "unsupported-expression": { + "type": "object", + "properties": { + "annotation": { "$ref": "#/$defs/unsupported-annotation" } + }, + "required": ["annotation"] }, "expression": { "oneOf": [ { "$ref": "#/$defs/literal-expression" }, { "$ref": "#/$defs/variable-expression" }, - { "$ref": "#/$defs/function-expression" } + { "$ref": "#/$defs/function-expression" }, + { "$ref": "#/$defs/unsupported-expression" } ] }, diff --git a/spec/message.abnf b/spec/message.abnf index bd7dbeb8eb..8d6950d2cc 100644 --- a/spec/message.abnf +++ b/spec/message.abnf @@ -19,13 +19,13 @@ selector = expression variant = key *(s key) [s] quoted-pattern key = literal / "*" -expression = literal-expression / variable-expression / function-expression +expression = literal-expression / variable-expression / annotation-expression literal-expression = "{" [s] literal [s annotation] [s] "}" variable-expression = "{" [s] variable [s annotation] [s] "}" -function-expression = "{" [s] annotation [s] "}" +annotation-expression = "{" [s] annotation [s] "}" annotation = (function *(s option)) - / reserved-annotation / private-use-annotation + / reserved-annotation literal = quoted / unquoted variable = "$" name diff --git a/spec/syntax.md b/spec/syntax.md index cf34de5570..e4ce167bb7 100644 --- a/spec/syntax.md +++ b/spec/syntax.md @@ -431,13 +431,13 @@ optionally followed by an _annotation_. A **_variable-expression_** contains a _variable_, optionally followed by an _annotation_. -A **_function-expression_** contains only an _annotation_. +An **_annotation-expression_** contains an _annotation_ without an _operand_. ```abnf -expression = literal-expression / variable-expression / function-expression +expression = literal-expression / variable-expression / annotation-expression literal-expression = "{" [s] literal [s annotation] [s] "}" variable-expression = "{" [s] variable [s annotation] [s] "}" -function-expression = "{" [s] annotation [s] "}" +annotation-expression = "{" [s] annotation [s] "}" ``` There are several types of _expression_ that can appear in a _message_. @@ -476,12 +476,12 @@ Additionally, an _input-declaration_ can contain a _variable-expression_. An **_annotation_** is part of an _expression_ containing either a _function_ together with its associated _options_, or -a _reserved annotation_ or a _private-use annotation_. +a _private-use annotation_ or a _reserved annotation_. ```abnf annotation = (function *(s option)) - / reserved-annotation / private-use-annotation + / reserved-annotation ``` An **_operand_** is the _literal_ of a _literal-expression_ or