I'm the ANTLR creator and am trying my hand at creating an ANTLR v4 plug-in for Intellij. My co-author, Sam Harwell, has created one for netbeans, but Intellij is my preference. Ultimately, I would like to build plug-ins for languages using ANTLR in intellij, rather than having to convert ANTLR grammars to the PEG-based BNF grammars used in the grammarkit. For one, I'm the ANTLR guy, and two there is no point in maintaining two language descriptions. It seems to me that the community could be well served by an ability to specify lexers and parsers in ANTLR's metalanguage instead of building parsers by hand or using the grammarkit. The grammarkit might be fine for syntax highlighting, but if you're actually going to do anything with the language you need a compiler or interpreter which means you need a real parser. That means creating a grammar in something other than grammarkit, even if it's for the simple need to create the proper compiler data structure instead of what intellij needs. (imagine incorporating a random C compiler; it has a grammar and then you would need to code dup it into grammarkit for syntax highlighting.)
I've been going through the tutorials, reading source code, and reading through these discussions. It's fairly slow going trying to build my plug-in because of the scarcity of written documentation and documentation within the library code, but some recent videos and some of the example plug-ins are illuminating. They're well worth reading through. I appreciate the efforts you've gone through to create the documentation that is available.
I have a number of questions for the Galactic overlords from jetbrains:
* Would you consider it valuable if I made an adapter so that plug-ins could use ANTLR v4 grammars out-of-the-box? There was some discussion that it "is not recommended to use ANTLR for language plugins because most ANTLR grammars don't handle error recovery well " which is probably a bit in error, particularly with the latest v4. Possibly an earlier versions consumed too much but it never gives up and exits the parser. Building great error recovery by hand is notoriously difficult. Because grammarkit is PEG-based, it essentially has no error recovery. PEGs can only discover errors after the entire input has been matched; then they jump to the deepest position in the input and claim that's where the syntax error is. [xtext guys abandoned PEGs and came back to ANTLR after they experienced PEG "error recovery".] ;) I'm happy to discuss how to integrate ANTLR's error recovery into Intellij so that it performs as you would like. I'd like to build a commandline option on ANTLR that generates a basic intellij plug-in automatically from a grammar so I think this could contribute a lot to plug-in development.
* What are the minimum requirements of a parser? (The required lexer implementation seems reasonably straightforward from looking at the source code, but I've not actually tried a custom lexer.) The sample handwritten parsers seem to create PSI nodes via mark() / marker.done() at the start/end of parsing functions. From what I can tell, integrating ANTLR's generated recursive descent parsers would require altering ANTLR code generation. That's no big deal, but perhaps the way to integrate ANTLR would be avoid integrating the parser itself and wrap or convert its automatically-generated parse trees into PSI elements. Does this approach makes sense? Netbean's got a very simple lexer/parser interface and cramming ANTLR in there is no big deal; it's just for syntax highlighting. Is their similar lightweight approach where I can simply indicate where the syntax errors are? I.e., w/o having to build your special tree? In the end, do I need a PSI tree to access all of the cool widgets like source code navigators and search dialogs? Certainly for re-factoring and so on I would need to use your trees...
Sorry for the long initial post, but I wanted to start a discussion and learn how to proceed at the same time :) If there is desire from the community and I can get my roadblocks cleared, I'd be happy to keep working on this.
Thanks for your time,