{"id":51297712,"url":"https://github.com/zuzukin/antlrope","last_synced_at":"2026-06-30T16:01:29.797Z","repository":{"id":365023492,"uuid":"1255446966","full_name":"zuzukin/antlrope","owner":"zuzukin","description":"Fast interface to python antlr4 based on antlr C++ runtime","archived":false,"fork":false,"pushed_at":"2026-06-19T23:07:47.000Z","size":1056,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2026-06-20T01:07:01.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/zuzukin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-31T20:51:46.000Z","updated_at":"2026-06-19T23:07:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zuzukin/antlrope","commit_stats":null,"previous_names":["zuzukin/antlr-pyfacade","zuzukin/antlrope"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/zuzukin/antlrope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuzukin%2Fantlrope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuzukin%2Fantlrope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuzukin%2Fantlrope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuzukin%2Fantlrope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuzukin","download_url":"https://codeload.github.com/zuzukin/antlrope/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuzukin%2Fantlrope/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34973617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":[],"created_at":"2026-06-30T16:01:25.804Z","updated_at":"2026-06-30T16:01:29.761Z","avatar_url":"https://github.com/zuzukin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"docs/assets/logo-dark.svg\"\u003e\n    \u003cimg alt=\"antlrope\" src=\"docs/assets/logo.svg\" width=\"420\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\nA fast, C++-accelerated [ANTLR](https://www.antlr.org/) runtime for Python for target-agnostic grammars\n\n*antl**rope*** = ANTLR + **O**rdered **P**arse **E**vents — your parse delivered as one ordered stream of events, not a per-node tree walk.\n\n\u003e **10–20× faster** than the official pure-Python `antlr4-python3-runtime` on\n\u003e workloads that touch most nodes — and more when your listener subscribes to\n\u003e only a subset of the grammar.\n\n[![Parsing and reading a 2.6 MB SystemRDL file: antlrope is ~21x faster than the pure-Python runtime and ~8x faster than the speedy-antlr accelerator, at lower peak memory](docs/benchmarks/systemrdl.svg)](docs/benchmarks/systemrdl.md)\n\n\u003csub\u003eParsing + reading a real 2.6 MB SystemRDL file — see the [full benchmark](docs/benchmarks/systemrdl.md) (vs the pure-Python runtime and the `speedy-antlr` accelerator).\u003c/sub\u003e\n\nGenerate your parser with the ordinary ANTLR tool targeting Python, install\nthis package, generate a small *facade* class, and write a pure-Python event listener.\nParsing itself runs inside the official ANTLR4 **C++** runtime, driven directly\nfrom the serialized ATN (Augmented Transition Network) the stock Python target already emits.\nInstead of a per-node parse-tree walk (one foreign-function crossing per tree node), the C++\nside collects a **single bulk, filtered event stream** and hands it to Python in\none transfer — and it drops the rules/tokens your listener doesn't subscribe to\n*before* they ever reach Python.\n\nIt complements, rather than replaces, the official `antlr4-python3-runtime`: same\ngenerated parser, a faster way to consume it.\n\n## Install\n\nFrom PyPI:\n\n```sh\npip install antlrope\n```\n\nOr from conda-forge (with conda, mamba, or pixi):\n\n```sh\nconda install -c conda-forge antlrope\n```\n\nEither way you get a pre-compiled binary — nothing to build — and the official\n`antlr4-python3-runtime` is pulled in automatically.\n\n## Quickstart\n\n1. **Generate your parser** with the stock ANTLR tool (Python target):\n\n   ```sh\n   antlr4 -Dlanguage=Python3 MyGrammar.g4 -o generated\n   ```\n\n2. **Generate the facade** from the generated parser module:\n\n   ```sh\n   antlrope gen generated.MyGrammarParser MyGrammar -o my_listener.py\n   ```\n\n   This emits a `MyGrammarEventListener` base class with `enter\u003cRule\u003e` /\n   `exit\u003cRule\u003e` / `visitTerminal` / `visitError` stubs and token-type constants.\n   The facade also imports and bakes in your lexer/parser, so you never pass them\n   at parse time. The lexer module is derived from the parser's by ANTLR's\n   `\u003cGrammar\u003eLexer` / `\u003cGrammar\u003eParser` convention; pass `--lexer` if yours is\n   named differently.\n\n3. **Subclass it** and override only the callbacks you care about:\n\n   ```python\n   from my_listener import MyGrammarEventListener\n\n   class Collector(MyGrammarEventListener):\n       def enterPair(self) -\u003e None:\n           ...\n       def visitTerminal(self, token_type: int, text: str) -\u003e None:\n           ...\n\n   Collector().walk(source_text)\n   ```\n\nOnly the callbacks you override drive native masks, so the C++ side skips every\nother rule/token — the fewer node kinds you subscribe to, the faster the walk.\n\n## How it works\n\n- The C++ extension deserializes the ATN from your generated lexer/parser and\n  drives `LexerInterpreter` / `ParserInterpreter` — no generated C++ parser.\n- A native iterative DFS over the finished parse tree appends fixed\n  `(kind, payload, start, stop)` int32 records to one buffer (`parse_events`).\n- `kind`: `0=ENTER_RULE, 1=EXIT_RULE, 2=TERMINAL, 3=ERROR`; `payload` is the rule\n  index or token type; `start`/`stop` are char indices into the source (`-1` for\n  rule events). Token text is recovered Python-side by slicing\n  `text[start:stop + 1]` — no string copies cross the boundary.\n- Rule/token masks built from your overrides filter the stream in C++.\n\n## Limitations\n\nThis can only be used for target-language-agnostic grammars.\nThis runtime executes the **interpreted ATN**; it cannot run target-language\n**semantic predicates or embedded grammar actions**. Grammars that depend on\nthem will not parse correctly here. See `docs/` for the full discussion and the\nperformance characteristics of the bulk event-stream approach.\n\n## Contributing\n\nDevelopment setup, pixi environments, and the vendored-runtime workflow live in\n[CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Documentation\n\nFull documentation: **[zuzukin.github.io/antlrope](https://zuzukin.github.io/antlrope/)**.\nIn the repo, see [`docs/`](docs/index.md): [getting started](docs/getting-started.md),\n[installation](docs/installation.md),\n[API reference](docs/reference/api.md),\n[chunking](docs/chunking.md),\n[migrating from antlr4-python3-runtime](docs/migrating.md),\n[performance \u0026 limitations](docs/performance.md),\n[how it works](docs/concepts.md), and the\n[SystemRDL benchmark](docs/benchmarks/systemrdl.md).\n\n## License\n\nApache-2.0. Bundles the ANTLR4 C++ runtime (BSD-3-Clause) under\n`vendor/antlr4-cpp/`; see `vendor/antlr4-cpp/UPDATING.md` for provenance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuzukin%2Fantlrope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuzukin%2Fantlrope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuzukin%2Fantlrope/lists"}