{"id":13995699,"url":"https://github.com/BNFC/bnfc","last_synced_at":"2025-07-22T22:32:09.662Z","repository":{"id":5577141,"uuid":"6782974","full_name":"BNFC/bnfc","owner":"BNFC","description":"BNF Converter","archived":false,"fork":false,"pushed_at":"2025-03-15T20:23:40.000Z","size":7993,"stargazers_count":602,"open_issues_count":92,"forks_count":169,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-06-27T02:51:03.420Z","etag":null,"topics":["abstract-syntax-tree","bnf","bnf-converter","bnfc","grammar-specification","lexer-generator","parser-generator","pretty-print"],"latest_commit_sha":null,"homepage":"http://bnfc.digitalgrammars.com/","language":"TeX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BNFC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2012-11-20T18:33:10.000Z","updated_at":"2025-05-27T05:39:41.000Z","dependencies_parsed_at":"2023-10-20T18:29:57.935Z","dependency_job_id":"a00757fd-a4aa-4c80-8e58-62656dbddf98","html_url":"https://github.com/BNFC/bnfc","commit_stats":{"total_commits":1520,"total_committers":51,"mean_commits":29.80392156862745,"dds":0.4519736842105263,"last_synced_commit":"d759eecf9d3e8de9868959b39bbd2066404984be"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/BNFC/bnfc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BNFC%2Fbnfc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BNFC%2Fbnfc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BNFC%2Fbnfc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BNFC%2Fbnfc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BNFC","download_url":"https://codeload.github.com/BNFC/bnfc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BNFC%2Fbnfc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266585845,"owners_count":23952167,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["abstract-syntax-tree","bnf","bnf-converter","bnfc","grammar-specification","lexer-generator","parser-generator","pretty-print"],"created_at":"2024-08-09T14:03:33.438Z","updated_at":"2025-07-22T22:32:08.983Z","avatar_url":"https://github.com/BNFC.png","language":"TeX","readme":"[![Hackage version](https://img.shields.io/hackage/v/BNFC.svg?label=Hackage)](http://hackage.haskell.org/package/BNFC) \u003c!-- [![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/BNFC/badge)](https://matrix.hackage.haskell.org/package/BNFC) --\u003e\n[![BNFC on Stackage Nightly](https://stackage.org/package/BNFC/badge/nightly)](https://stackage.org/nightly/package/BNFC)\n[![Stackage LTS version](https://www.stackage.org/package/BNFC/badge/lts?label=Stackage)](https://www.stackage.org/package/BNFC)\n[![Build status](https://github.com/BNFC/bnfc/workflows/Haskell-CI/badge.svg)](https://github.com/BNFC/bnfc/actions)\n[![Documentation status](https://readthedocs.org/projects/bnfc/badge/?version=latest)](http://bnfc.readthedocs.io/en/latest/?badge=latest)\n\nThe BNF Converter\n=================\n\nWhat is the BNF Converter?\n--------------------------\n\nThe BNF Converter (bnfc) is a compiler construction tool generating a compiler\nfront-end from a Labelled BNF (LBNF) grammar. It is currently able to generate Haskell,\nAgda, C, C++, Java, and OCaml, as well as XML representations.\n\nGiven a LBNF grammar the tool produces:\n- an abstract syntax implementation\n- a case skeleton for the abstract syntax in the same language\n- an Alex, Ocamllex, JLex, or Flex lexer generator file\n- a Happy, Ocamlyacc, Menhir, ANTLR, CUP, or Bison parser generator file\n- a pretty-printer as a Haskell/Agda/C/C++/Java/Ocaml module\n- a Latex file containing a readable specification of the language\n\n*More information*: http://bnfc.digitalgrammars.com/\n\nInstallation\n------------\n\nSome binaries are available at https://github.com/BNFC/bnfc/releases.\nInstallation from the Haskell sources is possible via `stack` or `cabal`.\n\n### Installation via stack (recommended)\n\nYou need a running installation of\n[stack](https://docs.haskellstack.org/en/stable/install_and_upgrade/).\nTo install and run the latest version of\n[bnfc from stackage](https://www.stackage.org/package/BNFC),\nenter at the command line:\n\n```\n  stack install BNFC\n  bnfc --help\n```\n\nBNFC versions in major Stackage LTS snapshots:\n\n|  GHC   |  LTS  |  BNFC   |\n|--------|-------|---------|\n| 8.8.4  | 16.31 | 2.8.4   |\n| 8.10.7 | 18.28 | 2.9.4   |\n| 9.0.2  | 19.33 | 2.9.4   |\n| 9.2.8  | 20.26 | 2.9.4.1 |\n| 9.4.8  | 21.25 | 2.9.5   |\n\n### Installation via cabal\n\nYou need a running installation of a recent version of\n[GHC](https://www.haskell.org/ghc/) and\n[Cabal](https://www.haskell.org/cabal/), most easily available via the\n[GHCup](https://www.haskell.org/ghcup/).  To install\n[bnfc from hackage](https://hackage.haskell.org/package/BNFC),\nenter at the command line:\n```\n  cabal install BNFC\n  bnfc --help\n```\n\n### Installing the development version\n\nTo install the\n[development version of bnfc](https://github.com/BNFC/bnfc)\nwith the latest bugfixes (and regressions ;-)):\n```\n  git clone https://github.com/BNFC/bnfc.git\n  cd bnfc/source\n```\nand then either\n```\n  cabal install\n```\nor\n```\n  stack install --stack-yaml stack-9.4.yaml\n```\n(replace `9.4` with your GHC major version, and if you want to build with\nyour installed GHC then add flag `--system-ghc`).\n\nMini tutorial\n-------------\n\n- Build a first parser in 5 min (Haskell backend):\n\n  1. In a fresh directory, prepare a grammar file `Sum.cf` with the following content:\n     ```\n     EInt.  Exp ::= Integer;\n     EPlus. Exp ::= Exp \"+\" Integer;\n     ```\n  2. Build a parser (in Haskell) with bnfc:\n     ```\n     bnfc -d -m Sum.cf  \u0026\u0026  make\n     ```\n     The `make` step needs the Haskell compiler [GHC](https://www.haskell.org/ghc/), the lexer\n     generator [alex](https://www.haskell.org/alex/) and the parser generator [happy](https://www.haskell.org/happy/) (all included in the GHC installation).\n\n  3. Inspect the generated files in directory `Sum`.\n  4. Test the parser.\n     ```\n     echo \"1 + 2 + 3\" | Sum/Test\n     ```\n\n- Try the C-family backends. (The prerequisites, GNU C(++) compiler\n  (`gcc` / `g++`), lexer generator `flex` and parser generator `bison`,\n  are usually present):\n  ```\n  bnfc --c   -m -o sum-c   Sum.cf  \u0026\u0026  make -C sum-c    \u0026\u0026  echo \"1 + 2 + 3\" | sum-c/TestSum\n  bnfc --cpp -m -o sum-cpp Sum.cf  \u0026\u0026  make -C sum-cpp  \u0026\u0026  echo \"1 + 2 + 3\" | sum-cpp/TestSum\n  ```\n\n- Try the other backends:\n\n  | Option  | Backend  |\n  | --- | --- |\n  | `--java` | Requires Java, [JLex](https://www.cs.princeton.edu/~appel/modern/java/JLex/) or [JFlex](https://jflex.de/), and [CUP](http://www2.cs.tum.edu/projects/cup/).|\n  | `--java-antlr` | Requires [ANTLR](https://www.antlr.org/).|\n  | `--ocaml` | Requires [OCaml](https://ocaml.org/), `ocamllex` and `ocamlyacc`.|\n  | `--ocaml-menhir` | Uses [menhir](http://gallium.inria.fr/~fpottier/menhir/) instead of `ocamlyacc`.|\n  | `--agda` | Produces [Agda](https://agda-lang.org) bindings to the parser generated for Haskell.|\n  | `--pygments` | Produces a lexer definition for the Python highlighting suite [Pygments](https://pygments.org/).|\n\nDocumentation\n-------------\n\nhttps://bnfc.readthedocs.org/en/latest/\n\nSupport\n-------\n\nYou can discuss with us issues around bnfc on our mailing list bnfc-dev@googlegroups.com.\n\nFor current limitations of bnfc, or to report a new bug, please consult our [issue tracker](https://github.com/BNFC/bnfc/issues).\n\nContribute\n----------\n\n- Issue Tracker: https://github.com/BNFC/bnfc/issues\n- Source Code: https://github.com/BNFC/bnfc\n- Haskell coding style guide: https://github.com/andreasabel/haskell-style-guide/\n- Some pull request etiquette:\n  * Document, document, document!  (See style guide)\n  * Include test cases that cover your feature.\n  * Include changelog entry.\n  * More etiquette: E.g. https://gist.github.com/mikepea/863f63d6e37281e329f8\n\nLicense\n-------\n\nThe project is licensed under the [BSD 3-clause license](https://raw.githubusercontent.com/BNFC/bnfc/master/source/LICENSE).\n\nBNFC versions until 2.8.4 released under the\n[GNU General Public License](https://www.gnu.org/licenses/gpl-2.0.html).\n\nExample uses of the BNF Converter\n---------------------------------\n\nIn research:\n- NASA's [OGMA](https://github.com/nasa/ogma) tool uses LBNF for its grammars, e.g. for a [subset of C 99](https://github.com/nasa/ogma/blob/49e78e4d6fa7558d09d36a284648087df48714e4/ogma-language-c/grammar/C.cf).\n\nIn teaching:\n- Course [Programming Language Technology](http://www.cse.chalmers.se/edu/course/DAT151/) at Chalmers / Gothenburg University.\n","funding_links":[],"categories":["TeX"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBNFC%2Fbnfc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBNFC%2Fbnfc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBNFC%2Fbnfc/lists"}