Registry / serialization / antlr4-tools

antlr4-tools

JSON →
library0.2.2pypypi✓ verified 83d ago

Provides command-line tools (`antlr4`, `grun`) to run ANTLR4 (All-Star) and the TestRig grammar interpreter/profiler. This package is a convenience wrapper for ANTLR4, often used in conjunction with ANTLR4 runtime libraries. Current version 0.2.2, low release cadence.

pip install antlr4-tools
INSTALL
IMPORT
SIG · ANTLR4-TOOLS
A
antlr4-tools
serializationpythonv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

antlr4_tool_runner
import antlr4_tool_runner
from antlr4 import *
run_cli
from antlr4_tool_runner import run_cli
from antlr4 import *
download_antlr4
from antlr4_tool_runner import download_antlr4
from antlr4 import *

Example using antlr4 runtime to parse input file (requires generated parser).

import sys import antlr4 from antlr4 import * # Generate parser (run separately: antlr4 -Dlanguage=Python3 MyGrammar.g4) from MyGrammarLexer import MyGrammarLexer from MyGrammarParser import MyGrammarParser def main(): input_stream = FileStream(sys.argv[1]) lexer = MyGrammarLexer(input_stream) stream = CommonTokenStream(lexer) parser = MyGrammarParser(stream) tree = parser.prog() print(tree.toStringTree(recog=parser)) if __name__ == '__main__': main()
antlr4 --version
Debug
Known issues
deprecatedantlr4-tools includes `grun` alias for `org.antlr.v4.gui.TestRig`; this is legacy and may be removed.
fix
Use `java org.antlr.v4.gui.TestRig` directly.
affects: all
gotchaPackage does not include the ANTLR4 runtime for Python. You must install `antlr4-python3-runtime` separately.
fix
Run `pip install antlr4-python3-runtime`.
affects: all
gotchaThe `antlr4` command only works if Java is installed. No Python-based ANTLR tool is provided.
fix
Install Java (JDK 8+).
affects: all
Upgrade
Version history
0.2.2latest on PyPI · released Apr 27, 2025
Audit
Dependencies
antlr4-python3-runtimerequiredProvides ANTLR4 runtime classes used by generated parsers
Agent activity
43 hits · last 30 days
node
36
OpenAI (training)
1
Resources
antlr4-tools — pip install antlr4-tools · libregistry