{"id":13598042,"url":"https://github.com/katef/kgt","last_synced_at":"2025-04-04T15:10:34.270Z","repository":{"id":43427710,"uuid":"80591696","full_name":"katef/kgt","owner":"katef","description":"BNF wrangling and railroad diagrams","archived":false,"fork":false,"pushed_at":"2023-09-25T13:09:05.000Z","size":1338,"stargazers_count":600,"open_issues_count":20,"forks_count":30,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-03-28T14:09:27.637Z","etag":null,"topics":["abnf","bnf","cfgs","chomsky","compiler","compiler-designs","compiler-principles","compilers","ebnf","grammar","grammar-specification","grammars","parser","parser-library","parsing","syntax","syntax-tree","wsn"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/katef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["katef"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-02-01T05:13:03.000Z","updated_at":"2025-03-28T10:07:45.000Z","dependencies_parsed_at":"2024-01-13T15:38:18.687Z","dependency_job_id":"815df8fe-a6d6-4975-ac14-e5788dd2bc2e","html_url":"https://github.com/katef/kgt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katef%2Fkgt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katef%2Fkgt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katef%2Fkgt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katef%2Fkgt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katef","download_url":"https://codeload.github.com/katef/kgt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198463,"owners_count":20900080,"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":["abnf","bnf","cfgs","chomsky","compiler","compiler-designs","compiler-principles","compilers","ebnf","grammar","grammar-specification","grammars","parser","parser-library","parsing","syntax","syntax-tree","wsn"],"created_at":"2024-08-01T17:00:46.806Z","updated_at":"2025-04-04T15:10:34.249Z","avatar_url":"https://github.com/katef.png","language":"C","readme":"\n## KGT: Kate's Grammar Tool\n\nDo you want to convert various kinds of BNF to other kinds of BNF? No?  \nWell imagine if you did! This would be the tool for you.\n\n Input:  Various BNF-like syntaxes  \n Output: Various BNF-like syntaxes, AST dumps, and Railroad Syntax Diagrams\n\nCompilation phases:\n\n![phases.svg](doc/tutorial/phases.svg)\n\n- Bold indicates the input BNF dialects with the most features\n- ✨ indicates presentational formats (these are the good ones!)\n- 🧪 indicates debugging formats.  \n  You don't want these unless you're looking at kgt's internals.\n- Other formats provide various subsets of features\n\nGallery:\n\n- C89 grammar [WSN source](/examples/c_syntax.wsn)  \n  → Presentational BNF:\n  [EBNF](https://katef.github.io/kgt/doc/gallery/c89-ebnf.html)  \n  → Railroad diagrams:\n  [SVG](https://katef.github.io/kgt/doc/gallery/c89-rrd.html),\n  [ASCII](https://katef.github.io/kgt/doc/gallery/c89-ascii.txt),\n  [UTF8](https://katef.github.io/kgt/doc/gallery/c89-utf8.txt)   ✨ Look at these ones! ✨\n- C99 grammar [EBNF source](/examples/c99-grammar.iso-ebnf)  \n  → Presentational BNF:\n  [EBNF](https://katef.github.io/kgt/doc/gallery/c99-ebnf.html)  \n  → Railroad diagrams:\n  [SVG](https://katef.github.io/kgt/doc/gallery/c99-rrd.html),\n  [ASCII](https://katef.github.io/kgt/doc/gallery/c99-ascii.txt),\n  [UTF8](https://katef.github.io/kgt/doc/gallery/c99-utf8.txt)\n\nGetting started:\n\nSee the [/examples](examples/) directory for grammars in various\nBNF dialects. These have been collated from various sources and\nare of various quality. BNF dialects tend to be poorly specified,\nand these examples are an attempt to keep a corpus of known-good\nexamples for each dialect. kgt can't parse them all yet.\n\nkgt reads from _stdin_ in dialect `-l ...` and writes to _stdout_\nin format `-e ...`:\n\n    ; kgt -l bnf -e rrutf8 \u003c examples/expr.bnf\n    expr:\n        │├──╮── term ── \"+\" ── expr ──╭──┤│\n            │                         │\n            ╰───────── term ──────────╯\n    \n    term:\n        │├──╮── factor ── \"*\" ── term ──╭──┤│\n            │                           │\n            ╰───────── factor ──────────╯\n    \n    factor:\n        │├──╮── \"(\" ── expr ── \")\" ──╭──┤│\n            │                        │\n            ╰──────── const ─────────╯\n    \n    const:\n        │├── integer ──┤│\n\nand the same grammar output as SVG instead:\n\n    ; kgt -l bnf -e svg \u003c examples/expr.bnf \u003e /tmp/expr.svg\n\n![expr.svg](examples/expr.svg)\n\n### Building from source\n\nClone with submodules (contains required .mk files):\n\n    ; git clone --recursive https://github.com/katef/kgt.git\n\nTo build and install:\n\n    ; bmake -r install\n\nYou can override a few things:\n\n    ; CC=clang bmake -r\n    ; PREFIX=$HOME bmake -r install\n\nYou need bmake for building. In order of preference:\n\n 1. If you use some kind of BSD (NetBSD, OpenBSD, FreeBSD, ...) this is make(1).\n    They all differ slightly. Any of them should work.\n 2. If you use Linux or MacOS and you have a package named bmake, use that.\n 3. If you use Linux and you have a package named pmake, use that.\n    It's the same thing.\n    Some package managers have bmake packaged under the name pmake.\n    I don't know why they name it pmake.\n 4. Otherwise if you use MacOS and you only have a package named bsdmake, use that.\n    It's Apple's own fork of bmake.\n    It should also work but it's harder for me to test.\n 5. If none of these are options for you, you can build bmake from source.\n    You don't need mk.tar.gz, just bmake.tar.gz. This will always work.\n    https://www.crufty.net/help/sjg/bmake.html\n\nWhen you see \"bmake\" in the build instructions above, it means any of these.\n\nBuilding depends on:\n\n * Any BSD make.\n * A C compiler. Any should do, but GCC and clang are best supported.\n * ar, ld, and a bunch of other stuff you probably already have.\n\nIdeas, comments or bugs: kate@elide.org\n\n","funding_links":["https://github.com/sponsors/katef"],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatef%2Fkgt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatef%2Fkgt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatef%2Fkgt/lists"}