{"id":18616769,"url":"https://github.com/sile/textparse","last_synced_at":"2025-04-11T01:32:14.548Z","repository":{"id":62833660,"uuid":"562348905","full_name":"sile/textparse","owner":"sile","description":"A Rust library to declaratively implement parsers that are based on Packrat Parsing.","archived":false,"fork":false,"pushed_at":"2022-12-25T04:21:15.000Z","size":122,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-01T23:47:30.744Z","etag":null,"topics":["parser","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-06T03:46:14.000Z","updated_at":"2023-07-25T15:03:40.000Z","dependencies_parsed_at":"2022-11-07T15:30:31.317Z","dependency_job_id":null,"html_url":"https://github.com/sile/textparse","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ftextparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ftextparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ftextparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Ftextparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/textparse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248325282,"owners_count":21084901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parser","rust"],"created_at":"2024-11-07T03:37:51.043Z","updated_at":"2025-04-11T01:32:14.231Z","avatar_url":"https://github.com/sile.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"textparse\n=========\n\n[![textparse](https://img.shields.io/crates/v/textparse.svg)](https://crates.io/crates/textparse)\n[![Documentation](https://docs.rs/textparse/badge.svg)](https://docs.rs/textparse)\n[![Actions Status](https://github.com/sile/textparse/workflows/CI/badge.svg)](https://github.com/sile/textparse/actions)\n![License](https://img.shields.io/crates/l/textparse)\n\nA Rust library to declaratively implement parsers that are based on Packrat Parsing.\n\nExamples\n--------\n\nThe following code implements a parser for a JSON subset format:\n```rust\nuse textparse::{\n    components::{AnyChar, Char, Digit, Eos, Items, NonEmpty, Not, Str, While, Whitespace},\n    Parse, Parser, Position, Span,\n};\n\n#[derive(Clone, Span, Parse)]\nstruct JsonValue(WithoutWhitespaces\u003cJsonValueInner\u003e);\n\n#[derive(Clone, Span, Parse)]\n#[parse(name = \"a JSON value\")]\nenum JsonValueInner {\n    Null(JsonNull),\n    String(JsonString),\n    Number(JsonNumber),\n    Array(JsonArray),\n    Object(JsonObject),\n}\n\n#[derive(Clone, Span, Parse)]\nstruct JsonNull(Str\u003c'n', 'u', 'l', 'l'\u003e);\n\n#[derive(Clone, Span, Parse)]\n#[parse(name = \"a JSON string\")]\nstruct JsonString(Char\u003c'\"'\u003e, While\u003c(Not\u003cChar\u003c'\"'\u003e\u003e, AnyChar)\u003e, Char\u003c'\"'\u003e);\n\n#[derive(Clone, Span, Parse)]\n#[parse(name = \"a JSON number\")]\nstruct JsonNumber(NonEmpty\u003cWhile\u003cDigit\u003e\u003e);\n\n#[derive(Clone, Span, Parse)]\n#[parse(name = \"a JSON array\")]\nstruct JsonArray(Char\u003c'['\u003e, Csv\u003cJsonValue\u003e, Char\u003c']'\u003e);\n\n#[derive(Clone, Span, Parse)]\n#[parse(name = \"a JSON object\")]\nstruct JsonObject(Char\u003c'{'\u003e, Csv\u003cJsonObjectItem\u003e, Char\u003c'}'\u003e);\n\n#[derive(Clone, Span, Parse)]\nstruct JsonObjectItem(WithoutWhitespaces\u003cJsonString\u003e, Char\u003c':'\u003e, JsonValue);\n\n#[derive(Clone, Span, Parse)]\nstruct Csv\u003cT\u003e(Items\u003cT, Char\u003c','\u003e\u003e);\n\n#[derive(Clone, Span, Parse)]\nstruct WithoutWhitespaces\u003cT\u003e(While\u003cWhitespace\u003e, T, While\u003cWhitespace\u003e);\n```\n\nYou can run the above parser via [examples/check_json.rs](examples/check_json.rs) as follows:\n```console\n$ echo '[\"foo\",null,{\"key\": \"value\"}, 123]' | cargo run --example check_json\nOK: the input string is a JSON text.\n\n$ echo '[\"foo\" null]' | cargo run --example check_json\nError: expected one of ',', or ']'\n  --\u003e \u003cSTDIN\u003e:1:8\n  |\n1 | [\"foo\" null]\n  |        ^ expected one of ',', or ']'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Ftextparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Ftextparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Ftextparse/lists"}