aboutsummaryrefslogtreecommitdiff
path: root/05/main.l
diff options
context:
space:
mode:
Diffstat (limited to '05/main.l')
-rw-r--r--05/main.l24
1 files changed, 24 insertions, 0 deletions
diff --git a/05/main.l b/05/main.l
new file mode 100644
index 0000000..ee13053
--- /dev/null
+++ b/05/main.l
@@ -0,0 +1,24 @@
1%{
2 int k = 0;
3 int o = 0;
4 int i = 0;
5%}
6
7%%
8int|main|printf|scanf|char|if|else|for|switch|case k++;
9[+*/%&=] o++;
10[a-zA-Z_][a-zA-Z0-9_]* i++;
11. ;
12\n ;
13%%
14
15int main(void) {
16 yylex();
17 printf("%d keywords\n", k);
18 printf("%d operators\n", o);
19 printf("%d identifiers\n", i);
20}
21
22int yywrap() {
23 return 1;
24}