{"id":13994922,"url":"https://github.com/jmillikin/rules_bison","last_synced_at":"2026-05-04T02:43:47.970Z","repository":{"id":48944899,"uuid":"162051544","full_name":"jmillikin/rules_bison","owner":"jmillikin","description":"Bazel build rules for GNU Bison","archived":false,"fork":false,"pushed_at":"2024-08-01T18:57:58.000Z","size":107,"stargazers_count":15,"open_issues_count":5,"forks_count":24,"subscribers_count":4,"default_branch":"trunk","last_synced_at":"2024-08-10T14:17:33.165Z","etag":null,"topics":["bazel","bison"],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jmillikin.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":"2018-12-16T23:46:38.000Z","updated_at":"2024-02-16T18:38:05.000Z","dependencies_parsed_at":"2023-01-28T06:46:21.438Z","dependency_job_id":null,"html_url":"https://github.com/jmillikin/rules_bison","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_bison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_bison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_bison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmillikin%2Frules_bison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmillikin","download_url":"https://codeload.github.com/jmillikin/rules_bison/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227177688,"owners_count":17743144,"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":["bazel","bison"],"created_at":"2024-08-09T14:03:10.733Z","updated_at":"2026-05-04T02:43:42.917Z","avatar_url":"https://github.com/jmillikin.png","language":"Starlark","funding_links":[],"categories":["Starlark"],"sub_categories":[],"readme":"# Bazel build rules for GNU Bison\n\nThis Bazel ruleset allows [GNU Bison] to be integrated into a Bazel build. It\ncan be used to generate parsers in C, C++, or Java.\n\nAPI reference: [docs/rules_bison.md](docs/rules_bison.md)\n\n[GNU Bison]: https://www.gnu.org/software/bison/\n\n## Setup\n\nAdd the following to your `MODULE.bazel`:\n\n```python\nbazel_dep(name = \"rules_bison\", version = \"0.4\")\n```\n\nTo specify a version or build with additional C compiler options, use the\n`bison_repository_ext` module extension:\n\n```python\nbison = use_extension(\n    \"@rules_bison//bison/extensions:bison_repository_ext.bzl\",\n    \"bison_repository_ext\",\n)\nbison.repository(\n    name = \"bison\",\n    version = \"3.3.2\",\n    extra_copts = [\"-O3\"],\n)\nuse_repo(bison, \"bison\")\nregister_toolchains(\"@bison//:toolchain\")\n```\n\nNote that repository names registered with a given bzlmod module extension must\nbe unique within the scope of that extension. See the [Bazel module extensions]\ndocumentation for more details.\n\n[Bazel module extensions]: https://bazel.build/external/extension\n\n## Examples\n\nIntegrating Bison into a C/C++ dependency graph:\n\n```python\nload(\"@rules_bison//bison:bison.bzl\", \"bison_cc_library\")\n\nbison_cc_library(\n    name = \"hello_parser\",\n    src = \"hello.y\",\n)\n\ncc_binary(\n    name = \"hello\",\n    deps = [\":hello_parser\"],\n)\n```\n\nIntegrating Bison into a Java dependency graph:\n\n```python\nload(\"@rules_bison//bison:bison.bzl\", \"bison_java_library\")\n\nbison_java_library(\n    name = \"HelloParser\",\n    src = \"hello.y\",\n)\n\njava_binary(\n    name = \"Hello\",\n    srcs = [\"Hello.java\"],\n    main_class = \"Hello\",\n    deps = [\":HelloParser\"],\n)\n```\n\nGenerating `.c` / `.h` / `.cc` source files (not as a `CcInfo`):\n\n```python\nload(\"@rules_bison//bison:bison.bzl\", \"bison\")\n\nbison(\n    name = \"hello_parser_srcs\",\n    src = \"hello.y\",\n)\n\ncc_binary(\n    name = \"hello\",\n    srcs = [\":hello_parser_srcs\"],\n)\n```\n\nRunning Bison in a `genrule`:\n\n```python\ngenrule(\n    name = \"hello_gen\",\n    srcs = [\"hello.y\"],\n    outs = [\"hello_gen.c\"],\n    cmd = \"M4=$(M4) $(BISON) --output=$@ $\u003c\",\n    toolchains = [\n        \"@rules_bison//bison:current_bison_toolchain\",\n        \"@rules_m4//m4:current_m4_toolchain\",\n    ],\n)\n```\n\nWriting a custom rule that depends on Bison as a toolchain:\n\n```python\nload(\"@rules_bison//bison:bison.bzl\", \"BISON_TOOLCHAIN_TYPE\", \"bison_toolchain\")\nload(\"@rules_m4//m4:m4.bzl\", \"M4_TOOLCHAIN_TYPE\")\n\ndef _my_rule(ctx):\n    bison = bison_toolchain(ctx)\n    ctx.actions.run(\n        executable = bison.bison_tool,\n        env = bison.bison_env,\n        # ...\n    )\n\nmy_rule = rule(\n    implementation = _my_rule,\n    toolchains = [\n        BISON_TOOLCHAIN_TYPE,\n        M4_TOOLCHAIN_TYPE,\n    ],\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmillikin%2Frules_bison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmillikin%2Frules_bison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmillikin%2Frules_bison/lists"}