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