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?
ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With