Pattern AST
           | repeated * files
          P|     ...[ ]{ [^#]+ filename }#{ \d+ revision }[ ]{ \w+ action }\s*
           | end
  
MatchRepeated    (name: files)
    MatchRegex '...[ ]'
    MatchValue    (name: filename, scalar)
        MatchRegex '[^#]+'
    MatchLiteral '#'
    MatchValue    (name: revision, scalar)
        MatchRegex '\\d+'
    MatchRegex '[ ]'
    MatchValue    (name: action, scalar)
        MatchRegex '\\w+'
    MatchRegex '\\s*'
Input String Captured JSON
... foo.py#13 add
{
  "files": [
    {
      "action": "add", 
      "revision": "13", 
      "filename": "foo.py"
    }
  ]
}
Pattern AST
           | repeated * files
          P|     ...[ ]{ [^#]+ filename }#{ \d+ revision }[ ]{ \w+ action }\s*
           | end
  
MatchRepeated    (name: files)
    MatchRegex '...[ ]'
    MatchValue    (name: filename, scalar)
        MatchRegex '[^#]+'
    MatchLiteral '#'
    MatchValue    (name: revision, scalar)
        MatchRegex '\\d+'
    MatchRegex '[ ]'
    MatchValue    (name: action, scalar)
        MatchRegex '\\w+'
    MatchRegex '\\s*'
Input String Captured JSON
... foo.py#13 add
... baz/bar.cc#5 edit
{
  "files": [
    {
      "action": "add", 
      "revision": "13", 
      "filename": "foo.py"
    }, 
    {
      "action": "edit", 
      "revision": "5", 
      "filename": "baz/bar.cc"
    }
  ]
}

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