Skip to content

Instantly share code, notes, and snippets.

@mrluanma
Created June 7, 2010 03:38
Show Gist options
  • Save mrluanma/428198 to your computer and use it in GitHub Desktop.
Save mrluanma/428198 to your computer and use it in GitHub Desktop.
digit [0-9]
letter [A-Za-z]
%{
int count;
%}
%%
/* match identifier */
{letter}({letter}|{digit})* count++;
%%
int yywrap(void) {
return 1;
}
int main(void) {
yylex();
printf("number of identifiers = %d\n", count);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment