|cycle free grammar ? email@example.com (2007-08-04)|
|Re: cycle free grammar ? firstname.lastname@example.org (SM Ryan) (2007-08-07)|
|Re: cycle free grammar ? email@example.com (Max Hailperin) (2007-08-08)|
|From:||Max Hailperin <firstname.lastname@example.org>|
|Date:||08 Aug 2007 11:41:00 -0500|
|Posted-Date:||08 Aug 2007 23:21:27 EDT|
> I am currently learning how to write a compiler , i am using a book
> called Compilers Principles , techniques, and tools.
> in this book , there is an exercise asking write a algorithm to
> convert a grammar into a equivalent cycle - free grammar.
> for example:
> convert grammar s->ss|(s)|e to a cycle free grammar.
> any one know how to do that?
If you first make the grammar epsilon-free (which is the prior
exercise, if memory serves me), then the only kinds of cycles that can
remain are those based on productions of the form A -> B. That may be
enough of a hint to let you figure out the algorithm on your own. If
not, a second hint would be to look at algorithms for finding the
strongly connected components of directed graphs. -max
Return to the
Search the comp.compilers archives again.