diff --git a/lib/Pegex/JSON/Grammar.pm b/lib/Pegex/JSON/Grammar.pm index a063359..5b2394b 100644 --- a/lib/Pegex/JSON/Grammar.pm +++ b/lib/Pegex/JSON/Grammar.pm @@ -71,7 +71,7 @@ sub tree { '.rgx' => qr/(?-xism:\Gnull)/ }, 'number' => { - '.rgx' => qr/(?-xism:\G(\-?[0-9]+(?:\.[0-9]*)?|\.[0-9]+))/ + '.rgx' => qr/(?-xism:\G(\-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][\-\+]?[0-9]+)?))/ }, 'pair' => { '.all' => [ diff --git a/t/test.t b/t/test.t index d7225d3..c06fc6c 100644 --- a/t/test.t +++ b/t/test.t @@ -103,9 +103,27 @@ xyz: === Numbers --- json -[0, -1, .1, 1.] +[ + 0, -0, + 1, -1, + 22, -22, + 3.3, -3.3, + 44.4, -44.4, + 5.55, -5.55, + 66.66, -66.66 +] --- yaml - 0 -- -1 -- 0.1 +- 0 - 1 +- -1 +- 22 +- -22 +- 3.3 +- -3.3 +- 44.4 +- -44.4 +- 5.55 +- -5.55 +- 66.66 +- -66.66