1
votes

I'm new to Xtext and wondering what's the purpose of antlr is in xtext. As I've understand so far, antlr generate a parser based on the grammar and the parser then deal with the text models. Right? And what about the other generated stuff like the editor or the ecore. Are there other components behind xtext which generate them?

2

2 Answers

2
votes

Xtext needs a parser generator to produce a parser for the language you define. They could have built one of their own. They chose to use ANTLR instead.

I don't know what other third party machinery they might have chosen to use.

0
votes

I've been hacking one Xtext based plugin and from what I saw I think it works like this: Xtext has it's own BNF syntax, which is very similar to ANTLR one. In fact its it's subset.

Xtext takes your grammar, and generates the ANTLR one from it(.g file). The generated ANTLR grammar adds specific actions to your BNF rules. The actions code interacts with the Xtext runtime and (maybe) with the Eclipse itself. The .g file is processed using some older version of ANTLR and .java file is generated. This file is then compiled.