Skip to content

Make option values optional, defaulting to true #502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion spec/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ the following steps are taken:
and use a _fallback value_ for the _expression_.
3. Resolve the _option_ values to a mapping of string identifiers to values.
For each _option_:
- If its right-hand side successfully resolves to a value,
- If the _option_ contains no value,
bind the _name_ of the _option_ to the character sequence `true`.
- Else, if its right-hand side successfully resolves to a value,
bind the _name_ of the _option_ to the resolved value in the mapping.
- Otherwise, do not bind the _name_ of the _option_ to any value in the mapping.
4. Call the function implementation with the following arguments:
Expand Down
3 changes: 2 additions & 1 deletion spec/message.abnf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ annotation = (function *(s option)) / reserved / private-use
literal = quoted / unquoted
variable = "$" name
function = (":" / "+" / "-") name
option = name [s] "=" [s] (literal / variable)
option = name [option-value]
option-value = [s] "=" [s] (literal / variable)

; reserved keywords are always lowercase
Copy link
Member

Choose a reason for hiding this comment

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

We should reserve the keyword true if this goes in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think that would be required? The resolved value of a un-valued option doesn't actually show up in the syntax.

input = %x69.6E.70.75.74 ; "input"
Expand Down
16 changes: 10 additions & 6 deletions spec/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,19 @@ _Options_ are not required.
An **_<dfn>option</dfn>_** is a key-value pair
containing a named argument that is passed to a _function_.

An _option_ has a _name_ and a _value_.
The _name_ is separated from the _value_ by an U+003D EQUALS SIGN `=` along with
An _option_ has a _name_ and optionally a _value_.
An _option_ without a _value_ has the literal value `true`.

If an _option_ has a _value_,
it is separated from the _name_ by an U+003D EQUALS SIGN `=` along with
optional whitespace.
The value of an _option_ can be either a _literal_ or a _variable_.
The _value_ of an _option_ can be either a _literal_ or a _variable_.

Multiple _options_ are permitted in an _annotation_.
Each _option_ is separated by whitespace.

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

> Examples of _functions_ with _options_
Expand All @@ -492,10 +495,11 @@ option = name [s] "=" [s] (literal / variable)

> A _message_ with a `$userName` _variable_ formatted with
> the custom `:person` _function_ capable of
> declension (using either a fixed dictionary, algorithmic declension, ML, etc.):
> declension (using either a fixed dictionary, algorithmic declension, ML, etc.),
> as well as capitalization:
>
> ```
> {Hello, {$userName :person case=vocative}!}
> Hello, {$userName :person case=vocative capitalized}!
> ```

> A _message_ with a `$userObj` _variable_ formatted with
Expand Down