peg 0.3.9

A parser generator built on the Parsing Expression Grammar (PEG) formalism.
// JSON grammar (RFC 4627). Note that this only checks for valid JSON and does not build a syntax
// tree.


#[pub]
json = object / array

ws = [ \t\r\n]*
begin_array = ws "[" ws
begin_object = ws "{" ws
end_array = ws "]" ws
end_object = ws "}" ws
name_separator = ws ":" ws
value_separator = ws "," ws

value
    = "false" / "true" / "null" / object / array / number / string

object
    = begin_object (member (value_separator member)*)? end_object

member
    = string name_separator value

array
    = begin_array (value (value_separator value)*)? end_array

number
    = "-"? int frac? exp? {}

int
    = "0" / [1-9][0-9]*

exp
    = ("e" / "E") ("-" / "+")? [0-9]{1,}

frac
    = "." [0-9]{1,}

// note: escaped chars not handled
string
    = "\"" (!"\"" .)* "\""