//! A parser for JSON file. //! //! And this is a example for JSON parser. //! //! Created by [Tomas Tauber](https://github.com/tomtau). //! Modified by [Boyi Huang](https://github.com/TheVeryDarkness). // FIXME: some should be under pest::* use common::base as p json = pest::SOI ~ value ~ pest::EOI /// Matches object, e.g.: `{ "foo": "bar" }` /// Foobar object = "{" ~ pair^* ~ "}" pair = string ~ ":" ~ value array = "[" ~ value ~ ("," ~ value)* ~ "]" | "[" ~ "]" ////////////////////// /// Matches value, e.g.: `"foo"`, `42`, `true`, `null`, `[]`, `{}`. ////////////////////// value = string | number | object | array | bool | null string = "\"" - inner - "\"" inner = (!("\"" | "\\") - pest::any)* - (escape ~ inner)? escape = "\\" - ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | unicode) unicode = "u" - p::ascii_hex_digit{4} number = "-"? - int - ("." ~ p::ascii_digit+ ~ exp? | exp)? int = "0" | p::ascii_nonzero_digit - p::ascii_digit* exp = ("E" | "e") - ("+" | "-")? - p::ascii_digit+ bool = "true" | "false" null = "null" space = " " | "\t" | "\r" | "\n" ~ = space* ^ = space* - "," - space*