Hi,
I was trying learn lex and yacc using the oreilly book. I tried following example from book, but it gives segmentation fault.
%{
/**
* A lexer for the basic grammar to use for recognizing English sentences.
*/
#include <stdio.h>
extern FILE *yyin;
%}
%token NOUN PRONOUN VERB ADVERB ADJECTIVE PREPOSITION CONJUNCTION
%%
sentence: subject VERB object{ printf("Sentence is valid.\n");}
;
subject: NOUN
| PRONOUN
;
object: NOUN
;
%%
main()
{
while(!feof(yyin)) {
yyparse();
}
}
yyerror(char *s)
{
fprintf(stderr, "%s\n", s);
}
i'm using flex and bison. I'm getting segmentation fault in main function, in the while loop. It is not entering at all to the loop.
Any thoughts? Thanks, Robert