{"id":19460976,"url":"https://github.com/smolkaj/nice-parser","last_synced_at":"2025-04-25T07:33:35.170Z","repository":{"id":47044497,"uuid":"89413882","full_name":"smolkaj/nice-parser","owner":"smolkaj","description":"Nice parsers in OCaml without the boilerplate","archived":false,"fork":false,"pushed_at":"2024-05-06T17:26:24.000Z","size":498,"stargazers_count":121,"open_issues_count":0,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-19T06:00:04.811Z","etag":null,"topics":["boilerplate","dune","lexing","menhir","ocaml","ocamllex","parser-generator","parsing"],"latest_commit_sha":null,"homepage":"https://smolkaj.github.io/nice-parser/nice_parser/","language":"OCaml","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/smolkaj.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","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}},"created_at":"2017-04-25T22:50:37.000Z","updated_at":"2024-05-06T17:26:28.000Z","dependencies_parsed_at":"2024-05-02T15:21:26.913Z","dependency_job_id":null,"html_url":"https://github.com/smolkaj/nice-parser","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smolkaj%2Fnice-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smolkaj%2Fnice-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smolkaj%2Fnice-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smolkaj%2Fnice-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smolkaj","download_url":"https://codeload.github.com/smolkaj/nice-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223990445,"owners_count":17237289,"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":["boilerplate","dune","lexing","menhir","ocaml","ocamllex","parser-generator","parsing"],"created_at":"2024-11-10T17:39:15.370Z","updated_at":"2024-11-10T17:39:15.890Z","avatar_url":"https://github.com/smolkaj.png","language":"OCaml","readme":"*For an older version of this repository based on sedlex, refer to the [sedlex branch](../../tree/sedlex)*.\n\n# Nice Parser\n\n[![Build Status](https://github.com/smolkaj/nice-parser/workflows/build%20and%20test/badge.svg?branch=master)](https://github.com/smolkaj/nice-parser/actions)\n\nWriting an OCaml parser with nice error messages should be easy - and now it is!\n*Nice Parser* comes in two parts:\n\n1. **lib/**: The [`nice_parser`](lib/) library ([API](http://smolkaj.github.io/nice-parser/nice_parser/)) consolidates boilerplate code and wraps your auto-generated parser in  a *nice* interface with beautiful error messages. \nIn types: `Nice_parser.Make : functor(P : RAW_PARSER) -\u003e NICE_PARSER`.\n2. **example/**: The example parser lets you get started on your own parser in seconds. It is based on [`nice_parser`](lib/) and standard tools:\n   * [Menhir](http://gallium.inria.fr/~fpottier/menhir/), a LR(1) parser generator.\n   * [ocamllex](https://caml.inria.fr/pub/docs/manual-ocaml/lexyacc.html), OCaml's built-in lexer generator.\n   * Jane Street's [dune](https://dune.build/) and [base](https://opensource.janestreet.com/base/), the de-facto standard built tool and standard library for OCaml.\n\nUsing the library and the skeleton, you can get started on your own parser in seconds:\n```sh\ngit clone https://github.com/smolkaj/nice-parser.git  # clone this repository\ncd nice-parser \u0026\u0026 rm -r lib \u0026\u0026 mv example src         # use example as starting point\nopam install . --deps-only --with-test                # install dependencies\ndune build                                            # try to build...\ndune exec src/bin/main.exe                            # ...and run your parser!\n```\nYou should see the following output (the error message relies on OCaml \u003e= 4.08's new [source highlighting mechanism](https://github.com/ocaml/ocaml/pull/2096)):\n```\nTrying to parse \"(a b (c d) e)\".\n-\u003e (List ((Atom a) (Atom b) (List ((Atom c) (Atom d))) (Atom e)))\n\nTrying to parse \"(long_atom_with_0123)\".\n-\u003e (List ((Atom long_atom_with_0123)))\n\nTrying to parse \"\n    ( so far so good\n          but (this is)) illegal (isnt it?)\n    (* parsing will fail ^^^^^^^ here *)\n  \".\nFatal error: exception Line 3, characters 25-32:\n3 |           but (this is)) illegal (isnt it?)\n                             ^^^^^^^\nError: [parser] unexpected token\n```\n\n## Documentation\nThe API is documented [here](http://smolkaj.github.io/nice-parser/nice_parser/).\nThe [example skeleton](example) should be self-explanatory.\n\n## How to build\nIdeally, use OCaml 4.08 or higher (for [beautiful error messages](https://github.com/ocaml/ocaml/pull/2096)).\nAll required dependencies can be installed using the [opam](http://opam.ocaml.org) package manager.\nThe project can be built using [dune](https://dune.build).\n```\nopam install . --deps-only --with-test\ndune build\ndune runtest\n```\n\n## Suggestions and Improvements\nSuggestions and changes are welcome. Please submit pull requests, or open issues.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmolkaj%2Fnice-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmolkaj%2Fnice-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmolkaj%2Fnice-parser/lists"}