help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

yacc2bison: int/int * confusion causes segfault


From: Tom Jones
Subject: yacc2bison: int/int * confusion causes segfault
Date: Mon, 26 Mar 2007 10:11:53 -0700

Hello,

I am a neophyte trying to convert a yacc grammar to bison.  The grammar
in question runs fine with yacc but my requirements are to be able to
run under linux and/or cygwinix - I'd rather fix the grammar for bison
than try to find a yacc executable for win32.

Anyway, I had some initial problems getting YYSTYPE properly defined for
yylval - perhaps they're not completely resolved.  YYSTYPE is a union
here but defined in a two stage process.  To get past the compiler
errors I merely #defined YYSTYPE right after the union declaration
inside the .h file that defines the union.

If I run the resultant parser I get a segfault but the compiler warnings
are a pretty good clue to what's happening:

   warning: passing arg 1 of `stricmp' makes pointer from integer
without a cast

What's happening is bison is creating an 'int yytoken' - however, the
hand-rolled lexical analyzer already declared a char *yytoken (it's
actually a fixed array).  If I comment out the "int yytoken" it compiles
with fewer warnings but there is clearly a cognitive dissonance here.

Any help on this matter would be greatly appreciated.

~Tom




reply via email to

[Prev in Thread] Current Thread [Next in Thread]