Skip to content

Commit

Permalink
RFC 7159 compliance.
Browse files Browse the repository at this point in the history
  • Loading branch information
daoswald committed Aug 31, 2014
1 parent f3bfae6 commit fcb51a3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 70 deletions.
4 changes: 2 additions & 2 deletions lib/Pegex/JSON/Data.pm
Expand Up @@ -4,8 +4,8 @@ extends 'Pegex::Tree';

use boolean;

sub got_map { +{map @$_, map @$_, @{(pop)}} }
sub got_seq { [map @$_, @{(pop)}] }
sub got_object { +{map @$_, map @$_, @{(pop)}} }
sub got_array { [map @$_, @{(pop)}] }

my %escapes = (
'"' => '"',
Expand Down
115 changes: 47 additions & 68 deletions lib/Pegex/JSON/Grammar.pm
Expand Up @@ -4,36 +4,55 @@ extends 'Pegex::Grammar';

use constant file => '../json-pgx/json.pgx';

sub make_tree {
sub make_tree { # Generated/Inlined by Pegex::Grammar (0.45)
{
'+grammar' => 'json',
'+include' => 'pegex-atoms',
'+toprule' => 'json',
'+version' => '0.0.1',
'boolean' => {
'.any' => [
'array' => {
'.all' => [
{
'.ref' => 'true'
'.rgx' => qr/\G\s*\[\s*/
},
{
'.ref' => 'false'
'+max' => 1,
'.all' => [
{
'.ref' => 'value'
},
{
'+min' => 0,
'-flat' => 1,
'.all' => [
{
'.rgx' => qr/\G\s*,\s*/
},
{
'.ref' => 'value'
}
]
}
]
},
{
'.rgx' => qr/\G\s*\]\s*/
}
]
},
'false' => {
'.rgx' => qr/\Gfalse/
},
'json' => {
'.any' => [
{
'.ref' => 'map'
},
{
'.ref' => 'seq'
}
]
'.ref' => 'value'
},
'null' => {
'.rgx' => qr/\Gnull/
},
'number' => {
'.rgx' => qr/\G(\-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][\-\+]?[0-9]+)?)/
},
'map' => {
'object' => {
'.all' => [
{
'.rgx' => qr/\G\s*\{\s*/
Expand Down Expand Up @@ -63,25 +82,6 @@ sub make_tree {
}
]
},
'node' => {
'.any' => [
{
'.ref' => 'map'
},
{
'.ref' => 'seq'
},
{
'.ref' => 'scalar'
}
]
},
'null' => {
'.rgx' => qr/\Gnull/
},
'number' => {
'.rgx' => qr/\G(\-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][\-\+]?[0-9]+)?)/
},
'pair' => {
'.all' => [
{
Expand All @@ -91,11 +91,17 @@ sub make_tree {
'.rgx' => qr/\G\s*:\s*/
},
{
'.ref' => 'node'
'.ref' => 'value'
}
]
},
'scalar' => {
'string' => {
'.rgx' => qr/\G"((?:\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})|[^"\x00-\x1f])*)"/
},
'true' => {
'.rgx' => qr/\Gtrue/
},
'value' => {
'.any' => [
{
'.ref' => 'string'
Expand All @@ -104,48 +110,21 @@ sub make_tree {
'.ref' => 'number'
},
{
'.ref' => 'boolean'
'.ref' => 'object'
},
{
'.ref' => 'null'
}
]
},
'seq' => {
'.all' => [
'.ref' => 'array'
},
{
'.rgx' => qr/\G\s*\[\s*/
'.ref' => 'true'
},
{
'+max' => 1,
'.all' => [
{
'.ref' => 'node'
},
{
'+min' => 0,
'-flat' => 1,
'.all' => [
{
'.rgx' => qr/\G\s*,\s*/
},
{
'.ref' => 'node'
}
]
}
]
'.ref' => 'false'
},
{
'.rgx' => qr/\G\s*\]\s*/
'.ref' => 'null'
}
]
},
'string' => {
'.rgx' => qr/\G"((?:\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})|[^"\x00-\x1f])*)"/
},
'true' => {
'.rgx' => qr/\Gtrue/
}
}
}
Expand Down

0 comments on commit fcb51a3

Please sign in to comment.