Category Archives: Compiler Design

Program to find out FOLLOW of NONTERMINALS of given productions


#include”stdio.h”#include<conio.h>#define max 10#define MAX 15void ffun(int,int);void fun(int,int[]);void follow(int i);char array[max][MAX],temp[max][MAX];int c,n,t;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 … Continue reading

Posted in C, Compiler Design | Tagged , , , | Leave a comment

A program to find FIRST of NON TERMINALS of the given grammar


#include<stdio.h> #include<conio.h> char array[10][20],temp[10]; int c,n; void fun(int,int[]); int fun2(int i,int j,int p[],int ); void main() {    int p[2],i,j;    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;i<n;i++) … Continue reading

Posted in C, Compiler Design | Tagged , , , , , , | 10 Comments

Program to recognize strings ‘aaab’, ‘abbb’, ‘ab’, ‘a’ , aabb using the grammer (an bn ,n>=0).


Lex part : %{ #include “y.tab.h” %} %% a return A; b return B; .|\n return yytext[0]; %% Yacc Part : %{ #include<stdio.h> int valid=1; %} %token A B %% str:S’\n’ {return 0;} S:A S B  |  ; %% main() … Continue reading

Posted in C, Compiler Design | Tagged , , , , | Leave a comment