A Rust library to declaratively implement parsers that are based on Packrat Parsing.
The following code implements a parser for a JSON subset format: ```rust use textparse::{ components::{ Char, Eos, Items, NonEmpty, SkipWhitespaces, StartsWith, StaticStr, Until, While, }, Parse, ParseError, ParseResult, Parser, Position, Span, };
struct JsonValue(WithoutWhitespaces
enum JsonValueInner { Null(JsonNull), String(JsonString), Number(JsonNumber), Array(JsonArray), Object(JsonObject), }
null
")]struct JsonNull(StartsWith
struct JsonString(Char<'"'>, Until
struct JsonNumber(NonEmpty
struct JsonArray(Char<'['>, Csv
struct JsonObject(Char<'{'>, Csv
struct JsonObjectItem(WithoutWhitespaces
struct Csv
struct WithoutWhitespaces
struct Null; impl StaticStr for Null { fn static_str() -> &'static str { "null" } }
struct Digit(Position, Position);
impl Parse for Digit {
fn parse(parser: &mut Parser) -> ParseResult
You can run the above parser via examples/checkjson.rs as follows: ```console $ echo '["foo",null,{"key": "value"}, 123]' | cargo run --example checkjson OK: the input string is a JSON text.
$ echo '["foo" null]' | cargo run --example check_json
Error: expected one of ',', or ']'
-->