Skip to main content

Posts

Showing posts with the label compiler design lab

Write program to convert NFA to DFA

 Write program to convert NFA to DFA Agenda 1.Code 2.Input/Output 1.Code #include <stdio.h> #include <string.h> #include <math.h> int  ninputs; int  dfa[ 100 ][ 2 ][ 100 ] = { 0 }; int  state[ 10000 ] = { 0 }; char  ch[ 10 ], str[ 1000 ]; int  go[ 10000 ][ 2 ] = { 0 }; int  arr[ 10000 ] = { 0 }; int  main() {       int  st, fin, in;       int  f[ 10 ];       int  i,j= 3 ,s= 0 ,final= 0 ,flag= 0 ,curr1,curr2,k,l;       int  c;            printf( "\nFollow the one based indexing\n" );            printf( "\nEnter the number of states::" );      scanf( "%d" ,&st);       ...

Write program to minimize any given DFA.

  Write program to minimize any given DFA. Agendra- 1.Algorithm 2.Code 3.Input/output 1.Algorithms Get the start state, final state, input symbols as input and also give the edge value for each state. Maintain a stack required for transition from one state to other state. Using Pop or push function perform the insertion and deletion of elements when required. Finally conversion has been made to change from regular expression to minimized DFA and the output is displayed as DFA transition table. 2.Code- #include <stdio.h> #include <string.h> #define  STATES   50 struct  Dstate {    char  name;    char  StateString[ STATES  +  1 ];    char  trans[ 10 ];    int  is_final; } Dstates[ 50 ]; struct  tran {    char  sym;    int  tostates[ 50 ];    int  notran; }; struct  state {    int  no;    struct  tran...

Write program to find Simulate First and Follow of any given grammar.

 Write program to find Simulate First and Follow of any given grammar. First Using C- ___________________________________________________________________________________ #include <stdio.h> #include <ctype.h>   void  Find_First( char[] ,  char ); void  Array_Manipulation( char[] ,  char );   int  limit; char  production[ 25 ][ 25 ];   int  main() {        char  option;         char  ch;        char  array[ 25 ];        int  count;       printf( "\nEnter Total Number of Productions:\t" );       scanf( "%d" , &limit);        for (count =  0 ; count < limit; count++)       {     ...