aboutsummaryrefslogtreecommitdiff
path: root/08
diff options
context:
space:
mode:
Diffstat (limited to '08')
-rw-r--r--08/input1
-rw-r--r--08/main.l14
-rw-r--r--08/main.y28
3 files changed, 43 insertions, 0 deletions
diff --git a/08/input b/08/input
new file mode 100644
index 0000000..5c11124
--- /dev/null
+++ b/08/input
@@ -0,0 +1 @@
aaaab
diff --git a/08/main.l b/08/main.l
new file mode 100644
index 0000000..ad755d5
--- /dev/null
+++ b/08/main.l
@@ -0,0 +1,14 @@
1%{
2extern int yylval;
3%}
4
5%%
6a return A;
7b return B;
8. return yytext[0];
9\n return 0;
10%%
11
12int yywrap() {
13 return 1;
14}
diff --git a/08/main.y b/08/main.y
new file mode 100644
index 0000000..04e98a7
--- /dev/null
+++ b/08/main.y
@@ -0,0 +1,28 @@
1%{
2#include <stdio.h>
3#include <stdlib.h>
4int yyerror(char *);
5%}
6
7%token A B
8%start S
9
10%%
11
12S: C B
13 |
14 ;
15C: A C
16 | A A A A
17 ;
18%%
19
20int main() {
21 yyparse();
22 printf("valid string");
23}
24
25int yyerror(char *s) {
26 printf("error: %s", s);
27 exit(0);
28}