Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e9cb6d

Browse files
eemeliaphillips
andauthored
Allow name-char as first character of unquoted-literal (#990)
* Allow name-char as first character of unquoted-literal * Add exponents back in number-literal * Update spec/syntax.md Co-authored-by: Addison Phillips <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent 12ffb9b commit 3e9cb6d

File tree

8 files changed

+37
-41
lines changed

8 files changed

+37
-41
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
@@ -597,9 +597,13 @@ Implementations MUST NOT substitute the unit without performing the associated c
597597
### Number Operands
598598
599599
The _operand_ of a number function is either an implementation-defined type or
600-
a literal whose contents match the `number-literal` production in the [ABNF](/spec/message.abnf).
600+
a literal whose contents match the following `number-literal` production.
601601
All other values produce a _Bad Operand_ error.
602602
603+
```abnf
604+
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
605+
```
606+
603607
> For example, in Java, any subclass of `java.lang.Number` plus the primitive
604608
> types (`byte`, `short`, `int`, `long`, `float`, `double`, etc.)
605609
> might be considered as the "implementation-defined numeric types".
@@ -609,7 +613,7 @@ All other values produce a _Bad Operand_ error.
609613
> [!NOTE]
610614
> String values passed as variables in the _formatting context_'s
611615
> _input mapping_ can be formatted as numeric values as long as their
612-
> contents match the `number-literal` production in the [ABNF](/spec/message.abnf).
616+
> contents match the `number-literal` production.
613617
>
614618
> For example, if the value of the variable `num` were the string
615619
> `-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
@@ -738,19 +738,17 @@ escaped as `\\` and `\|`.
738738
An **_<dfn>unquoted literal</dfn>_** is a _literal_ that does not require the `|`
739739
quotes around it to be distinct from the rest of the _message_ syntax.
740740
An _unquoted literal_ MAY be used when the content of the _literal_
741-
contains no whitespace and otherwise matches the `unquoted` production.
741+
contains no whitespace and otherwise matches the `unquoted-literal` production.
742742
Implementations MUST NOT distinguish between _quoted literals_ and _unquoted literals_
743743
that have the same sequence of code points.
744744

745-
_Unquoted literals_ can contain a _name_ or consist of a _number-literal_.
746-
A _number-literal_ uses the same syntax as JSON and is intended for the encoding
747-
of number values in _operands_ or _options_, or as _keys_ for _variants_.
745+
_Unquoted literals_ can contain any characters also valid in _name_,
746+
less _name_'s additional restrictions on the first character.
748747

749748
```abnf
750749
literal = quoted-literal / unquoted-literal
751750
quoted-literal = "|" *(quoted-char / escaped-char) "|"
752-
unquoted-literal = name / number-literal
753-
number-literal = ["-"] (%x30 / (%x31-39 *DIGIT)) ["." 1*DIGIT] [%i"e" ["-" / "+"] 1*DIGIT]
751+
unquoted-literal = 1*name-char
754752
```
755753

756754
### 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
"exp": "hello -4"
1717
},
1818
{
19-
"src": "hello {0.42e+1 :integer}",
19+
"src": "hello {0.42 :integer}",
20+
"exp": "hello 0"
21+
},
22+
{
23+
"src": "hello {|0.42e+1| :integer}",
2024
"exp": "hello 4"
2125
},
2226
{

test/tests/functions/number.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
"exp": "hello -4.2"
1717
},
1818
{
19-
"src": "hello {0.42e+1 :number}",
19+
"src": "hello {0.42 :number}",
20+
"exp": "hello 0.42"
21+
},
22+
{
23+
"src": "hello {|0.42e+1| :number}",
2024
"exp": "hello 4.2"
2125
},
2226
{

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)