How To Implement FIRST of an Expression in C

How To Implement FIRST of an Expression in C:-


if You need The Exe ,i can prvide it
Source Code :-







1:  #include<stdio.h>  

2:  #include<ctype.h>
3:  #include<conio.h>
4:  void FIRST(char );
5:  int count,n=0;
6:  char prodn[10][10], first[10];
7:  main()
8:  {
9:     int i,choice;
10:     char c,ch;
11:     printf("How many productions ? :");
12:     scanf("%d",&count);
13:     printf("Enter %d productions epsilon= $ :\n\n",count);
14:     for(i=0;i<count;i++)
15:        scanf("%s%c",prodn[i],&ch);
16:        do
17:        {
18:        n=0;
19:        printf("Element :");
20:        scanf("%c",&c);
21:        FIRST(c);
22:        printf("\n FIRST(%c)= { ",c);
23:        for(i=0;i<n;i++)
24:        printf("%c ",first[i]);
25:        printf("}\n");
26:        getch();
27:        printf("press 1 to continue : ");
28:        scanf("%d%c",&choice,&ch);
29:        }while(choice==1);
30:        }
31:        void FIRST(char c)
32:        {
33:           int j;
34:           if(!(isupper(c)))first[n++]=c;
35:           for(j=0;j<count;j++)
36:           {
37:           if(prodn[j][0]==c)
38:           {
39:           if(prodn[j][2]=='$') first[n++]='$';
40:           else if(islower(prodn[j][2]))first[n++]=prodn[j][2];
41:           else FIRST(prodn[j][2]);
42:           }
43:           }
44:           }

Comments

Popular posts from this blog

How To Install LEX and YACC in Linux or Ubuntu

Lex Program To Check The Syntax of For Loop

Listing/Delisting of an article in to an Assortment in SAP SCM Retail