Important: Use custom search function to get better results from our thousands of pages

Use " " for compulsory search eg:"electronics seminar" , use -" " for filter something eg: "electronics seminar" -"/tag/" (used for exclude results from tag pages)
Tags: First, calculate, program, software to write, lr k grammar, how to check the sentence, find the of a number, how to do addition, find the date, how to write computer software, how to find the number, computer c program, A program to calculate the First,
Ask More Info Of  A Seminar Ask More Info Of A Project Post Reply  Follow us on Twitter
22-01-2011, 01:27 PM
Post: #1
A program to calculate the First & Follow of a grammar.



Code:
#include"stdio.h"
#include<conio.h>
#define max 10
#define MAX 15
char array[max][MAX],temp[max][MAX];
int c,n,t;void fun(int,int[]);
int fun2(int i,int j,int p[],int key)
{
int k;
if(!key)
{
for(k=0;k<n;k++)
if(array[i][j]==array[k][0])
break;
p[0]=i;p[1]=j+1;
fun(k,p);
return 0;
}
else
{
for(k=0;k<=c;k++)
{
if(array[i][j]==temp[t][k])
break;
}
if(k>c)return 1;
else return 0;
}
}
void fun(int i,int p[])
{
int j,k,key;
for(j=2;array[i][j]!='\0';j++)
{
if(array[i][j-1]=='/')
{
if(array[i][j]>='A'&&array[i][j]<='Z')
{
key=0;
fun2(i,j,p,key);
}
else
{key=1;
if(fun2(i,j,p,key))
temp[t][++c]=array[i][j];
if(array[i][j]=='@'&&p[0]!=-1)
{ //taking ,@, as null symbol.
if(array[p[0]][p[1]]>='A'&&array[p[0]][p[1]]<='Z')
{
key=0;
fun2(p[0],p[1],p,key);
}
else
if(array[p[0]][p[1]]!='/'&&array[p[0]][p[1]]!='\0')
{
if(fun2(p[0],p[1],p,key))
temp[t][++c]=array[p[0]][p[1]];
}
}
}
}
}
}
char fol[max][MAX],ff[max];int f,l,ff0;
void ffun(int,int);
void follow(int i)
{
int j,k;
for(j=0;j<=ff0;j++)
if(array[i][0]==ff[j])
return 0;
if(j>ff0)ff[++ff0]=array[i][0];
if(i==0)fol[l][++f]='$';
for(j=0;j<n;j++)
for(k=2;array[j][k]!='\0';k++)
if(array[j][k]==array[i][0])
ffun(j,k);
}
void ffun(int j,int k)
{
int ii,null=0,tt,cc;
if(array[j][k+1]=='/'||array[j][k+1]=='\0')
null=1;
for(ii=k+1;array[j][ii]!='/'&&array[j][ii]!='\0';ii++)
{
if(array[j][ii]<='Z'&&array[j][ii]>='A')
{
for(tt=0;tt<n;tt++)
if(temp[tt][0]==array[j][ii])break;
for(cc=1;temp[tt][cc]!='\0';cc++)
{
if(temp[tt][cc]=='@')null=1;
else fol[l][++f]=temp[tt][cc];
}
}
else fol[l][++f]=array[j][ii];
}
if(null)follow(j);
}
void main()
{
int p[2],i,j;
clrscr();
printf("Enter the no. of productions :");
scanf("%d",&n);
printf("Enter the productions :\n");
for(i=0;i<n;i++)
scanf("%s",array[i]);
for(i=0,t=0;i<n;i++,t++)
{
c=0,p[0]=-1,p[1]=-1;
temp[t][0]=array[i][0];
fun(i,p);
temp[t][++c]='\0';
printf("First(%c) : [ ",temp[t][0]);
for(j=1;j<c;j++)
printf("%c,",temp[t][j]);
printf("\b ].\n");
getch();
}
/* Follow Finding */
for(i=0,l=0;i<n;i++,l++)
{
f=-1;ff0=-1;
fol[l][++f]=array[i][0];
follow(i);
fol[l][++f]='\0';
}
for(i=0;i<n;i++)
{
printf("\nFollow[%c] : [ ",fol[i][0]);
for(j=1;fol[i][j]!='\0';j++)
printf("%c,",fol[i][j]);
printf("\b ]");
getch();
}
}



09-04-2014, 09:34 PM
Post: #2
RE: A program to calculate the First & Follow of a grammar.
which type of productions it will take ???
Rating A program to calculate the First & Follow of a grammar. Options
Share A program to calculate the First & Follow of a grammar. To Your Friends :- Seminar Topics Bookmark
Post Reply 

Marked Categories : first follow, first and follow c program using files, how to compute first and follow, c progarm for finding follow and first, first and follow implementation, to compute first and follow set program in c, prgm for first nd follow functn, program on first and follow, program in c to find first and follow function, first and follow set program, first and follow function program in c, grammar first follow, c algorithm on first and follow, c program to implement first and follow, program in c to find first and follow, first and follow program, program to compute first and follow, program to compute first and follow of a grammar, c program to compute first follow,

[-]
Quick Reply
Message
Type your reply to this message here.


Image Verification
Image Verification
(case insensitive)
Please enter the text within the image on the left in to the text box below. This process is used to prevent automated posts.

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  NATURAL LANGUAGE GRAMMAR INDUCTION USING PARALLEL GENETIC ALGORITHM full report seminar topics 3 3,895 06-03-2013 09:42 AM
Last Post: vrushali kurhade
  ONLINE ASSESSMENT PROGRAM REPORT study tips 0 319 16-02-2013 12:33 PM
Last Post: study tips
  Mini Project on Electricity Bill Calculation Program Report project girl 0 1,786 28-01-2013 10:21 AM
Last Post: project girl
  PROGRAM TO POST-PROCESS THE CDROM DATABASE RECORDS seminar tips 0 307 02-01-2013 02:21 PM
Last Post: seminar tips
  anti-virus program seminar paper 1 1,090 04-12-2012 11:49 AM
Last Post: seminar tips
  1992 Bold Shift Program. Survey Instruments seminar flower 0 254 27-10-2012 01:17 PM
Last Post: seminar flower
  Advanced Simulation and Computing Program seminar flower 0 316 25-10-2012 11:39 AM
Last Post: seminar flower
  Support for International Space University?s (ISU) 2003 Summer Session Program seminar flower 0 245 22-10-2012 05:31 PM
Last Post: seminar flower
  Agilent 3070 Test Program Set (TPS) Development seminar flower 0 299 22-10-2012 05:08 PM
Last Post: seminar flower
  Implementing An In-Service F-16 Avionics Unique Item Identification Program seminar flower 0 280 22-10-2012 05:06 PM
Last Post: seminar flower
This Page May Contain What is A program to calculate the First & Follow of a grammar. And Latest Information/News About A program to calculate the First & Follow of a grammar.,If Not ...Use Search to get more info about A program to calculate the First & Follow of a grammar. Or Ask Here

Options: