This is my first time trying out BISON and I'm stuck trying to figure out how to take a complete statement for example astros = 2
. Whenever I try to do that, I don't get any output. But if I try each part separately then I get output for each part. My code is as follow, just part of it of course:
.y file
%token ASSIGNMENT
%token <intToken> INTNUMBER
%token <intToken> INTTOKEN
%type <statement> STATEMENT
STATEMENT: '\n'
| INTTOKEN STATEMENT {printf("Token");}
| INTNUMBER STATEMENT {printf("Number");}
| STATEMENT ASSIGNMENT STATEMENT{printf("Assinging");}
| INTTOKEN '\t' ASSIGNMENT '\t' INTNUMBER STATEMENT {printf("FULL STATEMENT COMPLETE");}
|error {yyerror("ERROR");}
My .l file:
"=" return ASSIGNMENT;
[0-9]+ { ECHO; yylval.integer = atoi(yytext); return INTNUMBER; }
[a-fA-F]+[a-zA-Z]+ { ECHO; yylval.variableInteger = yytext; return INTTOKEN; }
Also if someone could explain me how the rules of the tokens work then that would be great. Maybe like that I can figure it by myself.