I am trying to write a yacc grammer to recognize the following pattern:
AAAA -> Multiple As
BBBB -> Multiple Bs
AAAABB -> 2 As followed by (AABB)
AAABBBBB -> (AAABBB) followed by 2Bs
In general, I would like to group equal blocks of contiguous As and Bs together, in precedence over runs of just As or Bs. A straightforward grammar shows a bunch of conflicts.
I need a way to give precedence to this production.
T -> | AB | ATB
over
U -> | AU
(where T and U are yacc productions, A and B are tokens)
How is this done?