Lex program that detects statement type i.e. Simple or Compound
Note: Only AND | OR | BUT conjunctions are supported.Program:%option noyywrap %{ char test='s'; %} %% (""[aA][nN][dD]"")|(""[oO][rR]"")|(""[bB][uU][tT]"") {test='c';} . {;} \n return 0; %% main() { yylex(); if(test=='s') printf("\n Its a simple sentence"); else if(test=='c') printf("\n This is compound sentence"); }
Thank you for this code.
ReplyDeletenice code
ReplyDeleteHello world
ReplyDeleteAbove program takes it as simple sentence !
I need a code where a file contain both compound and simple sentence separated by enter
ReplyDeletehow to Write a lex program to find a simple and compound statement.
ReplyDelete(Compound statement must use: and, or, but, because.)
Example:
I am a girl (Simple statement)
You and me (Compound statement)
THANK U SO MUCH BROTHER
ReplyDelete