diff options
author | Akshay <[email protected]> | 2021-04-16 05:32:33 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-04-16 06:06:29 +0100 |
commit | 30047205e440e9ad8984e1830b8b819b5fe1f9f7 (patch) | |
tree | c30239e30d0687903cdd76a43630e7bc58d8dd4c /5 | |
parent | 5b54c1d51afad68d497a14d8c5e3a9fc852d5f20 (diff) |
add prog 5
Diffstat (limited to '5')
-rw-r--r-- | 5/input | 5 | ||||
-rw-r--r-- | 5/main.l | 24 |
2 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,5 @@ | |||
1 | int main() { | ||
2 | int one, two, three; | ||
3 | three = two + one; | ||
4 | printf(three); | ||
5 | } | ||
diff --git a/5/main.l b/5/main.l new file mode 100644 index 0000000..ee13053 --- /dev/null +++ b/5/main.l | |||
@@ -0,0 +1,24 @@ | |||
1 | %{ | ||
2 | int k = 0; | ||
3 | int o = 0; | ||
4 | int i = 0; | ||
5 | %} | ||
6 | |||
7 | %% | ||
8 | int|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 | |||
15 | int main(void) { | ||
16 | yylex(); | ||
17 | printf("%d keywords\n", k); | ||
18 | printf("%d operators\n", o); | ||
19 | printf("%d identifiers\n", i); | ||
20 | } | ||
21 | |||
22 | int yywrap() { | ||
23 | return 1; | ||
24 | } | ||