ANTLR v4 grammar plugin
for IntelliJ IDEA

Compatible with all products except MPS
20.12.2016
92 989

This plugin is for ANTLR v4 grammars and includes ANTLR 4.6. It works with Intellij 13.x-15, 2016.1-2016.3. It should work in other Jetbrains IDEs. I have tested in PyCharm 4.5 and CLion 1.2.

  • syntax highlighting
  • syntax error checking
  • semantic error checking
  • navigation window
  • goto-declaration
  • find usages
  • rename tokens
  • rename rules
  • comment grammar rule lines with meta-/ (1.7)
  • grammar/comment folding (1.7)
  • generates parser code; shortcut (ctrl-shift-G / meta-shift-G) but it's in Tools menu and popups.
  • code completion for tokens, rule names;
  • finds tokenVocab option for code gen if there is a tokenVocab option, don't warn about implicit tokens.
  • handles separate parsers and lectures like TParser.g4 and TLexer.g4 (1.7)
  • Parse tree nodes show the alternative number the parser chose to match that node. (1.7)
  • has live grammar interpreter for grammar preview. Right click on rule and say "Test ANTLR Rule".
  • view parse trees in hierarchy (sideways tree) view. (1.8)
  • can view parse trees for input matched in more than one way (ambiguities) (1.7)
  • can view lookahead trees to show how input directed ANTLR to match a particular alternative (1.7)
  • changes to grammar seen in parse tree upon save of grammar.
  • works with all Jetbrains IDEs (1.8)
  • refactoring: extract rule, inline rule (1.8), dup rule to make refs unique (1.9)

Generates code in /gen/package/YourGrammarRecognizer.java unless you override in the configuration dialog. Shortcut to generate parsers is ctrl-shift-G / meta-shift-G but it's in Tools menu, popups. Code completion for tokens, rule names. finds tokenVocab option for code gen if there is a tokenVocab option, don't warn about implicit tokens. shortcut conflicted with grammar-kit plugin. Has live grammar interpreter for grammar preview. Right click on rule and say "Test ANTLR Rule". Changes to grammar seen in parse tree upon save of grammar.

You can configure the ANTLR tool options per grammar file; right-click in a grammar or on a grammar element within the structured view. When you change and save a grammar, it automatically builds with ANTLR in the background according to the preferences you have set. ANTLR tool errors appear in a console you can opened by clicking on a button in the bottom tab.

You can use the ctrl-key while moving the mouse and it will show you token information in the preview editor box via tooltips.

Errors within the preview editor are now highlighted with tooltips and underlining just like a regular editor window. The difference is that this window's grammar is specified in your grammar file.

See README.md for more details.

For really big files and slow grammars, there is an appreciable delay when displaying the parse tree or profiling information.

Github source

Download plugin

Recent change notes

This release updates internal ANTLR from 4.5.3 to 4.6 and fixed a bug where \r\n wasn't tracked properly causes issues when highlighting some grammar elements.
20.12.2016
Great tool, but workspace.xml is not the right place for saving its per-file code generation preferences. They are essentially build settings, so they should go into project settings tracked by a VCS, not into a personal preferences file.
Anonymous
26.12.2015
This is my tool of choice when fiddling with antlr grammars, love it!
Anonymous
14.02.2015
Pretty nifty alternative to ANTLRWorks if you are an IDEA user. Very helpful for visualizing grammars! Thanks!
22.03.2014
Great plugin! I love the fact you can dynamically test the generated parser by typing some input source that should be parsed and immediately see the parse tree. Really cool!
25.02.2014
Link to github source https://github.com/antlr/intellij-plugin-v4
Please  sign in  to leave a comment.