First of all I have to make it clear that I am a beginner regarding flex and bison programming.
I'm trying to write a code recognizing a particular declaration part. Its syntax and logic can be understood by the flex and bison code, I present below:
%{
#include <stdio.h>
%}
[ \t\n]+ { /* Ignore all whitespace */ }
var { return VAR; }
real { return REAL; }
boolean { return BOOLEAN; }
integer { return INTEGER; }
char { return CHAR; }
[a-zA-Z][a-zA-Z0-9_]* { return VAR_NAME; }
. { return yytext[0]; }
%%
program : VAR typedecls ;
typedecls : typedecl | typedecls typedecl ;
typedecl : varlist ':' var_type ';' ;
varlist : VAR_NAME | varlist ',' VAR_NAME ;
var_type : REAL | BOOLEAN | INTEGER | CHAR ;
%%
main( argc, argv )
int argc;
char **argv;
{
++argv, --argc; /* skip over program name */
if ( argc > 0 )
yyin = fopen( argv[0], "r" );
else
yyin = stdin;
yylex();
}
The problem lies to compiling. When compiling on the terminal I get the following lines of errors:
What is going wrong with my code? How can I fix the errors?
I am looking forward to reading your answers!