{"id":21424220,"url":"https://github.com/thatsjustcheesy/parsem","last_synced_at":"2025-07-14T08:31:44.031Z","repository":{"id":42865072,"uuid":"510951539","full_name":"ThatsJustCheesy/parsem","owner":"ThatsJustCheesy","description":"Parsec-like parser combinators for Crystal","archived":false,"fork":false,"pushed_at":"2022-11-17T04:15:20.000Z","size":59,"stargazers_count":13,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T05:13:51.373Z","etag":null,"topics":["crystal","parsec","parser","parser-combinators"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/ThatsJustCheesy.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}},"created_at":"2022-07-06T01:48:43.000Z","updated_at":"2025-03-11T05:36:14.000Z","dependencies_parsed_at":"2022-07-09T02:00:36.609Z","dependency_job_id":null,"html_url":"https://github.com/ThatsJustCheesy/parsem","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ThatsJustCheesy/parsem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatsJustCheesy%2Fparsem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatsJustCheesy%2Fparsem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatsJustCheesy%2Fparsem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatsJustCheesy%2Fparsem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThatsJustCheesy","download_url":"https://codeload.github.com/ThatsJustCheesy/parsem/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThatsJustCheesy%2Fparsem/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265262615,"owners_count":23736429,"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":["crystal","parsec","parser","parser-combinators"],"created_at":"2024-11-22T21:20:10.574Z","updated_at":"2025-07-14T08:31:43.242Z","avatar_url":"https://github.com/ThatsJustCheesy.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parsem\n\nCrystal library for [Parsec][]-like _parser combinators_, which allow you to construct complex parsers out of simpler ones. Usually, this leads to highly compact parsing code, with a structure that very much resembles the grammar itself.\n\nHeavily inspired by [FootlessParser][], a parser combinator library for Swift.\n\n[parsec]: https://wiki.haskell.org/Parsec\n[footlessparser]: https://github.com/kareman/FootlessParser\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     parsem:\n       github: ThatsJustCheesy/parsem\n   ```\n\n2. Run `shards install`\n\n## Usage\n\nBegin by finding or creating a right-recursive grammar for the language you want to parse. Then translate the grammar into Parsem parsers.\n\nYou'll make frequent use of these combinators:\n\n- Sequencing operators: Run the left parser, then the right parser\n  - Left-yield `\u003c\u003c`\n    - Keeps only the result of the left parser\n  - Right-yield `\u003e\u003e`\n    - Keeps only the result of the right parser\n  - Proc-apply `\u003c=\u003e`\n    - Effectively keeps the result of both parsers, but must be used in conjunction with `^` (map operator) or a related convenience method\n- Choice operator `|`\n  - Runs the left parser; if it fails without consuming any input, runs the right parser instead\n- Map operator `^`\n  - Partially applies the (left) proc with the (right) parser's result as the first argument. Supply any additional arguments with `\u003c=\u003e` (sequencing proc-apply operator)\n\n### Docs\n\nPlease clone the repository, run `crystal docs`, and open the resulting `docs/index.html`.\n\n### Examples\n\n#### CSV parser\n\n```crystal\nrequire \"parsem\"\ninclude Parsem\n\n# Adapted from https://github.com/kareman/FootlessParser#csv-parser\n# Thanks!\n\nDELIMITER = ','\nQUOTE     = '\"'\nNEWLINE   = '\\n'\n\nquoted_cell = token(QUOTE) \u003e\u003e not(QUOTE).repeat(..).join \u003c\u003c token(QUOTE)\nunquoted_cell = none_of([DELIMITER, NEWLINE]).repeat(..).join\ncell = quoted_cell | unquoted_cell\n\nrow = (cell \u003c\u003c token(DELIMITER)).repeat(..).extend \u003c=\u003e cell\ncsv = (row \u003c\u003c token(NEWLINE)).repeat(..).extend \u003c=\u003e row\n```\n\n#### More (complex) examples\n\nPlease see [`spec/examples`](spec/examples) for more, including an arithmetic expression parser and a pseudo-JSON parser.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/ThatsJustCheesy/parsem/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Ian Gregory](https://github.com/ThatsJustCheesy) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatsjustcheesy%2Fparsem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthatsjustcheesy%2Fparsem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthatsjustcheesy%2Fparsem/lists"}