brainfuck.y - brcon2024-hackathons - Bitreichcon 2024 Hackathons
 (HTM) git clone git://bitreich.org/brcon2024-hackathons git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/brcon2024-hackathons
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
       ---
       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