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:

  ... 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 ...

Get Implementing Domain-Specific Languages with Xtext and Xtend now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.