ANTLR and Eclipse (or any decent IDE)

2019-03-26 14:11发布

问题:

I have been using ANTLR with Eclipse for some time using the ANTLRv3IDE plugin. While it is not perfect, and a bit outdated, it does its job reasonably well.

Now I am looking to switch to ANTLRv4 for another DSL that I am creating. However, Eclipse support seems to be extremely thin. I decided to try out ANTLRWorks, which is a NetBeans plugin, but I could not get it to install (it seems to be locked to specific dated versions (201302132200 while I have something newer, still 7.3 as docs say) of dependencies).

So, the question: Has anyone set up any Java IDE (preferably Eclipse, but I could be persuaded to switch if support is good for something else) to integrate with ANTLR? With integrate, I mean: code generate on save/keyboard shortcut and syntax coloring (at the very least). Code completion and other features are of course nice to have, but I could live without them for now.

I am well aware of Xtext and I have had great success using it for some projects, but unfortunately it does not fit the needs here (need no IDE support, need my own DSL model not based on ECore, etc).

I know ANTLRWorks can be run as a standalone application without a Java IDE, but that I consider to be a last-resort solution as it is extremely cumbersome to work this way (switch between application, files out of sync, no VCS support etc). I tried the other way around: to install the Java parts into ANTLRworks (which itself is a NetBeans distro), but it did not end well (it seems basic project support etc was stripped out of ANTLRworks).

回答1:

Antlr4 plugin for Eclipse is here:

https://github.com/jknack/antlr4ide



回答2:

  • ANTLRWorks 2 uses many non-public interfaces from NetBeans, which means it will always be bound to a particular version. The standalone download will always work because it bundles the dependencies itself.

  • The standalone build of ANTLRWorks 2.1 is available. This build includes support for ANTLR 4.1.

  • A new plugin build of ANTLRWorks 2.1 will be available once NetBeans 7.4 is released.

  • Moving forward, the code for ANTLRWorks post-2.1 is open-source under an LGPL license.



回答3:

I think you have downloaded Netbeans 7.3.1. Try download 7.3 from https://netbeans.org/downloads/7.3/ and install the ANTLRworks plugin there. (Link to the ANTLRworks Update Center: http://tunnelvisionlabs.com/downloads/nbupdates/nb73/aw2/updates.xml ).

Note that ANTLRworks v2 contains ANTLR v4.0, which is not the current version of ANTLR (4.1). So also download ANTLR v4.0 from the ANTLR download folder (The antlr-4.0-complete.jar file) and use it as library for compilation.

Now you can use nearly all things you wanted.



回答4:

ANTLRv3IDE was opensourced. It should be compile-able for Juno. For stringtemplate (ST4) look at the Hastee plugin. It supports some of ST4 constructs.