I got the solution to this problem. To anyone else facing same problem here is the solution.
for warning part add
#define YYSTYPE char * in the definition section of both file.l and file.y
For part 2)
The bison parser calls yylex() whenever it needs a token. So no need to run yylex(). just run yyparse();
so main function of file.l is
I am new to flex and bison. I am trying to write a simple grammar accepting the strings :a word in lowercase followed by a word in upper case. below are my files-
contents of file.txt is:
this is how i compile and run:
yacc -d file.y
gcc lex.yy.c y.tab.c -o file
The program gives warning warning: assignment makes integer from pointer without a cast [-Wint-conversion] yylval=yytext;
When I run the program (ignoring warning), the output is "found lower" i.e the program stops reading tokens after . Can anyone help and tell me why is this running like this?Also why is the warning generated even though i specified in file.y
How would i declare a pointer which points to 2d array of character pointers. like
In my understanding this array is stored as array of array, so ar points to array of pointers , each of which points to a column in this array. So it has three level of pointers. So it should be declared as
Thus both ar and p are of same type.
But if I use this p like 2d array for e.g. p, it gives error as segmentation fault. Why does this happen and what would be the correct way to declare p?