Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include <stdio.h>
- int l=0, w=0;
- %}
- %%
- ^[ \t]+ ;
- [ \t]+$ ;
- [ \t]+ {
- printf(" ");
- }
- [^ \t\n]+ {
- ECHO;
- w++;
- }
- ([ \t]*\n)+ {
- printf("\n");
- l++;
- }
- %%
- int main(){
- yylex();
- printf("\nThere are %d words and %d lines",w,l+1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement