I need to solve the lab from univeristy but I can't understand main idea for the following:
you have a grammar and a start point grammar:
"S;""S->S(S)S|<empty>;""S"
Where first S is allowed symbol "S->S(S)S|<empty>;"
this is a chain from there I need to build rules, such as:
S->S
S->(S)
S-><empty>
Last string is "start point".
But I can't solve the problem: if I have many complecated rules in multiple chains:
A->BCD|1|2
B->2|3|ABC
I can't handle this situations.
I'm tried to multiple vector and store "recursion point" there, but no success.
Can anyone help me with understanding this?
When handling a grammar like this there are several ways to do it, some of which involve a lot of work.
I recommend you use a Recursive Descent Parser. It will make your life much happier.
BTW, that grammar is a little confusing to me the way it is written ā it does not clearly delineate terminals and rules. In particular, I am unsure what is meant by āS(S)Sā.
Also BTW, that grammar reduces to a single semicolon being a valid program.