{"id":13878513,"url":"https://github.com/ruby-next/paco","last_synced_at":"2025-07-16T14:32:20.039Z","repository":{"id":42227796,"uuid":"437601809","full_name":"ruby-next/paco","owner":"ruby-next","description":"Paco is a parser combinator library inspired by Haskell's Parsec and Parsimmon.","archived":false,"fork":false,"pushed_at":"2023-12-27T08:07:24.000Z","size":72,"stargazers_count":24,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-09T05:48:39.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/ruby-next.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-12-12T16:47:50.000Z","updated_at":"2024-11-08T17:16:46.000Z","dependencies_parsed_at":"2023-08-29T01:32:24.074Z","dependency_job_id":null,"html_url":"https://github.com/ruby-next/paco","commit_stats":null,"previous_names":["ruby-next/paco","skryukov/paco"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Fpaco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Fpaco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Fpaco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Fpaco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby-next","download_url":"https://codeload.github.com/ruby-next/paco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"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":[],"created_at":"2024-08-06T08:01:51.878Z","updated_at":"2024-11-24T07:31:06.232Z","avatar_url":"https://github.com/ruby-next.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Paco\n\n[![Gem Version](https://badge.fury.io/rb/paco.svg)](https://rubygems.org/gems/paco)\n[![Build](https://github.com/skryukov/paco/workflows/Build/badge.svg)](https://github.com/skryukov/paco/actions)\n\nPaco is a parser combinator library inspired by Haskell's [Parsec] and [Parsimmon].\n\n\"But I don't need to write another JSON parser or a new language, why do I need your library then?\"\n\nWell, most probably you don't. But I can think of rare cases when you do. Say, you need to write a validation for [git branch names].\n\nYou can go with easy-peasy regex:\n\n```ruby\nbranch_name_regex = /^(?!\\/|.*(?:[\\/.]\\.|\\/\\/|@{|\\\\|\\.lock$|[\\/.]$))[^\\040\\177 ~^:?*\\[]+$/\n\nbranch_name_regex.match?(\"feature/branch-validation\")\n```\n\nWith Paco, you can go with a little more verbose version of that rule:\n\n```ruby\nmodule BranchNameParser\n  extend Paco\n\n  class \u003c\u003c self\n    def parse(input)\n      parser.parse(input)\n    end\n\n    def parser\n      lookahead(none_of(\"/\")).next(valid_chars.join)\n    end\n\n    def valid_chars\n      any_char.not_followed_by(invalid_sequences).at_least(1)\n    end\n    \n    def invalid_sequences\n      alt(invalid_chars, invalid_endings)\n    end\n\n    def invalid_chars\n      alt(\n        string(\"/.\"),\n        string(\"..\"),\n        string(\"//\"),\n        string(\"@{\"),\n        string(\"\\\\\\\\\"),\n        one_of(\"\\040\\177 ~^:?*\\\\[\")\n      )\n    end\n\n    def invalid_endings\n      seq(\n        alt(string(\".lock\"), one_of(\"/.\")),\n        eof\n      )\n    end\n  end\nend\n\nBranchNameParser.parse(\"feature/branch-validation\")\n```\n\nEasy? Not really, but there is a chance you can read it. 😅\n\nSee [API documentation](docs/paco.md), [examples](examples) and [specs](spec) for more info on usage.\n\n\u003ca href=\"https://evilmartians.com/\"\u003e\u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\" alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\u003c/a\u003e\n\n## Installation\n\nAdd to your `Gemfile`:\n\n```ruby\ngem \"paco\"\n```\n\nAnd then run `bundle install`.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/skryukov/paco.\n\n## Alternatives\n\n- [parslet] - A small (but featureful) PEG based parser library.\n- [parsby] — Parser combinator library for Ruby inspired by Haskell's Parsec.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License].\n\n[MIT License]: https://opensource.org/licenses/MIT\n[Parsec]: https://github.com/haskell/parsec\n[Parsimmon]: https://github.com/jneen/parsimmon\n[parslet]: https://github.com/kschiess/parslet\n[parsby]: https://github.com/jolmg/parsby\n[git branch names]: https://git-scm.com/docs/git-check-ref-format#_description\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-next%2Fpaco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby-next%2Fpaco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-next%2Fpaco/lists"}