{"id":18026764,"url":"https://github.com/yegor256/antlr2ebnf-maven-plugin","last_synced_at":"2025-03-27T01:31:23.959Z","repository":{"id":193683204,"uuid":"689291128","full_name":"yegor256/antlr2ebnf-maven-plugin","owner":"yegor256","description":"Converts ANTLR grammar .g4 files into EBNF for naive-ebnf LaTeX package; also converts to PDF later on","archived":false,"fork":false,"pushed_at":"2024-10-29T08:44:40.000Z","size":124,"stargazers_count":9,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T09:57:03.939Z","etag":null,"topics":["antlr4","ebnf","ebnf-language","java","maven-plugin"],"latest_commit_sha":null,"homepage":"","language":"Java","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/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-09-09T10:57:36.000Z","updated_at":"2024-10-21T08:52:50.000Z","dependencies_parsed_at":"2024-04-08T20:34:37.124Z","dependency_job_id":"a1afb409-f2f3-4945-9fbd-9bb789d4a8b3","html_url":"https://github.com/yegor256/antlr2ebnf-maven-plugin","commit_stats":null,"previous_names":["yegor256/antlr2ebnf-maven-plugin"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fantlr2ebnf-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fantlr2ebnf-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fantlr2ebnf-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fantlr2ebnf-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/antlr2ebnf-maven-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245764689,"owners_count":20668461,"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":["antlr4","ebnf","ebnf-language","java","maven-plugin"],"created_at":"2024-10-30T08:07:57.181Z","updated_at":"2025-03-27T01:31:23.947Z","avatar_url":"https://github.com/yegor256.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ANTLR4 to EBNF in PDF Converter (Maven Plugin)\n\n[![mvn](https://github.com/yegor256/antlr2ebnf-maven-plugin/actions/workflows/mvn.yml/badge.svg)](https://github.com/yegor256/antlr2ebnf-maven-plugin/actions/workflows/mvn.yml)\n[![Maven Central](https://img.shields.io/maven-central/v/com.yegor256/antlr2ebnf-maven-plugin.svg)](https://maven-badges.herokuapp.com/maven-central/com.yegor256/antlr2ebnf-maven-plugin)\n[![Javadoc](http://www.javadoc.io/badge/com.yegor256/antlr2ebnf-maven-plugin.svg)](http://www.javadoc.io/doc/com.yegor256/antlr2ebnf-maven-plugin)\n[![codecov](https://codecov.io/gh/yegor256/antlr2ebnf-maven-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/yegor256/antlr2ebnf-maven-plugin)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/antlr2ebnf-maven-plugin)](https://hitsofcode.com/view/github/yegor256/antlr2ebnf-maven-plugin)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/antlr2ebnf-maven-plugin/blob/master/LICENSE.txt)\n\nThis Maven plugin takes your\n[ANTLR4](https://github.com/antlr/antlr4) grammar `.g4` files\nand generates\n[EBNF](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form)\nin the format expected by the\n[naive-ebnf](https://ctan.org/pkg/naive-ebnf) LaTeX package.\nThen, using `pdflatex` installed on your computer,\nthe plugin renders the generated EBNF as a PDF document\n(you can skip that with the `skipLatex` configuration option).\nThen, you can transform this PDF to SVG or PNG formats,\nusing the tools explained below.\n\nThe plugin expects you to have ANTLR-to-XML converter made by\n[Gunther Rademacher](https://www.bottlecaps.de/convert/),\nin the `target/convert`\ndirectory (normally, there should be five `.jar` files).\n\nJust add it to `pom.xml`:\n\n```xml\n\u003cproject\u003e\n  [...]\n  \u003cbuild\u003e\n    \u003cplugins\u003e\n      \u003cplugin\u003e\n        \u003cgroupId\u003ecom.yegor256\u003c/groupId\u003e\n        \u003cartifactId\u003eantlr2ebnf-maven-plugin\u003c/artifactId\u003e\n        \u003cversion\u003e0.0.7\u003c/version\u003e\n        \u003cexecutions\u003e\n          \u003cexecution\u003e\n            \u003cphase\u003einitialize\u003c/phase\u003e\n            \u003cgoals\u003e\n              \u003cgoal\u003egenerate\u003c/goal\u003e\n            \u003c/goals\u003e\n          \u003c/execution\u003e\n        \u003c/executions\u003e\n      \u003c/plugin\u003e\n    \u003c/plugins\u003e\n  \u003c/build\u003e\n\u003c/project\u003e\n```\n\nIf your ANTLR4 grammar file is in the `src/main/antlr4/foo/bar/Sample.g4` path,\nthe EBNF will be generated in the `target/ebnf/foo/bar/Sample.txt` path and\nthe PDF will be in the `target/ebnf/foo/bar/Sample.pdf` file.\n\nYou can also run this plugin in one line, without adding it to any `pom.xml`\n(Maven is still used, but no project is required, just a directory\nwith `.g4` files):\n\n```bash\nmvn com.yegor256:antlr2ebnf-maven-plugin:generate \\\n  -Dantlr2ebnf.sourceDir=/tmp/antlr4 \\\n  -Dantlr2ebnf.targetDir=/tmp/ebnf \\\n  -Dantlr2ebnf.convertDir=/tmp/convert-jars\n```\n\nThen, if you need PNG and SVG, use\n[pdfcrop](https://ctan.org/pkg/pdfcrop),\n[pdf2svg](https://manpages.ubuntu.com/manpages/xenial/man1/pdf2svg.1.html),\nand\n[convert](https://imagemagick.org/script/convert.php):\n\n```bash\npdfcrop --margins '10 10 10 10' Sample.pdf crop.pdf\npdf2svg crop.pdf Sample.svg\nconvert -density 300 -quality 100 -transparent white -colorspace RGB crop.pdf Sample.png\n```\n\nShould work. If it doesn't, submit a ticket, I will try to help.\n\nSee how this plugin generates PDF diagrams in\n[objectionary/eo](https://github.com/objectionary/eo).\n\n## Options\n\nHere is the full list of options that you may use in the `\u003cconfiguration\u003e`\nof the plugin:\n\n* `skip` — disables the execution of the plugin\n* `skipLatex` — skips PDF generation step, just generates the `.txt` file\n* `sourceDir` — the directory with `.g4` files\n* `targetDir` — the directory where `.txt` and `.pdf` files will be generated\n* `convertDir` — the directory with `.jar` files of the \"convert\" tool\n* `pdflatex` - the name of the `pdflatex` binary\n* `specials` — the list of terms that will be converted to ENBF specials\n* `latexDir` — the directory with temporary LaTeX files\n\nMore of them you can find in [`GenerateMojo.java`][mojo].\n\n[mojo]: https://github.com/yegor256/antlr2ebnf-maven-plugin/blob/master/src/main/java/com/yegor256/antlr2ebnf/GenerateMojo.java\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fantlr2ebnf-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fantlr2ebnf-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fantlr2ebnf-maven-plugin/lists"}