Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

RFC: A walkthrough from JSON ABNF to Regexp::Grammars

by Anonymous Monk
on Apr 04, 2012 at 02:25 UTC ( [id://963349]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl --
    use strict; use warnings; use Data::Dump;
    my $jp = do {
    ...
        }
        print "#>>@{[time-$^T]}#\n";
    }
    
  2. or download this
    #<<1#  [false,true,null]  
    {
      "" => "[false,true,null]",
    ...
      },
    }
    #>>1#
    
  3. or download this
    --- reg
    +++ reg
    @@ -49,3 +49,3 @@
    ...
    -  (?: <quotation_mark> (?: <char> )* <quotation_mark> )
    +  (?: <.quotation_mark> (?: <char> )* <.quotation_mark> )
    
  4. or download this
    #<<0#  [false,true,null]  
    {
      "" => "[false,true,null]",
    ...
      },
    }
    #>>0#
    
  5. or download this
    --- reg
    +++ reg
    @@ -55,3 +55,3 @@
    ...
    -  (?: <.begin_array> (?: (?: <value> (?: (?: <.value_separator><value
    +> ) )*  ) )? <.end_array> )
    +  (?: <.begin_array> (?: (?: <[value]> (?: (?: <.value_separator><[va
    +lue]> ) )*  ) )? <.end_array> )
    
  6. or download this
    #<<0#  [false,true,null]  
    {
      "" => "[false,true,null]",
    ...
      },
    }
    #>>0#
    
  7. or download this
    --- reg
    +++ reg
    @@ -7,2 +7,3 @@
     #~ <debug:on>
    +<nocontext: >  # Switch off context substring retention
    
  8. or download this
    #<<0#  [false,true,null]  
    {
      array => {
    ...
      },
    }
    #>>0#
    
  9. or download this
    --- reg
    +++ reg
    @@ -40,12 +40,15 @@
    ...
    +sub TRUE { bless \(my$s=!!1), 'TRUE' }
    +sub FALSE { bless \(my$s=!!0), 'FALSE' }
    +
    
  10. or download this
    #<<1#  [false,true,null]  
    {
      array => {
    ...
      },
    }
    #>>1#
    
  11. or download this
    --- reg
    +++ reg
    @@ -38,3 +38,3 @@
    ...
    -  <false> | <null> | <true> | <object> | <array> | <number> | <string
    +>
    +  <MATCH=false> | <MATCH=null> | <MATCH=true> | <MATCH=object> | <MAT
    +CH=array> | <MATCH=number> | <MATCH=string>
    
  12. or download this
    #<<0#  [false,true,null]  
    {
      array => {
    ...
      },
    }
    #>>0#
    
  13. or download this
    --- reg
    +++ reg
    @@ -58,6 +58,9 @@
    ...
     
     <token: number>
       (?:  (?: <minus> )? <int> (?: <frac> )?  (?: <exp> )?  )
    
  14. or download this
    #<<1#  [false,true,null]  
    {
      array => [
    ...
      ],
    }
    #>>1#
    
  15. or download this
    --- reg
    +++ reg
    @@ -8 +8 @@
    ...
    @@ -117 +117 @@
    -for my $str( q/[false,true,null]/ , ){
    +for my $str( q/[ -2.0, 4.333e333, 600 ]/ , ){
    
  16. or download this
    #<<0#  [ -2.0, 4.333e333, 600 ]  
    {
      "" => "[ -2.0, 4.333e333, 600 ]",
    ...
      ],
    }
    #>>0#
    
  17. or download this
    --- reg
    +++ reg
    @@ -7,3 +7,3 @@
    ...
    -  <zero> | (?: <digit1_9> (?: <DIGIT> )*  )
    +  <zero> | (?: <digit1_9> (?: <[DIGIT]> )*  )
    
  18. or download this
    #<<1#  [ -2.0, 4.333e333, 600 ]  
    {
      array => [
    ...
      ],
    }
    #>>1#
    
  19. or download this
    --- reg
    +++ reg
    @@ -76,12 +76,21 @@
    ...
         print "#<<@{[time-$^T]}#  $str  \n";
         if( $str =~ $jp ){
             dd(\%/) ; #/
    
  20. or download this
    #<<0#  [ -2.0, 4.333e333, 600, 0, 9 ]  
    {
      array => [
    ...
      ],
    }
    #>>0#
    
  21. or download this
    --- reg
    +++ reg
    @@ -65,4 +65,7 @@
    ...
    +  })
     
     <token: decimal_point>
    
  22. or download this
    #<<1#  [ -2.0, 4.333e333, 600, 0, 9 ]  
    { array => ["-2.0", "4.333e333", 600, 0, 9] }
    #>>1#
    
  23. or download this
    --- reg
    +++ reg
    @@ -8 +8 @@
    ...
    @@ -129 +129 @@
    -for my $str( q/[ -2.0, 4.333e333, 600, 0, 9 ]/ , ){
    +for my $str( q{[ "\\" quote \\t tab" ]} , ){
    
  24. or download this
    #<<0#  [ "\" quote \t tab" ]  
    {
      "" => "[ \"\\\" quote \\t tab\" ]",
    ...
      ],
    }
    #>>0#
    
  25. or download this
    --- reg
    +++ reg
    @@ -7,3 +7,3 @@
    ...
    -  (?: <.quotation_mark> (?: <char> )* <.quotation_mark> )
    +  (?: <.quotation_mark> (?: <[char]> )* <.quotation_mark> )
    
  26. or download this
    #<<0#  [ "\" quote \t tab" ]  
    {
      array => [
    ...
      ],
    }
    #>>0#
    
  27. or download this
    --- reg
    +++ reg
    @@ -108,0 +109,3 @@
    ...
    +            } @_;
    +    }
    +}
    
  28. or download this
    #<<0#  [ "\" quote \t tab \uD83D\uDC2A U+1F42A DROMEDARY CAMEL" ]  
    {
      array => ["\" quote \t tab \x{D83D}\x{DC2A} U+1F42A DROMEDARY CAMEL"
    +],
    }
    #>>0#
    
  29. or download this
    --- reg
    +++ reg
    @@ -135 +135 @@
    -for my $str( q{[ "\\" quote \\t tab \\uD83D\\uDC2A U+1F42A DROMEDARY 
    +CAMEL" ]}, ){
    +for my $str( q{[ -90.0, [" \\t tab",[7,11]],3e9,"\\r return", null ]}
    +, ){
    
  30. or download this
    #<<1#  [ -90.0, [" \t tab",[7,11]],3e9,"\r return", null ]  
    {
      array => ["-90.0", [" \t tab", [7, 11]], "3e9", "\r return", undef],
    }
    #>>1#
    
  31. or download this
    --- reg
    +++ reg
    @@ -8 +8 @@
    ...
    @@ -135 +135 @@
    -for my $str( q{[ -90.0, [" \\t tab",[7,11]],3e9,"\\r return", null ]}
    +, ){
    +for my $str( q{{ "key" : "lime", "blue": "berry" }}, ){
    
  32. or download this
    #<<0#  { "key" : "lime", "blue": "berry" }  
    {
      "" => "{ \"key\" : \"lime\", \"blue\": \"berry\" }",
    ...
      },
    }
    #>>0#
    
  33. or download this
    --- reg
    +++ reg
    @@ -7,3 +7,3 @@
    ...
    +    $MATCH = [ $MATCH{string}, $MATCH{value} ];
    +  })
    
  34. or download this
    #<<0#  { "key" : "lime", "blue": "berry" }  
    { object => { member => [["key", "lime"], ["blue", "berry"]] } }
    #>>0#
    
  35. or download this
    --- reg
    +++ reg
    @@ -53,4 +53,7 @@
    ...
    +  })
     
     <token: member>
    
  36. or download this
    #<<1#  { "key" : "lime", "blue": "berry" }  
    { object => { blue => "berry", key => "lime" } }
    #>>1#
    
  37. or download this
    --- reg
    +++ reg
    @@ -141 +141 @@
    -for my $str( q{{ "key" : "lime", "blue": "berry" }}, ){
    +for my $str( q{[{"k":"v"},{"v":"k"}] }, q{{"ro":["sham","bo"],"t":{"i
    +":{"c":{"t":{"o":"c"}}}}}}){
    
  38. or download this
    #<<1#  [{"k":"v"},{"v":"k"}]   
    { array => [{ k => "v" }, { v => "k" }] }
    #>>1#
    ...
      object => { ro => ["sham", "bo"], t => { i => { c => { t => { o => "
    +c" } } } } },
    }
    #>>1#
    
  39. or download this
    --- reg
    +++ reg
    @@ -141 +141 @@
    -for my $str( q{[{"k":"v"},{"v":"k"}] }, q{{"ro":["sham","bo"],"t":{"i
    +":{"c":{"t":{"o":"c"}}}}}}){
    +for my $str( q{[1,[2,[3],[]]]}, q{["double extra comma",,]} , ){
    
  40. or download this
    #<<0#  [1,[2,[3],[]]]  
    { array => [1, [2, [3], undef]] }
    #>>0#
    #<<0#  ["double extra comma",,]  
    ## fail to match 
    #>>43#
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://963349]
Approved by ww
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-19 15:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found