aboutsummaryrefslogtreecommitdiff
path: root/09
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-04-30 17:55:19 +0100
committerAkshay <[email protected]>2021-04-30 17:55:19 +0100
commitda1764a9f839e1d29b2bee12d35534f71f05c6ff (patch)
treed410c2191e571f9e6945ed88afd3faa1175675b3 /09
parent9ff0cec8b507d9164d8828dcb2a87012e140fdf5 (diff)
law & order
Diffstat (limited to '09')
-rw-r--r--09/input1
-rw-r--r--09/main.l15
-rw-r--r--09/main.y30
3 files changed, 46 insertions, 0 deletions
diff --git a/09/input b/09/input
new file mode 100644
index 0000000..01efb5e
--- /dev/null
+++ b/09/input
@@ -0,0 +1 @@
aaabbbbc
diff --git a/09/main.l b/09/main.l
new file mode 100644
index 0000000..7e888e9
--- /dev/null
+++ b/09/main.l
@@ -0,0 +1,15 @@
1%{
2extern int yylval;
3%}
4
5%%
6a return A;
7b return B;
8c return C;
9. return yytext[0];
10\n return 0;
11%%
12
13int yywrap() {
14 return 1;
15}
diff --git a/09/main.y b/09/main.y
new file mode 100644
index 0000000..0db29c1
--- /dev/null
+++ b/09/main.y
@@ -0,0 +1,30 @@
1%{
2#include <stdio.h>
3#include <stdlib.h>
4int yylex();
5int yyerror(char *);
6%}
7
8%token A B C
9
10%%
11S: X Y
12 |
13 ;
14X: A X B
15 |
16 ;
17Y: B Y C
18 |
19 ;
20%%
21
22int main() {
23 yyparse();
24 printf("valid string");
25}
26
27int yyerror(char *s) {
28 printf("error: %s", s);
29 exit(0);
30}