{"id":13616674,"url":"https://github.com/jubianchi/ppc","last_synced_at":"2025-04-30T18:07:03.949Z","repository":{"id":21744019,"uuid":"281054427","full_name":"jubianchi/ppc","owner":"jubianchi","description":"A parser combinator library for PHP","archived":false,"fork":false,"pushed_at":"2022-11-07T16:05:42.000Z","size":289,"stargazers_count":34,"open_issues_count":19,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T18:06:56.286Z","etag":null,"topics":["parser-combinators","php"],"latest_commit_sha":null,"homepage":"https://jubianchi.github.io/ppc/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jubianchi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["jubianchi"]}},"created_at":"2020-07-20T08:06:07.000Z","updated_at":"2024-09-27T17:08:20.000Z","dependencies_parsed_at":"2023-01-12T03:45:55.349Z","dependency_job_id":null,"html_url":"https://github.com/jubianchi/ppc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubianchi%2Fppc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubianchi%2Fppc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubianchi%2Fppc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jubianchi%2Fppc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jubianchi","download_url":"https://codeload.github.com/jubianchi/ppc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758162,"owners_count":21638989,"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-combinators","php"],"created_at":"2024-08-01T20:01:31.778Z","updated_at":"2025-04-30T18:07:03.929Z","avatar_url":"https://github.com/jubianchi.png","language":"PHP","readme":"# PPC\n\n\u003e A parser combinator library for PHP\n\nSimple to use \u0026 extend • Fast \u0026 lightweight • Reliable\n\n## Introduction\n\nPPC stands for **P**HP **P**arser **C**ombinator. What an obvious name for such a library!\n\nAs its name tells us, PPC is just another parser combinator library with a clear goal: make writing efficient parsers a\nbreeze. Writing parser with PPC does not require you to know how parser combinators works internally nor it requires you\nto learn a complex object-oriented API.\n\nPPC is a set of functions which you will love to compose to build complex parsers!\n\n## Installation\n\nPPC requires you to have at least PHP `7.4.0` and the [Multibyte String](https://www.php.net/manual/en/book.mbstring.php)\n(`mbstring`) extension enabled. You may want to check if your setup is correct using the following script:\n\n```bash\n#!/usr/bin/env bash\n\necho \"PHP version: $(php -v | head -n1 | grep -qE '7.([4-9]|1[0-9]).(0|[1-9][0-9]*)' \u0026\u0026 echo '✅' || echo '❌')\"\necho \"Multibyte String extension: $(php -m | grep -qE 'mbstring' \u0026\u0026 echo '✅' || echo '❌')\"\n```\n\nOnce everything is correct, choose the installation method that best feets your needs:\n\n### Composer (CLI)\n\n```bash\ncomposer require \"jubianchi/ppc\" \"dev-master\"\n```\n\n### Composer (JSON)\n\n```json\n{\n    \"require\": {\n        \"jubianchi/ppc\": \"dev-master\"\n    }\n}\n```\n\n### Git\n\n```bash\ngit clone \"https://github.com/jubianchi/ppc.git\"\ngit checkout \"master\"\n```\n\n## Example parser\n\nHere is a quick example demonstrating how easy it is to write a parser:\n\n```php\n\u003c?php\n\nuse jubianchi\\PPC\\Parser\\Result;\nuse jubianchi\\PPC\\CharStream;\nuse function jubianchi\\PPC\\Combinators\\{opt, separated, seq};\nuse function jubianchi\\PPC\\Parsers\\{char, eos, regex};\n\n$separator = seq(char(','), opt(char(' ')));\n$list = seq(\n    char('['),\n    seq(\n        separated(\n            $separator,\n            opt(regex('/[0-9]/'))\n        ),\n        opt($separator)\n    ),\n    char(']'),\n    eos()\n);\n\n$stream = new CharStream('[0, 1, 2, , 4, 5,, 7, 8, 9,]');\n$result = $list($stream);\n\nassert($result instanceof Result\\Success);\n```\n\nEasy, right? Be sure to read the [documentation](https://jubianchi.github.io/ppc) to understand how it works.\n","funding_links":["https://github.com/sponsors/jubianchi"],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjubianchi%2Fppc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjubianchi%2Fppc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjubianchi%2Fppc/lists"}