aboutsummaryrefslogtreecommitdiff
path: root/05/main.l
blob: ee130530af86c23a25e0d123938f361b534f9dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
%{
    int k = 0;
    int o = 0;
    int i = 0;
%}

%%
int|main|printf|scanf|char|if|else|for|switch|case k++;
[+*/%&=] o++;
[a-zA-Z_][a-zA-Z0-9_]* i++;
. ;
\n ;
%%

int main(void) {
    yylex();
    printf("%d keywords\n", k);
    printf("%d operators\n", o);
    printf("%d identifiers\n", i);
}

int yywrap() {
    return 1;
}