Haskellians,
Here is an idea so obvious that someone else must have already thought of it
and worked it all out. Consider the following grammar.
N0 ::= T0 N1 | T1 N1 N0 | T2 N0 N0
N1 ::= T3 N0
where Ti (0 = i 4) are understood to be terminals.
Using generics we can translate each production
Dusan,
Excellent point. To close it off, you need to add an empty alternative.
Thus, the corrected form would be
N0 ::= TEmpty | T0 N1 | T1 N1 N0 | T2 N0 N0
N1 ::= T3 N0
In the lambda calculus, this would show up as a constant term, say 0, that
would have to be treated in the operational