Skip to content

Commit

Permalink
Merge pull request #29 from cbor-wg/elide-zero-mantissa-parts
Browse files Browse the repository at this point in the history
Allow .3 and 3. for decimal and hex float
  • Loading branch information
cabo authored Jan 27, 2024
2 parents 6096deb + c8eaf92 commit edc778b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cbor-diag-parser.abnf
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ string = string1e *(S string1e)

number = (basenumber / decnumber / infin) spec
sign = "+" / "-"
decnumber = [sign] 1*DIGIT ["." 1*DIGIT] ["e" [sign] 1*DIGIT]
decnumber = [sign] (1*DIGIT ["." *DIGIT] / "." 1*DIGIT)
["e" [sign] 1*DIGIT]
basenumber = [sign] "0" ("x" 1*HEXDIG
[["." 1*HEXDIG] "p" [sign] 1*DIGIT]
[["." *HEXDIG] "p" [sign] 1*DIGIT]
/ "x" "." 1*HEXDIG "p" [sign] 1*DIGIT
/ "o" 1*ODIGIT
/ "b" 1*BDIGIT)
infin = %s"Infinity"
Expand Down
3 changes: 2 additions & 1 deletion draft-ietf-cbor-edn-literals.md
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,8 @@ The following additional items should help in the interpretation:
* `decnumber` stands for an integer in the usual decimal notation, unless at
least one of the optional parts starting with "." and "e" are
present, in which case it stands for a floating point value in the
usual decimal notation.
usual decimal notation. Note that the grammar now allows `3.` for
`3.0` and `.3` for `0.3` (also for hexadecimal floating point below).
* `basenumber` stands for an integer in the usual base 16/hexadecimal
("0x"), base 8/octal ("0o"), or base 2/binary ("0b") notation, unless the
optional part containing a "p" is present, in which case it stands
Expand Down

0 comments on commit edc778b

Please sign in to comment.