Created
March 2, 2014 03:43
-
-
Save JALsnipe/10b1d1270f590412768a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
#include<stdio.h> | |
int nums = 0; | |
%} | |
number [0-9] | |
%% | |
{number} {nums++; printf("%s", yytext);} | |
%% | |
int yywrap() | |
{ | |
return 1; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if(argc!=2) | |
{ | |
printf("Usage: <./a.out> <sourcefile>\n"); | |
exit(0); | |
} | |
yyin=fopen(argv[1],"r"); | |
yylex(); | |
printf("\nNumbers = %d\n",nums); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment