Skip to content

Commit 16996d3

Browse files
committed
Allow name-char as first character of unquoted-literal
1 parent 08b6612 commit 16996d3

File tree

8 files changed

+31
-43
lines changed

8 files changed

+31
-43
lines changed

spec/functions/datetime.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,7 @@ and what format to use for that field.
7474
> [!NOTE] > _Field options_ do not have default values because they are only to be used
7575
> to compose the formatter.
7676
77-
The _field options_ are defined as follows:
78-
79-
> [!IMPORTANT]
80-
> The value `2-digit` for some _field options_ MUST be quoted
81-
> in the MessageFormat syntax because it starts with a digit
82-
> but does not match the `number-literal` production in the ABNF.
83-
>
84-
> ```
85-
> .local $correct = {$someDate :datetime year=|2-digit|}
86-
> .local $syntaxError = {$someDate :datetime year=2-digit}
87-
> ```
88-
89-
The function `:datetime` has the following options:
77+
The function `:datetime` has the following _field options_:
9078

9179
- `weekday`
9280
- `long`

spec/functions/number.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,13 @@ Implementations MUST NOT substitute the unit without performing the associated c
655655
### Number Operands
656656
657657
The _operand_ of a number function is either an implementation-defined type or
658-
a literal whose contents match the `number-literal` production in the [ABNF](/spec/message.abnf).
658+
a literal whose contents match the following `number-literal` production.
659659
All other values produce a _Bad Operand_ error.
660660
661+
```abnf
662+
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT]
663+
```
664+
661665
> For example, in Java, any subclass of `java.lang.Number` plus the primitive
662666
> types (`byte`, `short`, `int`, `long`, `float`, `double`, etc.)
663667
> might be considered as the "implementation-defined numeric types".
@@ -667,7 +671,7 @@ All other values produce a _Bad Operand_ error.
667671
> [!NOTE]
668672
> String values passed as variables in the _formatting context_'s
669673
> _input mapping_ can be formatted as numeric values as long as their
670-
> contents match the `number-literal` production in the [ABNF](/spec/message.abnf).
674+
> contents match the `number-literal` production.
671675
>
672676
> For example, if the value of the variable `num` were the string
673677
> `-1234.567`, it would behave identically to the local

spec/message.abnf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ variable = "$" name
4141

