Skip to content

Specification refactor "v2" #441

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

Merged
merged 26 commits into from
Aug 7, 2023
Merged

Conversation

aphillips
Copy link
Member

This is the second attempt at the specification refactoring. I started with all of our PRs merged Monday.

This is a much more significant reformulation. It is intended to be read as prose as well as specifying individual productions.

I organized the sections "top down", with some sub-sections containing others, e.g.:

Message

Declarations

Body

Pattern

Matcher

Selector

Variant

Key

There is then a set of productions about Expressions and then finally the remaining terms, such as keywords, whitespace, and such. You might wish to view this rendered first rather than diving into the diff specifically.


I have followed commentary about separating "abstract" vs. "concrete" (e.g. in #440). This proposal embraces the use of ABNF constructs whose purpose is "abstract". We don't have to do this. We can define terms in the spec that do not appear in the ABNF. E.g.:

A placeholder refers to any expression that appears inside of a pattern.

(and then use expression in the ABNF exclusively), a la:

pattern = "{" 1* (text / expression) "}"

This PR does not include a repaired TOC and I have not yet removed the requirements to elsewhere. I moved some examples to the end, with an intention of moving them out altogether.

Have a read. 📚

Copy link
Collaborator

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

This reads much better than the previous update. I found it easier to evaluate as a whole, here: https://github.com/unicode-org/message-format-wg/blob/aphillips-specification-refactor/spec/syntax.md

Comments below from a first pass; I may have more thoughts on this later. Not sure if I noticed all the small changes that are applied here.

spec/syntax.md Outdated
Comment on lines 262 to 263
* The number of _keys_ on each _variant_ MUST be equal to the number of _selectors_.
* At least one _variant_ MUST exist whose _keys_ are all equal to the "catch-all" key `*`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Running Prettier on this will replace the * with - and add a space before the list. Might be easier to just use its styling for markdown?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good callout and one for the style guide.

spec/syntax.md Outdated
Comment on lines 406 to 407
A **_function_** is a used to evaluate, format, select, or otherwise process an _operand_,
or, if lacking an _operand_, its _options_.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This implies that a function with an operand does not care about its options, and that a function without an operand requires options. The previous reference to processing its annotation was really clumsy, but less incorrect.

This sentence should probably be completely refactored.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this sentence doesn't make sense as written. Refactored this section.

spec/syntax.md Outdated
Comment on lines 614 to 615
> **Note**
> _External variables_ names are constrained by this namespace.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Strictly speaking not true. Anything not fitting name just won't be matched by any variable in the message.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct. I ran into this issue when drafting this section and it occurred to me that we needed to deal with the fact that name is constrained but callers will not be constrained. I'll refactor this sentence to be correct, but it is the formatting spec that needs instructions on handling of external variables, which I recorded in #442.

spec/syntax.md Outdated
>```


> Expression examples:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you have a place in mind for these expression examples, and/or a reason why not to include them in this doc?

Copy link
Member Author

Choose a reason for hiding this comment

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

Along with "complex messages", I just pushed them out of the way for the nonce. I'm reluctant to delete them without looking more closely at the expression section. I'll refactor these into the text.

aphillips and others added 6 commits July 28, 2023 08:37
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
@aphillips aphillips requested a review from eemeli July 28, 2023 16:37
Copy link
Collaborator

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

  1. We should drop the ToC. It requires unnecessary manual maintenance, and it's replicating built-in functionality that GitHub provides for rendered markdown via the outline button at the far right of the Preview/Code/Blame toolbar.

  2. I think adding the <dfn> tags is jumping the gun. We do ultimately need to transform our spec format to whatever is required for the UTS/UTR format that we'll be publishing it in, but it'll be just as easy for automation to then find the definitions as <b><i>...</i></b> compared to <b><i><dfn>...</dfn></i></b>. But if adding it, see line comments fixing a few mistakes.

Comment on lines +412 to +418
A _function_'s entry in the _function registry_ will define
whether the _function_ is a _selector_ or formatter (or both),
whether an _operand_ is required,
what form the values of an _operand_ can take,
what _options_ and _option_ values are valid,
and what outputs might result.
See [function registry](./) for more information.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this description of the function registry embedded here in the syntax spec? Also, won't we eventually be making the _function registry_ a link to the relevant part of the spec, so shouldn't need an explicit markdown link as well?

aphillips and others added 3 commits July 30, 2023 07:55
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
aphillips and others added 3 commits July 30, 2023 08:25
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
Co-authored-by: Eemeli Aro <eemeli@mozilla.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants