-- Sep 22 In-Class Exercise Thread
%{
#include
int wordCount = 0;
%}
word a|(the)
%%
[\t\n ]+ {printf("I see whitespace\n");} //what to do if see pattern
{word} {wordCount++;}
%%
int main()
{
yylex(); //call the lexer. Gets input from command line until ^D
printf("word count: %d", wordCount); return 0;
}
<nowiki>%{
#include <stdio.h>
int wordCount = 0;
%}
word a|(the)
%%
[\t\n ]+ {printf("I see whitespace\n");} //what to do if see pattern
{word} {wordCount++;}
%%
int main()
{
yylex(); //call the lexer. Gets input from command line until ^D
printf("word count: %d", wordCount); return 0;
}</nowiki>