home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.compilers      Compiler construction, theory, etc. (Mod      2,753 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,030 of 2,753   
   Max Hailperin to ctx2002@gmail.com   
   Re: cycle free grammar ?   
   08 Aug 07 11:41:00   
   
   From: max@gustavus.edu   
      
   ctx2002@gmail.com writes:   
   > 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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca