Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Re: Computing F...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 5 Topic 2354 of 2472
Post > Topic >>

Re: Computing Follow set

by torbenm@[EMAIL PROTECTED] (Torben =?iso-8859-1?Q?=C6gidius?= Mogense Mar 7, 2008 at 09:38 AM

pavan <pavan.mail@[EMAIL PROTECTED]
> writes:

> I have a question regarding the computation of FOLLOW sets.
> Consider the following grammar:
>
> A -> aB | a
> B -> bA | b
>
> From the production A -> aB, we have FOLLOW(B) contains FOLLOW(A).
> From the production B -> bA, we have FOLLOW(A) contains FOLLOW(B).
>
> This ends up being an infinite loop when I code it. I would appreciate
> your suggestions on this.


You need to do some kind of fixed-point iteration.  The simplest form
is to initialise all FOLLOW sets to empty, and then treat each
constraint of the form FOLLOW(A) contains FOLLOW(B) as an assignment
FOLLOW(A) := FOLLOW(A) U FOLLOW(B).  Run through all constraints this
way repeatedly until a pass over the constraints makes no changes in
any FOLLOW set.

You can see more details in chapter 3 of Basics of Compiler Design,
which you can download from http://www.diku.dk/~torbenm/Basics

You can make convergence faster by using a worklist algorithm.

	Torben
 




 5 Posts in Topic:
Computing Follow set
pavan <pavan.mail@[EMA  2008-03-06 16:30:56 
Re: Computing Follow set
"Russ Cox" <  2008-03-06 21:04:52 
Re: Computing Follow set
torbenm@[EMAIL PROTECTED]  2008-03-07 09:38:37 
Re: Computing Follow set
Max Hailperin <max@[EM  2008-03-07 07:09:32 
Re: Computing Follow set
Hans Aberg <haberg_200  2008-03-08 22:33:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 2:20:46 CDT 2008.