
grammars-v4
A large collection of ready-made ANTLR v4 grammars for many languages and file formats.
- Stars
- 11.1k
- Forks
- 3.8k
- Licence
- MIT
- Language
- ANTLR
- Last update
- 6 days ago
- Type
- Learning resource
What it is
This repository is a collection of formal grammars written for ANTLR v4, a parser generator tool. A grammar describes the structure of a language or file format, so a parser can read code or data written in it. Each top-level folder is named after the language or format it covers, such as java or cpp, so you can find a grammar by name.
- Pick a grammar folder such as java or csharp as a base for a parser in your own project
- Compare how different grammars are written for a language you care about
- Use the grammar performance table linked in the README to compare grammars
Great for
- Developers who want a starting grammar for a language or file format instead of writing one from scratch
- People building parsers, linters, or code analysis tools with ANTLR
- Students learning how formal grammars describe real languages
Not ideal for
- People who need a finished application; this is a set of grammar files, not a program
- Users who do not work with parsers or ANTLR, since the grammars need ANTLR to be used
- Anyone expecting every grammar to be fully verified; the README does not describe per-grammar testing guarantees
How to get it
- 1
Clone and build from source
You'll need: ANTLR v4 tool
Clone the repository
git clone https://github.com/antlr/grammars-v4 - 2
Run it
- Clone the repository
- Open the folder for the language you need, such as java
- Use the grammar files with the ANTLR v4 tool to generate a parser in your project
- Check the wiki for FAQ and usage details
- 3
Get the most out of it
- Read the grammar performance table to compare grammars before choosing one
- Check the wiki for FAQ answers the README points to
- Use the weekly JAR build badges linked in the README to track build status of the collection
Downloads
Strengths
- Covers many languages and file formats in one place
- Grammars are organized by language name, which makes them easy to find
- Released under the MIT license, which permits reuse
Trade-offs
- The README is short and does not explain how to use individual grammars; the wiki holds the FAQ
- Quality and completeness can vary between grammars, so each one needs checking for your use
- The description says grammars are expected to be free of actions, which means you may need to add your own code to use them
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.