SYNOPSIS

A deliberately confusing example

Almost quoting Pete Jinks at http://www.cs.man.ac.uk/~pjj/cs2121/ho/node19.html:

The following grammar would confuse any LR(n) or LL(n) parser with a fixed amount of look-ahead:

A : B C d | E C f ;
B : x y ;
E : x y ;
C : /* empty */ | C c ;

As usual, one of the simplest solutions is to rewrite the grammar to unify the common prefix e.g.:

A    : BorE C d | BorE C f ;
BorE : x y ;
C    : /* empty */ | C c ;

The grammar would confuse any LR(n) or LL(n) parser with a fixed amount of look-ahead

See a solution in file: lr_1_grammar.eyp

SEE ALSO

This grammar is a variation of one seen at Pete Jinks page: http://www.cs.man.ac.uk/~pjj

Files

lr_1_grammar.eyp