Pattern AST
  
     #     Remove leading line:
     P|    .*\n
    SP|    total {:int total}\n
  
      |    repeated entries
     P|        {:perms perms} \s+ {:int foo} \s+ {:word group} \s+ 
     P|        {:word user} \s+ {:int bytes} \s+ {:Y-M-D date} \s+
     P|        {:H:M time} \s+ { \S+ filename }
      |        optional symlink-target
    SL|            {#} -> { \S+ }
      |        end
     P|        \n
      |    end
MatchRegex '.*\\n'
MatchLiteral 'total '
MatchSubpattern (anon)
MatchRegex '\\n'
MatchRepeated    (name: entries)
    MatchSubpattern (anon)
    MatchRegex '\\s+'
    MatchSubpattern (anon)
    MatchRegex '\\s+'
    MatchSubpattern (anon)
    MatchRegex '\\s+'
    MatchSubpattern (anon)
    MatchRegex '\\s+'
    MatchSubpattern (anon)
    MatchRegex '\\s+'
    MatchSubpattern (anon)
    MatchRegex '\\s+'
    MatchSubpattern (anon)
    MatchRegex '\\s+'
    MatchValue    (name: filename, scalar)
        MatchRegex '\\S+'
    MatchOptional    (name: symlink-target)
        MatchLiteral ' -> '
        MatchValue    (anonymous, scalar)
            MatchRegex '\\S+'
    MatchRegex '\\n'
Input String Captured JSON
$ ls -al --color=no --time-style long-iso /bin | head
total 3936
drwxr-xr-x  2 root root   4096 2009-06-08 21:24 .
drwxr-xr-x 21 root root   4096 2008-09-24 11:05 ..
-rwxr-xr-x  1 root root 702160 2008-05-12 14:33 bash
-rwxr-xr-x  3 root root  26300 2008-03-21 06:32 bunzip2
-rwxr-xr-x  3 root root  26300 2008-03-21 06:32 bzcat
lrwxrwxrwx  1 root root      6 2008-08-09 03:40 bzcmp -> bzdiff
-rwxr-xr-x  1 root root   2128 2008-03-21 06:32 bzdiff
lrwxrwxrwx  1 root root      6 2008-08-09 03:40 bzegrep -> bzgrep
-rwxr-xr-x  1 root root   4874 2008-03-21 06:32 bzexe
{
  "total": 3936, 
  "entries": [
    {
      "date": {
        "month": 6, 
        "day": 8, 
        "year": 2009
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 24, 
        "hour": 21
      }, 
      "perms": "drwxr-xr-x", 
      "foo": 2, 
      "bytes": 4096, 
      "symlink-target": {}, 
      "filename": "."
    }, 
    {
      "date": {
        "month": 9, 
        "day": 24, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 5, 
        "hour": 11
      }, 
      "perms": "drwxr-xr-x", 
      "foo": 21, 
      "bytes": 4096, 
      "symlink-target": {}, 
      "filename": ".."
    }, 
    {
      "date": {
        "month": 5, 
        "day": 12, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 33, 
        "hour": 14
      }, 
      "perms": "-rwxr-xr-x", 
      "foo": 1, 
      "bytes": 702160, 
      "symlink-target": {}, 
      "filename": "bash"
    }, 
    {
      "date": {
        "month": 3, 
        "day": 21, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 32, 
        "hour": 6
      }, 
      "perms": "-rwxr-xr-x", 
      "foo": 3, 
      "bytes": 26300, 
      "symlink-target": {}, 
      "filename": "bunzip2"
    }, 
    {
      "date": {
        "month": 3, 
        "day": 21, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 32, 
        "hour": 6
      }, 
      "perms": "-rwxr-xr-x", 
      "foo": 3, 
      "bytes": 26300, 
      "symlink-target": {}, 
      "filename": "bzcat"
    }, 
    {
      "date": {
        "month": 8, 
        "day": 9, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 40, 
        "hour": 3
      }, 
      "perms": "lrwxrwxrwx", 
      "foo": 1, 
      "bytes": 6, 
      "symlink-target": "bzdiff", 
      "filename": "bzcmp"
    }, 
    {
      "date": {
        "month": 3, 
        "day": 21, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 32, 
        "hour": 6
      }, 
      "perms": "-rwxr-xr-x", 
      "foo": 1, 
      "bytes": 2128, 
      "symlink-target": {}, 
      "filename": "bzdiff"
    }, 
    {
      "date": {
        "month": 8, 
        "day": 9, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 40, 
        "hour": 3
      }, 
      "perms": "lrwxrwxrwx", 
      "foo": 1, 
      "bytes": 6, 
      "symlink-target": "bzgrep", 
      "filename": "bzegrep"
    }, 
    {
      "date": {
        "month": 3, 
        "day": 21, 
        "year": 2008
      }, 
      "group": "root", 
      "user": "root", 
      "time": {
        "minute": 32, 
        "hour": 6
      }, 
      "perms": "-rwxr-xr-x", 
      "foo": 1, 
      "bytes": 4874, 
      "symlink-target": {}, 
      "filename": "bzexe"
    }
  ]
}

This HTML fragment was automatically generated from the test cases for JSON Pattern.