Which ANTLR product do I choose? - eclipse-plugin

I am confused, please do help me out. According to this tutorial, http://www.ibm.com/developerworks/opensource/tutorials/os-ecl-commplgin1/index.html, the first thing I need to do is create a parser and lexer. Okay, I've decided to use ANTLR. Now I've checked ANTLR on the net.. But which kind of ANTLR should I use? ANTLR Works / ANTLR V3 / ANTLR V4? I would like to build an editor after this phase, so I hope the generated parser / lexer / etc can be integrated smoothly with it. What I'm trying to do here actually is create an IDE for my language that can plug-in into Eclipse. Thanks. :)

ANTLR (ANother Tool for Language Recognition) is a tool for generating recognizer of various kinds. There are currently 2 versions out there: v4, the latest one, and v3 the previous one which is still in wide use because of the needed runtimes for different language targets (many haven't been ported to v4 yet).
ANTLR Works is a standalone IDE for developing ANTLR recognizers. There are other tools like Eclipse plugins, a VS plugin etc.
If you are going with Eclipse it sounds natural to me to use the Eclipse plugin for developing the parser for your IDE. You should probably first play a bit with other applications, test parser etc. to get an idea how this works.

Related

Can I use only GrammarKit to generate both parser and lexer for Intellij Plugin development (custom lang)

In the tutorial of custom language support for Intellij Plugin development, it uses GrammarKit to generate the Parser and JFlex (patched) to generate the Lexer.
On this page the author says we can "use the GrammarKit plugin to generate lexer and parser".
Is there a particular reason that JetBrains suggest using JFlex to generate the lexer? How different the process would be if we use GrammarKit to generate both?
Well, I think I know the answer now.
The short answer is NO. It is a little bit complex than that.
Grammar-Kit can be used to generate .flex file and you still need JFlex generator to generate the Java lexer.
Both steps can be done via the context menu.
See here for more info.

Is it possible to use Xtext with Antlr v4?

I'm wondering if it is possible to use Antlr v4 with Xtext?
I know currently (and the near future) Xtext is relying on Antlr v3 because they say they'd have to rewrite all their functions to fit Antlr v4, but I thoughtit might be possible to either add the Antlr v4 library to the buildpath of the Xtext onstead of let it download the v3 itself or if that is not possible if it is possible to generate the Parser with Antlr v4 and then insert the generated java code into Xtext.
Or could you think of another way using v4 with Xtext?
If you are wondering why I want to use v4: As far as I know it automatically handles ambigious grammar (it rewrites the grammar so everything is solvable by the computer) and that is the thing I'mstruggling with the most
Thanks for your help
Krzmbrzl
No, there is no trivial way to plug ANTLR4 into Xtext.
Note that ANTLR4's parsing algorithms are more powerful than those of ANTLR3, but it isn't magic. If you have a highly ambiguous grammar, you might (likely?) still get issues with v4.
I recommend you create a new question and post your Xtext grammar and explain where you're having issues.

How can I Adapt an already built antlr4 Cobol parser into antlr3 interfaces

I have built an antlr v4 grammar for parsing Cobol files. It is tested and fully functional. Now I need to adapt it to be used within a XText project (with unfortunately uses antlrv3). How can I achieve it without backporting my grammar (and loosing all already built Listeners and Visitors)?
After a few thinking about the problem I am wondering if there is a way to generate antlr v3 interface adaptors to use antlr v4 Parser and Lexer. If so, i could "tweak" XText, so it would be using my already built antlrv4 classes through this adaptor interface.
Anyone already had done something like this?
We are currently working on this problem as well. Is there a possibility to look at your grammar file?

antlr tooling recommendations

I'm trying to use Antlr4.5 to generate a lexer/parser (in C#) for a SQL grammar. What sort of tools would you recommend in order to write the grammar and to test it?
I'm trying antlrworks2 but I find it a bit confusing (can't find a way to enter sample text and see the parse tree - not sure if it's not there or I'm blind or just plain dumb, but I'm pretty sure antlrworks v1 had such a feature).
The Visual Studio VSIX plugin from Sam Harwell looks great but it also confuses the heck out of me, the lexer and parser get generated in the obj\ folder instead of inside the project. Also, it won't help me much when writing the grammar as far as showing me a syntax diagram, letting me try out the grammar with sample text and so on.
I'm pretty confident that antlr is a good way to go, but I'm really not sure about the tooling and the approach I should take when defining and testing my grammar. I would appreciate any suggestions.
My question wasn't brilliant because tooling is pretty independent of the antlr target language, but FWIW I ended up using the free version of IntelliJ IDEA with the antlr plugin. I started liking IntelliJ, it's very good. The antl plugin is also very good for the most part, it a bit rough around the edges here and there, but all the important stuff works very well and in general it's amazingly useful.

How to create an Eclipse editor plugin with syntax checking and coloring as fast as possible?

I'm working on a project that requires me to create a series of editors for languages that are quite different. The syntaxes are defined by us.
I'm looking for a solution for this.
Is there a shortcut to take in this problem?
You could use XText:
a framework for development of textual domain specific languages (DSLs).
Just describe your very own DSL using Xtext's simple EBNF grammar language and the generator will create a parser, an AST-meta model (implemented in EMF) as well as a full-featured Eclipse text editor from that.
Alternatives to XText are Rascal or Spoofax, both less popular than XText but interesting for they support more general context-free grammars, among other things. Nice to check out.
If you are looking for a more low level, programmable solution, then Eclipse's IDE Meta-tooling platform is a good choice (IMP).
What IMP gives you is API to connect your existing parsers to Eclipse without much hassle. You need to implement an IParseController interface, to call your parser and ITokenIterator to produce tokens and some other interface to assign fonts to each kind of token.
The aforementioned Rascal and Spoofax are both build on top of IMP.
Not mentioned is DLTK (proposed also in Tutorial regarding the development of a custom Eclipse editor)
There are Ruby, bash that are implemented with it.