{"id":26721,"library":"antlr4-tools","title":"ANTLR4 Tools","description":"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.","status":"active","version":"0.2.2","language":"python","source_language":"en","source_url":"https://github.com/antlr/antlr4-tools","tags":["antlr","parser","lexer","testing","profiling"],"install":[{"cmd":"pip install antlr4-tools","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Provides ANTLR4 runtime classes used by generated parsers","package":"antlr4-python3-runtime","optional":false}],"imports":[{"note":"antlr4-tools does not expose Python modules; use antlr4 runtime instead.","wrong":"import antlr4_tools","symbol":"antlr4","correct":"from antlr4 import *"}],"quickstart":{"code":"import sys\nimport antlr4\nfrom antlr4 import *\n\n# Generate parser (run separately: antlr4 -Dlanguage=Python3 MyGrammar.g4)\nfrom MyGrammarLexer import MyGrammarLexer\nfrom MyGrammarParser import MyGrammarParser\n\ndef main():\n    input_stream = FileStream(sys.argv[1])\n    lexer = MyGrammarLexer(input_stream)\n    stream = CommonTokenStream(lexer)\n    parser = MyGrammarParser(stream)\n    tree = parser.prog()\n    print(tree.toStringTree(recog=parser))\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"Example using antlr4 runtime to parse input file (requires generated parser)."},"warnings":[{"fix":"Use `java org.antlr.v4.gui.TestRig` directly.","message":"antlr4-tools includes `grun` alias for `org.antlr.v4.gui.TestRig`; this is legacy and may be removed.","severity":"deprecated","affected_versions":"all"},{"fix":"Run `pip install antlr4-python3-runtime`.","message":"Package does not include the ANTLR4 runtime for Python. You must install `antlr4-python3-runtime` separately.","severity":"gotcha","affected_versions":"all"},{"fix":"Install Java (JDK 8+).","message":"The `antlr4` command only works if Java is installed. No Python-based ANTLR tool is provided.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"`pip install antlr4-python3-runtime`","cause":"Missing ANTLR4 runtime for Python.","error":"ImportError: No module named 'antlr4'"},{"fix":"Run `pip install antlr4-tools` and ensure the scripts directory is in PATH.","cause":"antlr4-tools not installed or not in PATH.","error":"antlr4: command not found"},{"fix":"Use `antlr4` command from antlr4-tools or run `java -jar /path/to/antlr-4.13.1-complete.jar`.","cause":"Using standalone jar without proper classpath.","error":"java -jar antlr-4.13.1-complete.jar fails with 'Could not find or load main class org.antlr.v4.Tool'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}