I studying grammars and am a bit confused about how to design grammars where one value is dependent on another.
For example, say I want to define a grammar that produces exactly the following three sentences:
i + i = ii : BASE CASE
iiii + ii = iiiiii (thats 4 i’s + 2 i’s equals 6 i’s)
iii + i = iiii (3 i’s + 1 i equals 4 i’s)
How would I go about this? The part the confuses me is that if the first ‘value’ is iiii then the second can only be ‘ii’ and not ‘i’ or ‘iii’.
Thanks in advance!
Grammars are trivial if your language is finite: