Friday, May 3, 2019

SS 11 - LEX - SENTENCE IS SIMPLE/COMPOUND

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

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 :( click on image to zoom )


No comments:

Post a Comment