// https://mdaines.github.io/grammophone/?s=UyAtPiBhIFggYSB8IGIgWCBiIHwgYSBZIGIgfCBiIFkgYS4KWCAtPiBjICJYJyIuClkgLT4gYyAiWSciLgoiWCciIC0+IGMuCiJZJyIgLT4gYy4=
// S -> a X a | b X b | a Y b | b Y a.
// X -> c "X'".
// Y -> c "Y'".
// "X'" -> c.
// "Y'" -> c.
tokens {
ka <= `a`;
kb <= `b`;
kc <= `c`;
}
lexer {
main { body }
mode body {
ka => { emit; }
kb => { emit; }
kc => { emit; }
eof => { pop; }
}
}
parser {
main { S }
S <- `a` X `a` | `b` X `b` | `a` Y `b` | `b` Y `a`;
X <- `c` XP;
Y <- `c` YP;
XP <- `c`;
YP <- `c`;
}
Consider the following:
The grammar is from these slides.
I expected langcc to be able to parse it, because it is LR(1), but it seems like it can't: