aboutsummaryrefslogtreecommitdiff
path: root/6/main.y
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-04-30 17:52:13 +0100
committerAkshay <[email protected]>2021-04-30 17:52:13 +0100
commit8a57bedc04fff7a92ef6d2762cfe5fc17050f021 (patch)
tree192ea2a1bd2eec0c0f84a9cb7adc9b10d005e1db /6/main.y
parent30047205e440e9ad8984e1830b8b819b5fe1f9f7 (diff)
add yacc programs
Diffstat (limited to '6/main.y')
-rw-r--r--6/main.y28
1 files changed, 28 insertions, 0 deletions
diff --git a/6/main.y b/6/main.y
new file mode 100644
index 0000000..25005df
--- /dev/null
+++ b/6/main.y
@@ -0,0 +1,28 @@
1%{
2#include <stdio.h>
3#include <stdlib.h>
4int yylex();
5int yyerror(char *);
6%}
7
8%token A B ERR
9
10%%
11
12S:
13 A S B
14 |
15 ;
16
17%%
18
19int yyerror(char *s) {
20 printf("error: %s", s);
21 exit(0);
22}
23
24int main() {
25 yyparse();
26 printf("valid string\n");
27 return 0;
28}