ANTLR
.g4 file) and it emits a complete lexer, parser, and parse-tree walkers in Java, C#, Python, JavaScript, Go, C++, Swift, TypeScript, and more. It is the production shortcut — and the industry default — from grammar to compiler front end.
Purpose
ANTLR moves the mechanical part of language recognition into a tool, so the grammar itself stays the only specification.
The Problem It Solves
Hand-written recursive descent (this roadmap’s Phase 1 mini-parser) is the right default for tiny languages, but it stops scaling when the grammar grows: precedence, error recovery, and ambiguity audits become full-time work. ANTLR turns the grammar into lexer + parser + walkers, validates it, and reports ambiguity before users ever hit it. You write rules; the recognizer is generated.
Where It Fits
ANTLR is a front-end factory rather than a language you code in — its “language” is the grammar DSL itself. Racket (next page) gives you macros and #lang for language design; OCaml (after it) gives you a type-safe implementation language. All three build DSLs and compilers, so they sit together in their own phase, DSL Implementation Languages, right after the Implementation phase.
History
A single creator with a thirty-year arc, and a v4 line that removed most of the old tooling friction.
Origins
Terence Parr has worked on language tools since 1989; ANTLR is his long-running project (originally PCCTS). ANTLR v4, current since 2013, replaced the hand-rolled lookahead machinery of v3 with adaptive LL(*) parsing: the recognizer decides between alternatives at run time from the actual input, which is why common grammars — including direct left recursion — work without rewriting.
Adoption
ANTLR is used at Google and was the query parser for Twitter search; Apache Hive and Groovy are long-time users. Guido van Rossum, Python’s creator, publicly praised it — evidence that even the author of a famous language reaches for a parser generator when the grammar outgrows the hand-rolled approach.
Stage
Stable, production-proven, and under active maintenance.
Maturity
The v4 line has been the safe default for a decade or more; the tool runs on a JVM and ships runtime libraries for every major language. Grammar files survive minor releases, and the project’s “Getting Started” path (pip install antlr4-tools) installs Java and ANTLR for you.
Stability Practice
Pin the exact ANTLR tool and runtime versions together in your build (they match release-for-release). The generated code is plain source in your repository — commit it and regenerate on version bumps.
Popularity & Usability
One of the most widely used parser generators in industry, with a shallow learning curve for small grammars.
Adoption
ANTLR is the default recommendation in countless language-engineering posts and books; the antlr/grammars-v4 repository collects hundreds of real, readable grammars you can study or adapt.
Learning Curve
One file to learn — terminal rules (uppercase), parser rules (lowercase), actions — plus IDE plugins (IntelliJ) and the official book The Definitive ANTLR 4 Reference. Errors are reported against the grammar, which keeps debugging inside the spec.
Use Cases
Anything that must read structured input and then do something with it.
DSL & Query Front Ends
Grammar first, then a listener or visitor defines what the parse tree means — the classic shape for configuration DSLs, expression languages, and query parsers (Twitter search, Hive SQL).
Translation & Instrumentation
Tools that read one structured format and emit another (ANTLR integrates with the StringTemplate engine), plus linters, formatters, and IDE instrumentation where source is scanned and rewritten. Structured binary input is supported too, not just text.
Performance
Generated recognizers are fast where it matters, and the walkers remove the traversal code you would otherwise write.
Recognition Cost
For unambiguous grammars the parser runs in linear time; adaptive prediction spends extra work only on genuinely ambiguous alternatives — which the tool flags at build time so you can fix the grammar instead of the runtime.
Listeners & Visitors
The generator produces a default pre-order listener (fire-and-forget callbacks) and a visitor (explicit return values). You extend one method per rule name — no manual tree traversal, no switch statements over node kinds.
Example
A complete arithmetic grammar — the same mini-language this roadmap parses by hand in Phase 1 — plus the two commands that turn it into working recognizers.
Expr.g4 (commented)
grammar Expr ; // file name must match the grammar name
// parser rules (lowercase): expr is left-recursive — v4 handles that natively
program : ( expr NEWLINE )* ; // zero or more lines, each an expression
expr : expr ('*' | '/') expr // '*' and '/' bind tighter because
| expr ('+' | '-') expr // ... they appear earlier in the list
| INT // a bare integer is the base case
| '(' expr ')' // parentheses override precedence
;
// lexer rules (UPPERCASE): how characters become tokens
NEWLINE : [\r\n]+ ; // one or more line endings
INT : [0-9]+ ; // one or more digits
// WS : [ \t]+ -> skip ; // uncomment to ignore spaces
Run It
# one-time install: the launcher bundles Java + ANTLR for you
pip install antlr4-tools
# parse interactively and draw the tree for "10+20*30"
antlr4-parse Expr.g4 program -gui
# or generate a parser in your target language (Python shown)
antlr4 -Dlanguage=Python3 Expr.g4 # creates ExprLexer.py, ExprParser.py, ...
Compare this file with the hand-written parser on the Parsing & Trees page: the grammar declares the surface syntax, the generator produces the recognizer, and a single visitor method per rule adds the meaning.
Learn More
Official sources and free materials; the full categorized catalog is on the References & Downloads page.
Official Docs & Downloads
- antlr.org — getting started, downloads, and the ANTLR Lab
- antlr/antlr4 — source, releases, and runtime libraries
- grammars-v4 — hundreds of ready-to-read grammars
- ANTLR Documentation — the free official grammar, tool, and runtime reference