What is the relationship between Xtext and ANTLR?

I heard that Xtext ultimately uses ANTLR, but their grammar specification files have slightly different formats. So what is the connection between the two?

+8
parsing antlr xtext
source share
2 answers

Xtext relies on the Antlr parser generator to parse input files. In addition, the structure provides many additional values, such as strongly typed ASTs, abstractions for binding and static analysis, and IDE integration for Eclipse.

To this end, Xtext generates two Antlr grammars. One for parsing, in which the actual AST is produced, and a second grammar, which is used to consume events to calculate content suggestions for the Eclipse editor.

+12
source share

ANTLR grammar is created from Xtext. You can find it in src-gen/org/example/dsl/parser/antlr/internal/InternalDsl.g .

0
source share

All Articles