Sunday, January 29, 2017

Using antlr4 in IntelliJ



Earlier I wrote about configuring JavaCC in Android Studio / IntelliJ. Since I'm migrating from JavaCC to antlr4, I'll show how to integrate antlr4 to IntellJ.

It's actually less work than configuring JavaCC. All you have to do is to add 2 lines:

plugins {
  // ...
  id "antlr"
}

// ...

dependencies {
  antlr "org.antlr:antlr4:4.6"
  // ...
}

One might ask why switching from one LL(*) parser generator to another LL(*)?  There are many reasons, I'll comment on this later.  One note: antlr4 is not exactly LL(*), it is ALL(*), where A stands for Adaptive.  This difference by itself is a big improvement over JavaCC, where Adaptive part requires careful management by hand.

No comments:

Post a Comment