O'Reilly logo

Implementing Domain-Specific Languages with Xtext and Xtend by Lorenzo Bettini

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Left recursive grammars

When moving on to a more complex expression, such as addition, we need to write a recursive rule since the left and right parts of an addition are expressions themselves. It would be natural to express such a rule as follows:

Expression:
  ... as above
  {Plus} left=Expression '+' right=Expression;

However, this results in an error from the Xtext editor as shown in the following screenshot:

Left recursive grammars

Xtext uses a parser algorithm that is suitable for use for interactive editing due to its better handling of error recovery. Unfortunately this parser algorithm does not deal with left recursive rules. A rule is left recursive when the first ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required