4242
literal = quoted-literal / unquoted-literal
4343
quoted-literal = "|" *(quoted-char / escaped-char) "|"
44-
unquoted-literal = name / number-literal
45-
; number-literal matches JSON number (https://www.rfc-editor.org/rfc/rfc8259#section-6)
46-
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
44+
unquoted-literal = 1*name-char
4745

4846
; Keywords; Note that these are case-sensitive
4947
input = %s".input"

spec/syntax.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,19 +735,17 @@ escaped as `\\` and `\|`.
735735
An **_<dfn>unquoted literal</dfn>_** is a _literal_ that does not require the `|`
736736
quotes around it to be distinct from the rest of the _message_ syntax.
737737
An _unquoted literal_ MAY be used when the content of the _literal_
738-
contains no whitespace and otherwise matches the `unquoted` production.
738+
contains no whitespace and otherwise matches the `unquoted-literal` production.
739739
Implementations MUST NOT distinguish between _quoted literals_ and _unquoted literals_
740740
that have the same sequence of code points.
741741

742-
_Unquoted literals_ can contain a _name_ or consist of a _number-literal_.
743-
A _number-literal_ uses the same syntax as JSON and is intended for the encoding
744-
of number values in _operands_ or _options_, or as _keys_ for _variants_.
742+
_Unquoted literals_ can contain any characters also valid in _name_,
743+
but with none of its additional restrictions on its first character.
745744

746745
```abnf
747746
literal = quoted-literal / unquoted-literal
748747
quoted-literal = "|" *(quoted-char / escaped-char) "|"
749-
unquoted-literal = name / number-literal
750-
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
748+
unquoted-literal = 1*name-char
751749
```
752750

753751
### Names and Identifiers

test/tests/functions/datetime.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"src": "{|2006-01-02T15:04:06| :datetime}"
4646
},
4747
{
48-
"src": "{|2006-01-02T15:04:06| :datetime year=numeric month=|2-digit|}"
48+
"src": "{|2006-01-02T15:04:06| :datetime year=numeric month=2-digit}"
4949
},
5050
{
5151
"src": "{|2006-01-02T15:04:06| :datetime dateStyle=long}"

test/tests/functions/integer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"exp": "hello -4"
1717
},
1818
{
19-
"src": "hello {0.42e+1 :integer}",
20-
"exp": "hello 4"
19+
"src": "hello {0.42 :integer}",
20+
"exp": "hello 0"
2121
},
2222
{
2323
"src": ".input {$foo :integer} .match $foo 1 {{=1}} * {{other}}",

test/tests/functions/number.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"exp": "hello -4.2"
1717
},
1818
{
19-
"src": "hello {0.42e+1 :number}",
20-
"exp": "hello 4.2"
19+
"src": "hello {0.42 :number}",
20+
"exp": "hello 0.42"
2121
},
2222
{
2323
"src": "hello {foo :number}",

test/tests/syntax.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -421,72 +421,72 @@
421421
]
422422
},
423423
{
424-
"description": "... literal -> quoted-literal -> \"|\" \"|\" ...",
424+
"description": "... quoted-literal",
425425
"src": "{||}",
426426
"exp": ""
427427
},
428428
{
429-
"description": "... quoted-literal -> \"|\" quoted-char \"|\"",
429+
"description": "... quoted-literal",
430430
"src": "{|a|}",
431431
"exp": "a"
432432
},
433433
{
434-
"description": "... quoted-literal -> \"|\" escaped-char \"|\"",
434+
"description": "... quoted-literal",
435435
"src": "{|\\\\|}",
436436
"exp": "\\"
437437
},
438438
{
439-
"description": "... quoted-literal -> \"|\" quoted-char 1*escaped-char \"|\"",
439+
"description": "... quoted-literal",
440440
"src": "{|a\\\\\\{\\|\\}|}",
441441
"exp": "a\\{|}"
442442
},
443443
{
444-
"description": "... unquoted-literal -> number-literal -> %x30",
444+
"description": "... unquoted-literal",
445445
"src": "{0}",
446446
"exp": "0"
447447
},
448448
{
449-
"description": "... unquoted-literal -> number-literal -> \"-\" %x30",
449+
"description": "... unquoted-literal",
450450
"src": "{-0}",
451451
"exp": "-0"
452452
},
453453
{
454-
"description": "... unquoted-literal -> number-literal -> (%x31-39 *DIGIT) -> %x31",
454+
"description": "... unquoted-literal",
455455
"src": "{1}",
456456
"exp": "1"
457457
},
458458
{
459-
"description": "... unquoted-literal -> number-literal -> (%x31-39 *DIGIT) -> %x31 DIGIT -> 11",
459+
"description": "... unquoted-literal",
460460
"src": "{11}",
461461
"exp": "11"
462462
},
463463
{
464-
"description": "... unquoted-literal -> number-literal -> %x30 \".\" 1*DIGIT -> 0 \".\" 1",
464+
"description": "... unquoted-literal",
465465
"src": "{0.1}",
466466
"exp": "0.1"
467467
},
468468
{
469-
"description": "... unquoted-literal -> number-literal -> %x30 \".\" 1*DIGIT -> %x30 \".\" DIGIT DIGIT -> 0 \".\" 1 2",
469+
"description": "... unquoted-literal",
470470
"src": "{0.12}",
471471
"exp": "0.12"
472472
},
473473
{
474-
"description": "... unquoted-literal -> number-literal -> %x30 %i\"e\" 1*DIGIT -> %x30 \"e\" DIGIT",
474+
"description": "... unquoted-literal",
475475
"src": "{0e1}",
476476
"exp": "0e1"
477477
},
478478
{
479-
"description": "... unquoted-literal -> number-literal -> %x30 %i\"e\" 1*DIGIT -> %x30 \"E\" DIGIT",
479+
"description": "... unquoted-literal",
480480
"src": "{0E1}",
481481
"exp": "0E1"
482482
},
483483
{
484-
"description": "... unquoted-literal -> number-literal -> %x30 %i\"e\" \"-\" 1*DIGIT ...",
484+
"description": "... unquoted-literal",
485485
"src": "{0E-1}",
486486
"exp": "0E-1"
487487
},
488488
{
489-
"description": "... unquoted-literal -> number-literal -> %x30 %i\"e\" \"+\" 1*DIGIT ...",
489+
"description": "... unquoted-literal",
490490
"src": "{0E-1}",
491491
"exp": "0E-1"
492492
},

0 commit comments

Comments
 (0)