Question: HELP NEED THIS AS SOON AS POSSIBLE FLEX PROGRAM the code im going to give is FLEX program which recognizes if a word is a
HELP NEED THIS AS SOON AS POSSIBLE
FLEX PROGRAM
the code im going to give is FLEX program which recognizes if a word is a pronoun
it has been Extended by making it recognize also verbs, adjectives, nouns, prepositions (at least 10 of each) and digits (0-9).
%% [\t ]+ /* we can ignore the white spaces*/ ; is | am | are | were | was | be | being | been | do | does | did | will | would | should | can | could | has | have | had | go { printf("%s: word is a verb ", yytext); }
very | simply | gently | quietly | calmly | angrily { printf("%s: word is an adverb ", yytext); }
to | from | behind | above | below | between below { printf("%s: word is a preposition ", yytext); } their | my | your | his | her | its { printf("%s: word is a adjective ", yytext); }
I | you | he | she | we | they { printf("%s: word is a pronoun ", yytext); }
[0-9]+ | [0-9]+\.[0-9]+ | \.[0-9]+ { printf("%c: character ", yytext); }
[a-zA-Z]+ { printf("%s: do not recognize the word or character ", yytext); } .| { ECHO; }
%%
main() { yylex(); }
what I am asking for :
1. Extend the exercise done by also adding a counter for the number of pronouns, verbs, adjectives, nouns, prepositions, and digits. (Hint: the count variables should be added in the 1st section of the code and the yywrap() should be put in the 3rd section)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
