System Software Lab 11 | Read Now

System Software VTU Lab

Program 11:- Program to recognize whether a given sentence is simple or compound.


Steps in writing LEX Program:

  1. Step – Using gedit create a file with extension .l For example: prg1.l
  2. Step – lex prg1.l
  3. Step – cc lex.yy.c –ll
  4. Step – ./a.out

Steps in writing YACC Program:

  1. Step: Using gedit editor create a file with extension y. For example: gedit prg1.y
  2. Step: YACC –d prg1.y
  3. Step: lex prg1.l
  4. Step: cc y.tab.c lex.yy.c -ll
  5. Step: /a.out

System Software Lab 11 Code [vi lab11.l]

%{
int flag=0;
%}

%%
" and " |
" or " |
" but " |
" because " |
" than "|
" nevertheless " {flag=1;}
%%
int main()
{
 printf("Enter the sentence:\n");
 yylex();
  if(flag==1)
  printf("compound statement");
  else
  printf("simple statements\n");
}

Output

System Software

Leave a Reply

Your email address will not be published. Required fields are marked *

WhatsApp Icon Join For Job Alerts