{"id":18634649,"url":"https://github.com/tacoberu/bnf-php","last_synced_at":"2025-07-13T20:35:02.554Z","repository":{"id":57064445,"uuid":"243126368","full_name":"tacoberu/bnf-php","owner":"tacoberu","description":"Framework for building BNF like parsers.","archived":false,"fork":false,"pushed_at":"2025-03-08T16:18:02.000Z","size":56,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-04T12:04:38.684Z","etag":null,"topics":["bnf","bnf-parser","parser","parser-combinators"],"latest_commit_sha":null,"homepage":"","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/tacoberu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-25T23:40:08.000Z","updated_at":"2025-02-14T22:09:46.000Z","dependencies_parsed_at":"2025-04-11T07:48:04.620Z","dependency_job_id":"81473783-78c0-43bc-acf6-81731d924df6","html_url":"https://github.com/tacoberu/bnf-php","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"6aab4a1a4c75d69d895bf4e356d2ab6d0a42bb68"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/tacoberu/bnf-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacoberu%2Fbnf-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacoberu%2Fbnf-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacoberu%2Fbnf-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacoberu%2Fbnf-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tacoberu","download_url":"https://codeload.github.com/tacoberu/bnf-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacoberu%2Fbnf-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265200402,"owners_count":23726828,"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":["bnf","bnf-parser","parser","parser-combinators"],"created_at":"2024-11-07T05:20:18.741Z","updated_at":"2025-07-13T20:35:02.534Z","avatar_url":"https://github.com/tacoberu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"A PHP BNF like parser\n=====================\n\n[travisimage]: https://travis-ci.org/tacoberu/bnf-php.svg?branch=master\n[travislink]: https://travis-ci.org/tacoberu/bnf-php\n[![Latest Stable Version](http://poser.pugx.org/tacoberu/bnf/v)](https://packagist.org/packages/tacoberu/bnf)\n[![Latest Unstable Version](http://poser.pugx.org/tacoberu/bnf/v/unstable)](https://packagist.org/packages/tacoberu/bnf)\n[![PHP Version Require](http://poser.pugx.org/tacoberu/bnf/require/php)](https://packagist.org/packages/tacoberu/bnf)\n[![License](http://poser.pugx.org/tacoberu/bnf/license)](https://packagist.org/packages/tacoberu/bnf)\n\nThis is a PHP implementation of BNF like parser.\n\n\nInstallation\n------------\n\nThe recommended way to install is via Composer:\n\n        composer require tacoberu/bnf\n\n\n\nUsage\n-----\n\n```php\n\nrequire __dir__ . '/vendor/autoload.php';\n\nuse Taco\\BNF\\Parser;\nuse Taco\\BNF\\Combinators\\Pattern;\nuse Taco\\BNF\\Combinators\\Whitechars;\n\n$parser = new Parser([\n\tnew Whitechars(Null, False),\n\tnew Pattern('element', ['~[^\\n]+~']),\n]);\n$tree = $parser-\u003eparse('\n-brand-name = Foo 3000\nwelcome = Welcome, {$name}, to {-brand-name}!\n');\n\nprint_r($tree); /*\n\narray (\n    [0] =\u003e Taco\\BNF\\Token (\n\t\t[type] =\u003e Taco\\BNF\\Combinators\\Pattern (...)\n\t\t[content] =\u003e \"-brand-name = Foo 3000\"\n\t\t[start] =\u003e 1\n\t\t[end] =\u003e 23\n\t)\n    [0] =\u003e Taco\\BNF\\Token (\n\t\t[type] =\u003e Taco\\BNF\\Combinators\\Pattern (...)\n\t\t[content] =\u003e \"welcome = Welcome, {$name}, to {-brand-name}!\"\n\t\t[start] =\u003e 24\n\t\t[end] =\u003e 69\n\t)\n)\n\n*/\n```\n\nor more complex:\n\n```php\n\nrequire __dir__ . '/vendor/autoload.php';\n\nuse Taco\\BNF\\Parser;\nuse Taco\\BNF\\Combinators\\Pattern;\nuse Taco\\BNF\\Combinators\\Whitechars;\n\n$parser = new Parser([\n\tnew Whitechars(Null, False),\n\tnew Sequence('element', [\n\t\tnew Pattern('id', ['~[a-z\\-]+~']),\n\t\tnew Whitechars(Null, False),\n\t\tnew Match(Null, ['='], False),\n\t\tnew Whitechars(Null, False),\n\t\tnew Pattern('element', ['~[^\\n]+~']),\n\t]),\n]);\n$tree = $parser-\u003eparse('\n-brand-name = Foo 3000\nwelcome = Welcome, {$name}, to {-brand-name}!\n');\n\nprint_r($tree); /*\n\narray (\n    [0] =\u003e Taco\\BNF\\Token (\n\t\t[type] =\u003e Taco\\BNF\\Combinators\\Sequence (...)\n\t\t[content] =\u003e array(\n\t\t\t[0] =\u003e Taco\\BNF\\Token (\n\t\t\t\t[type] =\u003e Taco\\BNF\\Combinators\\Pattern (...)\n\t\t\t\t[content] =\u003e \"-brand-name\"\n\t\t\t\t[start] =\u003e 1\n\t\t\t\t[end] =\u003e 12\n\t\t\t)\n\t\t\t[1] =\u003e Taco\\BNF\\Token (\n\t\t\t\t[type] =\u003e Taco\\BNF\\Combinators\\Pattern (...)\n\t\t\t\t[content] =\u003e \"Foo 3000\"\n\t\t\t\t[start] =\u003e 15\n\t\t\t\t[end] =\u003e 23\n\t\t\t)\n\t\t)\n\t\t[start] =\u003e 1\n\t\t[end] =\u003e 23\n\t)\n    [0] =\u003e Taco\\BNF\\Token (\n\t\t[type] =\u003e Taco\\BNF\\Combinators\\Pattern (...)\n\t\t[content] =\u003e array(\n\t\t\t[0] =\u003e Taco\\BNF\\Token (\n\t\t\t\t[type] =\u003e Taco\\BNF\\Combinators\\Pattern (...)\n\t\t\t\t[content] =\u003e \"welcome\"\n\t\t\t\t[start] =\u003e 24\n\t\t\t\t[end] =\u003e 31\n\t\t\t)\n\t\t\t[1] =\u003e Taco\\BNF\\Token (\n\t\t\t\t[type] =\u003e Taco\\BNF\\Combinators\\Pattern (...)\n\t\t\t\t[content] =\u003e \"Welcome, {$name}, to {-brand-name}!\"\n\t\t\t\t[start] =\u003e 34\n\t\t\t\t[end] =\u003e 69\n\t\t\t)\n\t\t)\n\t\t[start] =\u003e 24\n\t\t[end] =\u003e 69\n\t)\n)\n\n*/\n```\n\nSee more examples in 'tests/ExhibitionTest.php'.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftacoberu%2Fbnf-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftacoberu%2Fbnf-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftacoberu%2Fbnf-php/lists"}