%{
#include <stdio.h>
int macros = 0;
int headers = 0;
%}

%%
^[ \t]*"#include"[ \t]*[<"].*[>"]   { headers++; }
^[ \t]*"#define"[ \t]+[a-zA-Z_][a-zA-Z0-9_]* { macros++; }
.|\n                                { /* Ignore all other characters so they don't echo to the screen */ }
%%

int yywrap() { 
    return 1; 
}

int main() {
    printf("Enter the C program input (press Ctrl+D to end):\n");
    yylex();
    printf("\nTotal number of macros defined: %d\n", macros);
    printf("Total number of header files included: %d\n", headers);
    return 0;
}
