I've these rules:
S -> I#A
I -> a
I -> b
A -> aA
A -> bA
A -> EPSILON
This grammar produces a sequence of a's
and b's
. They are preceded by a single a
(or a single b
) and an #
. I need to define semantic rules which gives me the number of a's or b's (it depends on which one I choose before the #) after the #.
I don't know how to start because the value of A (in the first rule) depends on the value of I. How do I pass 'a' or 'b' to A?