hi there everybody,

I have to make a program that gets a string and then finds out if it is accepted by the CFG(cintext free grammer),
I want to first do the Simplification of CFG but I really don't know what data structure I have to use,
for example I want to get rid of useless symbols(those that do
not participate in any derivation of a terminal string.)
here i have the file that keeps the grammer for example
S>AB
S>a
A>b
then I have to get ride of B cuz not genarating termenals so the grammer would be :
S>a
A>b
then get rid of A cuz not reachable from S,so:
S>a

so how cud I do this with coding?

thank you

thanks for your help,
I look at these pages,so the implementation is with a tree,
I'll read all,nice information,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.