bison's yyparse() several times (Hans Sundsfjord)
Thu, 19 May 1994 13:59:05 GMT

          From comp.compilers

Related articles
bison's yyparse() several times (1994-05-19)
Re: bison's yyparse() several times (1994-05-20)
Re: bison's yyparse() several times (1994-05-30)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Hans Sundsfjord)
Keywords: yacc, parse, comment
Organization: University of Tromsoe
Date: Thu, 19 May 1994 13:59:05 GMT


I'm building an interpreter using GNU Bison (1.19). I have a problem with
invoking the parser more than once from a program. It always works fine
the first time I call yyparse(), but it always gets a "parse error" when I
call it again.

Have I missed some initialization or buffer flushing or .... something else?

(I have run the same thing with yacc-made yyparse() before, without

Well, it looks like this....

FILE *infd;
FILE *outfd;

translate(char *in, char *out)

        if ((infd = fopen(in, "r")) == NULL)
            fprintf(stderr, "could not open input file: %s\n", in);
            return (-1);

        yyin = infd;

        if ((outfd = fopen(out, "w")) == NULL)
            fprintf(stderr, "could not open output file: %s\n", out);
            return (-1);

        yyout = outfd;


[I'd suspect a smashed pointer somewhere. If you don't need any of Bison's
unique features, you're probably better off with the smaller and faster
Berkeley Yacc anyway. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.