Introduction
Introduction Statistics Contact Development Disclaimer Help
brainfuck.y - brcon2024-hackathons - Bitreichcon 2024 Hackathons
git clone git://bitreich.org/brcon2024-hackathons git://enlrupgkhuxnvlhsf6lc3fz…
Log
Files
Refs
Tags
Submodules
---
brainfuck.y (860B)
---
1 %{
2 #include <stdio.h>
3
4 void yyerror(const char *s);
5 int yylex(void);
6
7 %}
8
9 %token INCPTR DECPTR INCVAL DECVAL OUTPUT INPUT LOOPSTART LOOPEND
10
11 %%
12
13 program:
14 /* empty */
15 | program command
16 ;
17
18 command:
19 INCPTR { printf("Move pointer to the right\n"); }
20 | DECPTR { printf("Move pointer to the left\n"); }
21 | INCVAL { printf("Increment the value at the pointer\n"); }
22 | DECVAL { printf("Decrement the value at the pointer\n"); }
23 | OUTPUT { printf("Output the value at the pointer\n"); }
24 | INPUT { printf("Input a value and store it at the pointer\n");…
25 | loop
26 ;
27
28 loop:
29 LOOPSTART program LOOPEND
30 {
31 printf("Start of loop\n");
32 printf("End of loop\n");
33 }
34 ;
35
36 %%
37
38 void yyerror(const char *s) {
39 fprintf(stderr, "Error: %s\n", s);
40 }
41
42 int main(void) {
43 return yyparse();
44 }
45
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.