%{ int the_count = 0; int a_count = 0; int an_count = 0; %} article a|an|the %% {article} do_article(yytext); . . . %% do_article(s) char *s; { if (!strcmp(s,"a")) { a_count++; return 0; } else if (!strcmp(s,"an")) { an_count++; return 0; } else if (!strcmp(s,"the")) { the_count++; return 0; } printf("text not an article: %s\n",s); return 1; }Other examples of subroutines are programmer-defined versions of the I/O routines input(), unput(), and output(), which will be discussed later. Subroutines that may be exploited by many different programs should probably be stored in their own individual file or library to be called as needed.
Saturday, 15 October 2016
The subroutines section
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment