Skip to content

Commit

Permalink
Make number rule match spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Jul 9, 2012
1 parent 3e0973b commit de2439b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Pegex/JSON/Grammar.pm
Expand Up @@ -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' => [
Expand Down
24 changes: 21 additions & 3 deletions t/test.t
Expand Up @@ -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

0 comments on commit de2439b

Please sign in to comment.