module languages/sdf2/idioms/SpecialCaseProductions

%% Grammar from page 252 of 
%% "Compilers, principles techniques, and tools"
%% Aho, Seti and Ullman

%% Ambiguities from special case productions

exports

sorts E

lexical syntax
[\ \t\n] -> LAYOUT

context-free start-symbols
  E

lexical syntax
  [a-z]+ -> E

context-free syntax
  E "sub" E "sup" E -> E {prefer}
  E "sub" E         -> E {right}
  E "sup" E         -> E {right}
  "{" E "}"         -> E {bracket}

context-free priorities
  {right:
    E "sub" E         -> E 
    E "sup" E         -> E 
  }

%% example term:
%% c sub c sup c