Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are features of ANTLR that XText Does not provide?

I just came across very nice tool Xtext to create DSL as well as IDE for editing. I did some search on the web and found people saying it does not provide all the features of ANTLR. I am using ANTLR as my parser generator.

I am not even sure what features of ANTLR I will need to write complete parser for my language but ANTLR is around for quite a long time and probably supports more features than Xtext.

Can anyone please give some examples of what CANNOT be specified in a Xtext grammar?

like image 826
Tasawer Khan Avatar asked May 05 '11 22:05

Tasawer Khan


People also ask

What does ANTLR generate?

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.

What can ANTLR do?

ANTLR is a powerful parser generator that you can use to read, process, execute, or translate structured text or binary files. It's widely used in academia and industry to build all sorts of languages, tools, and frameworks. Twitter search uses ANTLR for query parsing, with over 2 billion queries a day.

What is ANTLR jar used for?

ANTLR (ANother Tool for Language Recognition) is a tool for processing structured text. It does this by giving us access to language processing primitives like lexers, grammars, and parsers as well as the runtime to process text against them. It's often used to build tools and frameworks.

What is ANTLR in compiler?

In computer-based language recognition, ANTLR (pronounced antler), or ANother Tool for Language Recognition, is a parser generator that uses LL(*) for parsing. ANTLR is the successor to the Purdue Compiler Construction Tool Set (PCCTS), first developed in 1989, and is under active development.


1 Answers

You cannot specify semantic predicates in an Xtext grammar. Furthermore it's not possible to include arbitrary actions (read: target language code blocks) with Xtext. The only supported target platform is Java.

The good news is, that Xtext gains great benefit by inducing these constraints, e.g. you'll get an unparser that allows to serialize arbitrary models / syntax graphs that match your grammar. Speaking about syntax graphs, with Xtext you'll get a typed AST for your language that you can edit in your IDE.

A grammar feature that is unique in Xtext's representation are unordered groups. That is, you can directly express that certain elements in your grammar may occur in arbitrary order but each one only once. If you think about the java modifiers, this may be very handy:

  visibility=('public'|'private') // this is a mandatory assignment
& abstractOrFinal=('abstract'|'final')? // this is optional
& static?='static'? // this will become a boolean value in your ast

Have a look at the Xtext docs for more details on the grammar language.

like image 56
Sebastian Zarnekow Avatar answered Oct 16 '22 05:10

Sebastian Zarnekow